reactive-banana-0.8.0.4: Library for functional reactive programming (FRP).

Safe HaskellNone
LanguageHaskell98

Reactive.Banana.Experimental.Calm

Contents

Synopsis

Synopsis

Experimental module: API change very likely.

Event type that disallows simultaneous event occurrences.

The combinators behave essentially as their counterparts in Reactive.Banana.Combinators.

Main types

data Event t a Source

Instances

collect :: Event t a -> Event t [a] Source

Convert event with possible simultaneous occurrences into an Event with a single occurrence.

fromCalm :: Event t a -> Event t a Source

Convert event with single occurrences into event with possible simultaneous occurrences

interpret :: (forall t. Event t a -> Event t b) -> [a] -> IO [Maybe b] Source

Interpretation function. Useful for testing.

Core Combinators

never :: Event t a Source

Event that never occurs. Think of it as never = [].

unionWith :: (a -> a -> a) -> Event t a -> Event t a -> Event t a Source

Merge two event streams of the same type. Combine simultaneous values if necessary.

filterE :: (a -> Bool) -> Event t a -> Event t a Source

Allow all events that fulfill the predicate, discard the rest.

accumE :: a -> Event t (a -> a) -> Event t a Source

The accumE function accumulates a stream of events.

apply :: Behavior t (a -> b) -> Event t a -> Event t b Source

Apply a time-varying function to a stream of events.

stepper :: a -> Event t a -> Behavior t a Source

Construct a time-varying function from an initial value and a stream of new values.

Derived Combinators

Filtering

filterJust :: Event t (Maybe a) -> Event t a Source

Keep only the Just values. Variant of filterE.

Accumulation

Note: all accumulation functions are strict in the accumulated value! acc -> (x,acc) is the order used by unfoldr and State.

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

The accumB function is similar to a strict left fold, foldl'. It starts with an initial value and combines it with incoming events.

mapAccum :: acc -> Event t (acc -> (x, acc)) -> (Event t x, Behavior t acc) Source

Efficient combination of accumE and accumB.

Apply class

(<@>) :: Behavior t (a -> b) -> Event t a -> Event t b Source

Infix synonym for the apply combinator. Similar to <*>.

(<@) :: Behavior t a -> Event t b -> Event t a Source

Tag all event occurrences with a time-varying value. Similar to <*.