Portability | non-portable (TF,GNTD) |
---|---|

Stability | experimental |

Maintainer | hans@hanshoglund.se |

Safe Haskell | None |

Reactive values, or piecewise functions of time.

Similar to Conal's definition in http://conal.net/blog/posts/reactive-normal-form,
but defined in negative time as well. Its semantics function is either `occs`

`&&&`

`?`

*or* `initial`

`&&&`

`updates`

, where `intial`

is the value from negative infinity
to the first update.

TODO integrate better in the library

- data Reactive a
- initial :: Reactive a -> a
- final :: Reactive a -> a
- type Future a = (Time, a)
- type Past a = (Time, a)
- updates :: Reactive a -> [Future a]
- resets :: Reactive a -> [Past a]
- occs :: Reactive a -> [Time]
- isConstant :: Reactive a -> Bool
- isVariable :: Reactive a -> Bool
- step :: (AdditiveGroup a, Fractional a) => Reactive a
- switch :: Time -> Reactive a -> Reactive a -> Reactive a
- trim :: Monoid a => Span -> Reactive a -> Reactive a
- trimBefore :: Monoid a => Time -> Reactive a -> Reactive a
- trimAfter :: Monoid a => Time -> Reactive a -> Reactive a

# Documentation

Functor Reactive | |

Applicative Reactive | |

HasBehavior Reactive | |

Enum a => Enum (Reactive a) | |

Eq (Reactive b) | |

Floating b => Floating (Reactive b) | |

Fractional b => Fractional (Reactive b) | |

Integral a => Integral (Reactive a) | |

Num a => Num (Reactive a) | |

Ord b => Ord (Reactive b) | |

(Num a, Ord a) => Real (Reactive a) | |

IsString a => IsString (Reactive a) | |

Monoid a => Monoid (Reactive a) | |

Semigroup a => Semigroup (Reactive a) | |

Wrapped (Reactive a) | |

VectorSpace v => VectorSpace (Reactive v) | |

AdditiveGroup v => AdditiveGroup (Reactive v) | |

Delayable (Reactive a) | |

Stretchable (Reactive a) |

# Create, isos etc (TODO)

updates :: Reactive a -> [Future a]Source

Get the time of all updates and the value switched to at this point.

# Predicates

isConstant :: Reactive a -> BoolSource

isVariable :: Reactive a -> BoolSource

# Combinators

step :: (AdditiveGroup a, Fractional a) => Reactive aSource

The unit step function, which goes from 0 to 1 at `start`

.

switch :: Time -> Reactive a -> Reactive a -> Reactive aSource

`switch t a b`

behaves as `a`

before time `t`

, then as `b`

.

trim :: Monoid a => Span -> Reactive a -> Reactive aSource

Replace everthing outside the given span by `mempty`

.

trimBefore :: Monoid a => Time -> Reactive a -> Reactive aSource

Replace everthing before the given time by `mempty`

.

trimAfter :: Monoid a => Time -> Reactive a -> Reactive aSource

Replace everthing after the given time by `mempty`

.