reactive-0.8.6: Simple foundation for functional reactive programmingSource codeContentsIndex
FRP.Reactive.Reactive
Stabilityexperimental
Maintainerconal@conal.net
Contents
Event
Reactive values
Re-export
Tests
Description
Simple reactive values. Adds some extra functionality on top of FRP.Reactive.PrimReactive
Synopsis
module FRP.Reactive.PrimReactive
type TimeT = Double
type ITime = Improving TimeT
type Future = FutureG ITime
traceF :: Functor f => (a -> String) -> f a -> f a
type Event = EventG ITime
withTimeE :: Event a -> Event (a, TimeT)
atTime :: TimeT -> Event ()
atTimes :: [TimeT] -> Event ()
listE :: [(TimeT, a)] -> Event a
pairE :: Ord t => (c, d) -> (EventG t c, EventG t d) -> EventG t (c, d)
scanlE :: Ord t => (a -> b -> a) -> a -> EventG t b -> EventG t a
monoidE :: (Ord t, Monoid o) => EventG t o -> EventG t o
withPrevE :: Ord t => EventG t a -> EventG t (a, a)
withPrevEWith :: Ord t => (a -> a -> b) -> EventG t a -> EventG t b
stateE :: Ord t => s -> (s -> s) -> EventG t b -> EventG t (b, s)
stateE_ :: Ord t => s -> (s -> s) -> EventG t b -> EventG t s
countE :: (Ord t, Num n) => EventG t b -> EventG t (b, n)
countE_ :: (Ord t, Num n) => EventG t b -> EventG t n
diffE :: (Ord t, Num n) => EventG t n -> EventG t n
type Reactive = ReactiveG ITime
type Source = Reactive
snapshot_ :: Ord t => EventG t a -> ReactiveG t b -> EventG t b
snapshot :: Ord t => EventG t a -> ReactiveG t b -> EventG t (a, b)
whenE :: Ord t => EventG t a -> ReactiveG t Bool -> EventG t a
scanlR :: Ord t => (a -> b -> a) -> a -> EventG t b -> ReactiveG t a
monoidR :: (Ord t, Monoid a) => EventG t a -> ReactiveG t a
eitherE :: Ord t => EventG t a -> EventG t b -> EventG t (Either a b)
maybeR :: Ord t => EventG t a -> EventG t b -> ReactiveG t (Maybe a)
flipFlop :: Ord t => EventG t a -> EventG t b -> ReactiveG t Bool
countR :: (Ord t, Num n) => EventG t a -> ReactiveG t n
splitE :: Ord t => EventG t a -> EventG t b -> EventG t (a, EventG t b)
switchE :: Event (Event a) -> Event a
integral :: forall v t. (Num t, VectorSpace v t) => t -> Event t -> Reactive v -> Reactive v
sumR :: VectorSpace v s => Event v -> Reactive v
exact :: Improving a -> a
batch :: TestBatch
Documentation
module FRP.Reactive.PrimReactive
type TimeT = DoubleSource
The type of finite time values.
type ITime = Improving TimeTSource
Improving doubles, as used for time values in Event, Reactive, and ReactiveB.
type Future = FutureG ITimeSource
Type of future values. Specializes FutureG.
traceF :: Functor f => (a -> String) -> f a -> f aSource
Trace the elements of a functor type.
Event
type Event = EventG ITimeSource
Events, specialized to improving doubles for time
withTimeE :: Event a -> Event (a, TimeT)Source
Access occurrence times in an event. See withTimeGE for more general notions of time.
atTime :: TimeT -> Event ()Source
Single-occurrence event at given time. See atTimes and atTimeG.
atTimes :: [TimeT] -> Event ()Source
Event occuring at given times. See also atTime and atTimeG.
listE :: [(TimeT, a)] -> Event aSource
Convert a temporally monotonic list of timed values to an event. See also the generalization listEG
pairE :: Ord t => (c, d) -> (EventG t c, EventG t d) -> EventG t (c, d)Source
Generate a pair-valued event, given a pair of initial values and a pair of events. See also pair on Reactive.
scanlE :: Ord t => (a -> b -> a) -> a -> EventG t b -> EventG t aSource
Like scanl for events.
monoidE :: (Ord t, Monoid o) => EventG t o -> EventG t oSource
Accumulate values from a monoid-typed event. Specialization of scanlE, using mappend and mempty.
withPrevE :: Ord t => EventG t a -> EventG t (a, a)Source
Pair each event value with the previous one. The second result is the old one. Nothing will come out for the first occurrence of e, but if you have an initial value a, you can do withPrevE (pure a mappend e).
withPrevEWith :: Ord t => (a -> a -> b) -> EventG t a -> EventG t bSource
Same as withPrevE, but allow a function to combine the values. Provided for convenience.
stateE :: Ord t => s -> (s -> s) -> EventG t b -> EventG t (b, s)Source
State machine, given initial value and transition function. Carries along event data. See also stateE_. TODO: better name.
stateE_ :: Ord t => s -> (s -> s) -> EventG t b -> EventG t sSource
State machine, given initial value and transition function. See also stateE.
countE :: (Ord t, Num n) => EventG t b -> EventG t (b, n)Source
Count occurrences of an event, remembering the occurrence values. See also countE_.
countE_ :: (Ord t, Num n) => EventG t b -> EventG t nSource
Count occurrences of an event, forgetting the occurrence values. See also countE.
diffE :: (Ord t, Num n) => EventG t n -> EventG t nSource
Difference of successive event occurrences. See withPrevE for a trick to supply an initial previous value.
Reactive values
type Reactive = ReactiveG ITimeSource
Reactive values, specialized to improving doubles for time
type Source = ReactiveSource
Compatibility synonym (for ease of transition from DataDriven)
snapshot_ :: Ord t => EventG t a -> ReactiveG t b -> EventG t bSource
Like snapshot but discarding event data (often a is '()').
snapshot :: Ord t => EventG t a -> ReactiveG t b -> EventG t (a, b)Source
Snapshot a reactive value whenever an event occurs.
whenE :: Ord t => EventG t a -> ReactiveG t Bool -> EventG t aSource
Filter an event according to whether a reactive boolean is true.
scanlR :: Ord t => (a -> b -> a) -> a -> EventG t b -> ReactiveG t aSource
Like scanl for reactive values. See also scanlE.
monoidR :: (Ord t, Monoid a) => EventG t a -> ReactiveG t aSource
Accumulate values from a monoid-valued event. Specialization of scanlE, using mappend and mempty. See also monoidE.
eitherE :: Ord t => EventG t a -> EventG t b -> EventG t (Either a b)Source
Combine two events into one.
maybeR :: Ord t => EventG t a -> EventG t b -> ReactiveG t (Maybe a)Source
Start out blank (Nothing), latching onto each new a, and blanking on each b. If you just want to latch and not blank, then use mempty for lose.
flipFlop :: Ord t => EventG t a -> EventG t b -> ReactiveG t BoolSource
Flip-flopping reactive value. Turns true when ea occurs and false when eb occurs.
countR :: (Ord t, Num n) => EventG t a -> ReactiveG t nSource
Count occurrences of an event. See also countE.
splitE :: Ord t => EventG t a -> EventG t b -> EventG t (a, EventG t b)Source
Partition an event into segments.
switchE :: Event (Event a) -> Event aSource
Switch from one event to another, as they occur. (Doesn't merge, as join does.)
integral :: forall v t. (Num t, VectorSpace v t) => t -> Event t -> Reactive v -> Reactive vSource
Euler integral.
sumR :: VectorSpace v s => Event v -> Reactive vSource
Re-export
exact :: Improving a -> aSource
Tests
batch :: TestBatchSource
Produced by Haddock version 2.3.0