reactive-banana-0.7.1.3: Practical library for functional reactive programming (FRP).

Safe HaskellNone

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 aSource

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 aSource

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

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

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

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

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

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

The accumE function accumulates a stream of events.

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

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

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

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 aSource

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 aSource

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

class (Functor f, Functor g) => Apply f g whereSource

Class for overloading the apply function.

Methods

(<@>) :: f (a -> b) -> g a -> g bSource

Infix operation for the apply function, similar to <*>

(<@) :: f a -> g b -> g aSource

Convenience function, similar to <*

Instances

Apply (Behavior t) (Event t) 
Apply (Behavior t) (Event t)