FRP.Reactive.Behavior (original) (raw)

Description

Reactive behaviors (continuous time)

Synopsis

Documentation

data BehaviorG tr tf a Source

Reactive behaviors. They can be understood in terms of a simple model (denotational semantics) as functions of time, namely at :: BehaviorG t a -> (t -> a).

The semantics of [BehaviorG](FRP-Reactive-Behavior.html#t:BehaviorG) instances are given by corresponding instances for the semantic model (functions). Seehttp://conal.net/blog/posts/simplifying-semantics-with-type-class-morphisms/.

type Behavior = BehaviorI TimeTSource

Time-specialized behaviors. Note: The signatures of all of the behavior functions can be generalized. Is the interface generality worth the complexity?

time :: Ord t => BehaviorI t tSource

The identity generalized behavior. Has value t at time t.

time :: Behavior TimeT

stepper :: a -> EventI t a -> BehaviorI t aSource

Discretely changing behavior, based on an initial value and a new-value event.

stepper :: a -> Event a -> Behavior a

snapshotWith :: Ord t => (a -> b -> c) -> BehaviorI t b -> EventI t a -> EventI t cSource

Snapshots a behavior whenever an event occurs and combines the values using the combining function passed. Take careful note of the order of arguments and results.

snapshotWith :: (a -> b -> c) -> Behavior b -> Event a -> Event c

snapshot :: Ord t => BehaviorI t b -> EventI t a -> EventI t (a, b)Source

Snapshot a behavior whenever an event occurs. See also[snapshotWith](FRP-Reactive-Behavior.html#v:snapshotWith). Take careful note of the order of arguments and results.

snapshot :: Behavior b -> Event a -> Event (a,b)

snapshot_ :: Ord t => BehaviorI t b -> EventI t a -> EventI t bSource

Like [snapshot](FRP-Reactive-Behavior.html#v:snapshot) but discarding event data (often a is '()').

snapshot_ :: Behavior b -> Event a -> Event b

whenE :: Ord t => BehaviorI t Bool -> EventI t a -> EventI t aSource

Filter an event according to whether a reactive boolean is true.

whenE :: Behavior Bool -> Event a -> Event a

accumB :: a -> EventI t (a -> a) -> BehaviorI t aSource

Behavior from an initial value and an updater event. See alsoaccumE.

accumB :: a -> Event (a -> a) -> Behavior a

maybeB :: Ord t => EventI t a -> EventI t b -> BehaviorI t (Maybe a)Source

Start out blank ([Nothing](/packages/archive/base/4.2.0.2/doc/html/Data-Maybe.html#v:Nothing)), latching onto each new a, and blanking on each b. If you just want to latch and not blank, then use[mempty](/packages/archive/base/4.2.0.2/doc/html/Data-Monoid.html#v:mempty) for the second event.

maybeB :: Event a -> Event b -> Behavior (Maybe a)

flipFlop :: Ord t => EventI t a -> EventI t b -> BehaviorI t BoolSource

Flip-flopping behavior. Turns true whenever first event occurs and false whenever the second event occurs.

flipFlop :: Event a -> Event b -> Behavior Bool

countB :: (Ord t, Num n) => EventI t a -> BehaviorI t nSource

Count occurrences of an event. See also countE.

countB :: Num n => Event a -> Behavior n