Copyright | (c) 2017 Ertugrul Söylemez |
---|---|
License | BSD3 |
Maintainer | Ertugrul Söylemez <esz@posteo.de> |
Stability | experimental |
Safe Haskell | None |
Language | Haskell2010 |
- data Wire m a b
- evalWith :: Applicative m => (forall b. a -> b -> b) -> Wire m a a
- initial :: Applicative m => Wire m (m a) a
- withM :: Monad m => (s -> Wire m a b) -> (a -> m s) -> Wire m a b
- data Event a
- catMapE :: (a -> Maybe b) -> Event a -> Event b
- hold :: Applicative m => a -> Wire m (Event a) a
- hold' :: Applicative m => a -> Wire m (Event a) a
- never :: Event a
- unfoldE :: Applicative m => s -> Wire m (Event (s -> (a, s))) (Event a)
- newtype Switch f m a b = Switch {
- fromSwitch :: forall s. (Wire m a b -> s) -> f s -> f s
- manage :: (Traversable f, Applicative m) => f (Wire m a b) -> Wire m (a, Event (Switch f m a b)) (f b)
- manage' :: (Traversable f, Applicative m) => f (Wire m a b) -> Wire m (a, Event (Switch f m a b)) (f b)
- sequenceW :: (Traversable f, Applicative m) => f (Wire m a b) -> Wire m a (f b)
- switch :: Functor m => Wire m a (b, Event (Wire m a b)) -> Wire m a b
- switch' :: Monad m => Wire m a (b, Event (Wire m a b)) -> Wire m a b
- hoistW :: Functor m => (a -> a') -> (forall x. a -> m' x -> m x) -> Wire m' a' b -> Wire m a b
Wires
Wire
is a language for defining reactive systems. It is similar
to the underlying monad m
, but runs continuously.
Monad m => Arrow (Wire m) Source # | |
Monad m => ArrowChoice (Wire m) Source # | |
MonadFix m => ArrowLoop (Wire m) Source # | |
Applicative m => Choice (Wire m) Source # | |
Functor m => Strong (Wire m) Source # | |
MonadFix m => Costrong (Wire m) Source # | |
Functor m => Profunctor (Wire m) Source # | |
Monad m => Category * (Wire m) Source # | |
Functor m => Functor (Wire m a) Source # | |
Applicative m => Applicative (Wire m a) Source # | |
evalWith :: Applicative m => (forall b. a -> b -> b) -> Wire m a a Source #
Evaluate the input using the given strategy in every frame. Valid
arguments include functions like seq
.
initial :: Applicative m => Wire m (m a) a Source #
Run the given action once at the beginning.
withM :: Monad m => (s -> Wire m a b) -> (a -> m s) -> Wire m a b Source #
Run the given action to initialise the given wire. Example:
withM (scan f) actionFromInitialInput
Events
An event is a timestamped stream of occurrences with payloads of the given type.
catMapE :: (a -> Maybe b) -> Event a -> Event b Source #
Map and filter event occurrences using the given function.
hold :: Applicative m => a -> Wire m (Event a) a Source #
Hold the latest occurrence of the given event starting with the given initial value. The value switch occurs in the next frame.
hold' :: Applicative m => a -> Wire m (Event a) a Source #
Hold the latest occurrence of the given event starting with the given initial value. The value switch occurs instantly.
unfoldE :: Applicative m => s -> Wire m (Event (s -> (a, s))) (Event a) Source #
Unfold the given event using the state transition functions it carries.
Switching
newtype Switch f m a b Source #
Functions to be applied to the current set of wires managed by
manage
.
Switch | |
|
manage :: (Traversable f, Applicative m) => f (Wire m a b) -> Wire m (a, Event (Switch f m a b)) (f b) Source #
Sequence each of the given wires and collect their results. Whenever the given event occurs its function is applied to the current set of wires. Changes are applied in the next frame.
manage' :: (Traversable f, Applicative m) => f (Wire m a b) -> Wire m (a, Event (Switch f m a b)) (f b) Source #
Sequence each of the given wires and collect their results. Whenever the given event occurs its function is applied to the current set of wires. Changes are applied immediately.
sequenceW :: (Traversable f, Applicative m) => f (Wire m a b) -> Wire m a (f b) Source #
Sequence each of the given wires and collect their results.
switch :: Functor m => Wire m a (b, Event (Wire m a b)) -> Wire m a b Source #
Acts like the given wire until its event occurs, then switches to the wire the occurrence contained. The switch occurs in the next frame.
switch' :: Monad m => Wire m a (b, Event (Wire m a b)) -> Wire m a b Source #
Acts like the given wire until its event occurs, then switches to the wire the occurrence contained. The switch occurs immediately.