Safe Haskell | Trustworthy |
---|---|
Language | Haskell98 |
A different presentation of functional reactive programming, based on the Reactive library on Hackage. Push-pull FRP is due to Conal Elliott. The functionals here are directly based on those from Reactive.
- tick :: EventStream e => POSIXTime -> POSIXTime -> e POSIXTime
- untilE :: EventStream e => e t -> e u -> e t
- eitherOf :: (Functor e, MonadPlus e) => e t -> e u -> e (Either t u)
- holdE :: EventStream e => e t -> e u -> u -> e (t, u)
- zipE :: EventStream f => f t -> t -> f t1 -> t1 -> f (t, t1)
- simultE :: EventStream e => e t -> e u -> e (t, Maybe u)
- intersectE :: EventStream f => f (a -> b) -> f a -> f b
- differenceE :: EventStream f => f b -> f b1 -> f b
- unionE :: (EventStream e, Monoid t) => e t -> e t -> e t
- filterE :: (Alternative m, Monad m) => (b -> Bool) -> m b -> m b
- justE :: (Alternative f, Monad f) => f (Maybe b) -> f b
- duplicateE :: EventStream m => m a -> m (m a)
- withPrev :: EventStream f => f t -> f (t, t)
- calmE :: EventStream f => f b -> f b
- count :: (EventStream e, Num t1) => e t -> e (t, t1)
- takeE :: (EventStream e, Num n, Ord n) => n -> e t -> e t
- dropE :: (EventStream f, Ord b1, Num b1) => b1 -> f b -> f b
- once :: EventStream e => e t -> e t
- everyNth :: (EventStream e, Num n, Ord n) => n -> e t -> e t
- slowE :: EventStream m => POSIXTime -> m b -> m b
- rests :: EventStream e => e a -> e t -> e (t, e a)
- startAt :: EventStream m => m b -> m a -> m b
- splitE :: EventStream e => e t -> e u -> e (e t)
- data Behavior e t
- extractB :: Behavior t t1 -> t1
- duplicateB :: EventStream e => Behavior e t -> Behavior e (Behavior e t)
- time :: MonadPlus e => Behavior e POSIXTime
- switcher :: EventStream e => Behavior e t -> e (Behavior e t) -> Behavior e t
- stepper :: Functor e => t -> e t -> Behavior e t
- snapshot :: EventStream f => f t -> Behavior f t1 -> f (t, t1)
- flipFlop :: MonadPlus e => e b -> e b1 -> Behavior e Bool
- history :: EventStream e => Double -> Behavior e t -> Behavior e (POSIXTime -> t)
- scanB :: EventStream e => Behavior e (t -> e t) -> t -> e t
- delayB :: EventStream e => POSIXTime -> Behavior e c -> Behavior e c
- slow :: EventStream e => POSIXTime -> Behavior e c -> Behavior e c
- monoid :: (EventStream e, Monoid t) => e (Behavior e t) -> Behavior e t
- throttle :: EventStream e => Double -> e t -> Behavior e (Maybe t)
- sumE :: Num t => Event t -> Event t
- derivative :: (EventStream e, Real t, Fractional t) => Behavior e t -> Behavior e t
- supersample :: (EventStream e, Real t, Fractional t) => Double -> Behavior e t -> e (POSIXTime, t)
- integral :: (Real t, Fractional t) => Double -> Behavior Event t -> Behavior Event t
- threshold :: (EventStream e, Real t, Fractional t) => Double -> Behavior e t -> t -> e Bool
Derived event combinators
tick :: EventStream e => POSIXTime -> POSIXTime -> e POSIXTime Source #
A convenience to generate a tick on a regular interval.
untilE :: EventStream e => e t -> e u -> e t Source #
This functional can be used to terminate an event early.
holdE :: EventStream e => e t -> e u -> u -> e (t, u) Source #
Give the event times of e
, but latching onto the ticks of e2
. Prior to e2
ticking, gives x
.
zipE :: EventStream f => f t -> t -> f t1 -> t1 -> f (t, t1) Source #
simultE :: EventStream e => e t -> e u -> e (t, Maybe u) Source #
Pair values from e
to simultaneous occurrences from a
. Multiple occurrences
are paired up as with zip
. Excess occurrences from a
are discarded, while
excess WithAtoms falses atomsoccurrences from e
are paired with 'N(E simultE #-)
intersectE :: EventStream f => f (a -> b) -> f a -> f b Source #
differenceE :: EventStream f => f b -> f b1 -> f b Source #
Set-theoretical operations on event streams
unionE :: (EventStream e, Monoid t) => e t -> e t -> e t Source #
duplicateE :: EventStream m => m a -> m (m a) Source #
withPrev :: EventStream f => f t -> f (t, t) Source #
calmE :: EventStream f => f b -> f b Source #
Calms an event stream so that only one event occurs at a given time.
count :: (EventStream e, Num t1) => e t -> e (t, t1) Source #
once :: EventStream e => e t -> e t Source #
slowE :: EventStream m => POSIXTime -> m b -> m b Source #
rests :: EventStream e => e a -> e t -> e (t, e a) Source #
Get the remainder events of e
looking forward from particular occurrences in a
startAt :: EventStream m => m b -> m a -> m b Source #
Waits until a
ticks before it starts ticking.
splitE :: EventStream e => e t -> e u -> e (e t) Source #
Divides e
into chunks based on the ticks of a
, and returns those chunks in an event stream.
The occurrences of e
prior to the first occurrence of a
are omitted.
Reactive behaviors
Functor e => Functor (Behavior e) Source # | |
EventStream e => Applicative (Behavior e) Source # | |
EventStream e => Alternative (Behavior e) Source # | |
(EventStream e, Monoid t) => Monoid (Behavior e t) Source # | |
duplicateB :: EventStream e => Behavior e t -> Behavior e (Behavior e t) Source #
snapshot :: EventStream f => f t -> Behavior f t1 -> f (t, t1) Source #
history :: EventStream e => Double -> Behavior e t -> Behavior e (POSIXTime -> t) Source #
Keep a history of t
seconds as a "moving window" -- giving values for
the behavior, t
seconds prior to the current time. Outside of this
moving window, gives a constant behavior.
This functional should be enough for all "history-dependent" behaviors -- there
should be some t
which is a constant bound on a behavior's history,
in order to conserve memory.
scanB :: EventStream e => Behavior e (t -> e t) -> t -> e t Source #
A scan for behaviors.
delayB :: EventStream e => POSIXTime -> Behavior e c -> Behavior e c Source #
Delay by t
seconds before continuing as the behavior.
slow :: EventStream e => POSIXTime -> Behavior e c -> Behavior e c Source #
Slow down the behavior by a factor of x
.
monoid :: (EventStream e, Monoid t) => e (Behavior e t) -> Behavior e t Source #
Collect the event occurrences and add them together into a single behavior, using a monoid.
throttle :: EventStream e => Double -> e t -> Behavior e (Maybe t) Source #
Each event occurrence casts a shadow for t
seconds in the behavior.
derivative :: (EventStream e, Real t, Fractional t) => Behavior e t -> Behavior e t Source #
Estimate the derivative of a behavior.
supersample :: (EventStream e, Real t, Fractional t) => Double -> Behavior e t -> e (POSIXTime, t) Source #
Adaptively supersample a behavior.
integral :: (Real t, Fractional t) => Double -> Behavior Event t -> Behavior Event t Source #
Integral of behaviors
threshold :: (EventStream e, Real t, Fractional t) => Double -> Behavior e t -> t -> e Bool Source #
Given a differentiable behavior, find the times at which a certain value could be found. The result is an event which ticks when (an approximation of) the value is encountered.