Maintainer | Ertugrul Soeylemez <es@ertes.de> |
---|---|
Safe Haskell | None |
This is the core module implementing the Wire
type.
- data Wire e m a b
- type Time = Double
- mkFix :: (Time -> a -> Either e b) -> Wire e m a b
- mkFixM :: Monad m => (Time -> a -> m (Either e b)) -> Wire e m a b
- mkGen :: (Time -> a -> m (Either e b, Wire e m a b)) -> Wire e m a b
- mkPure :: (Time -> a -> (Either e b, Wire e m a b)) -> Wire e m a b
- mkState :: s -> (Time -> (a, s) -> (Either e b, s)) -> Wire e m a b
- mkStateM :: Monad m => s -> (Time -> (a, s) -> m (Either e b, s)) -> Wire e m a b
- constant :: b -> Wire e m a b
- identity :: Wire e m a a
- never :: Monoid e => Wire e m a b
- mapOutput :: Monad m => (Either e b' -> Either e b) -> Wire e m a b' -> Wire e m a b
- stepWire :: Monad m => Wire e m a b -> Time -> a -> m (Either e b, Wire e m a b)
- stepWireP :: Wire e Identity a b -> Time -> a -> (Either e b, Wire e Identity a b)
Wires
A wire is a signal function from an input value of type a
that
either produces an output value of type b
or inhibits with a
value of type e
. The underlying monad is m
.
Constructing wires
mkFix :: (Time -> a -> Either e b) -> Wire e m a bSource
Construct a pure stateless wire from the given function.
mkFixM :: Monad m => (Time -> a -> m (Either e b)) -> Wire e m a bSource
Construct a stateless effectful wire from the given function.
mkGen :: (Time -> a -> m (Either e b, Wire e m a b)) -> Wire e m a bSource
Construct an effectful wire from the given function.
mkPure :: (Time -> a -> (Either e b, Wire e m a b)) -> Wire e m a bSource
Construct a pure wire from the given function.
mkState :: s -> (Time -> (a, s) -> (Either e b, s)) -> Wire e m a bSource
Construct a pure wire from the given local state transision function.
mkStateM :: Monad m => s -> (Time -> (a, s) -> m (Either e b, s)) -> Wire e m a bSource
Construct a monadic wire from the given local state transision function.
Simple predefined wires
Helper functions
mapOutput :: Monad m => (Either e b' -> Either e b) -> Wire e m a b' -> Wire e m a bSource
Map the given function over the raw wire output.