Maintainer | Ertugrul Soeylemez <es@ertes.de> |
---|
Arrowized FRP implementation for networking applications. The aim of this library is to provide a convenient FRP implementation, which should enable you to write entirely pure network sessions.
- data Wire
- type Output = Either SomeException
- type Time = Double
- data WireState where
- mkGen :: (WireState m -> a -> m (Output b, Wire m a b)) -> Wire m a b
- toGen :: Monad m => Wire m a b -> WireState m -> a -> m (Output b, Wire m a b)
- data Session m a b
- stepWire :: MonadControlIO m => a -> Session m a b -> m (Output b)
- stepWireDelta :: MonadControlIO m => NominalDiffTime -> a -> Session m a b -> m (Output b)
- stepWireTime :: MonadControlIO m => UTCTime -> a -> Session m a b -> m (Output b)
- withWire :: (MonadControlIO m, MonadIO sm) => Wire sm a b -> (Session sm a b -> m c) -> m c
- testWire :: forall a b m. (MonadControlIO m, Show b) => Int -> m a -> Wire m a b -> m ()
- testWireStr :: forall a m. MonadControlIO m => Int -> m a -> Wire m a String -> m ()
- type SF = Wire Identity
- stepSF :: Time -> a -> SF a b -> (Output b, SF a b)
- stepWirePure :: Monad m => Time -> a -> Wire m a b -> m (Output b, Wire m a b)
- data InhibitException = InhibitException String
- inhibitEx :: String -> SomeException
- noEvent :: SomeException
- module FRP.NetWire.Analyze
- module FRP.NetWire.Calculus
- module FRP.NetWire.Event
- module FRP.NetWire.IO
- module FRP.NetWire.Random
- module FRP.NetWire.Request
- module FRP.NetWire.Switch
- module FRP.NetWire.Tools
- module Control.Monad.IO.Class
- module Control.Monad.IO.Control
- module Data.Functor.Identity
Wires
A wire is a network of signal transformers.
Monad m => Arrow (Wire m) | Arrow interface to signal networks. |
Monad m => ArrowZero (Wire m) | The zero arrow always inhibits. |
Monad m => ArrowPlus (Wire m) | Left-biased signal network combination. If the left arrow inhibits, the right arrow is tried. If both inhibit, their combination inhibits. Ignored wire networks still run in real time, i.e. passed time deltas are accumulated. |
Monad m => ArrowChoice (Wire m) | Signal routing. Unused routes are ignored. Note that they still run in real time, i.e. the time deltas passed are accumulated. |
Monad m => ArrowApply (Wire m) | The |
MonadFix m => ArrowLoop (Wire m) | Value recursion. Warning: Recursive signal networks must never
inhibit. Make use of |
Monad m => Category (Wire m) | Identity signal network and signal network sequencing. |
Monad m => Functor (Wire m a) | Map over the output of a signal network. |
Monad m => Applicative (Wire m a) | Applicative interface to signal networks. |
Monad m => Alternative (Wire m a) | This instance corresponds to the |
type Output = Either SomeExceptionSource
Functor for output signals.
The state of the wire.
mkGen :: (WireState m -> a -> m (Output b, Wire m a b)) -> Wire m a bSource
Create a generic (i.e. possibly stateful) wire from the given
function. This is a smart constructor. Please use it instead of the
WGen
constructor for creating generic wires.
toGen :: Monad m => Wire m a b -> WireState m -> a -> m (Output b, Wire m a b)Source
Extract the transition function of a wire. Unless there is reason
(like optimization) to pattern-match against the Wire
constructors,
this function is the recommended way to evolve a wire.
Reactive sessions
Reactive sessions with the given input and output types over the
given monad. The monad must have a MonadControlIO
instance to be
usable with the stepping functions.
:: MonadControlIO m | |
=> a | Input value. |
-> Session m a b | Session to step. |
-> m (Output b) | System's output. |
Feed the given input value into the reactive system performing the next instant using real time.
:: MonadControlIO m | |
=> NominalDiffTime | Time delta. |
-> a | Input value. |
-> Session m a b | Session to step. |
-> m (Output b) | System's output. |
Feed the given input value into the reactive system performing the next instant using the given time delta.
:: MonadControlIO m | |
=> UTCTime | Absolute time of the instant to perform. |
-> a | Input value. |
-> Session m a b | Session to step. |
-> m (Output b) | System's output. |
Feed the given input value into the reactive system performing the next instant, which is at the given time. This function is thread-safe.
:: (MonadControlIO m, MonadIO sm) | |
=> Wire sm a b | Initial wire of the session. |
-> (Session sm a b -> m c) | Continuation, which receives the session data. |
-> m c | Continuation's result. |
Initialize a reactive session and pass it to the given continuation.
Testing wires
:: forall a b m . (MonadControlIO m, Show b) | |
=> Int | Show output once each this number of frames. |
-> m a | Input generator. |
-> Wire m a b | Your wire. |
-> m () |
Interface to testWireStr
accepting all Show
instances as the
output type.
:: forall a m . MonadControlIO m | |
=> Int | Show output once each this number of frames. |
-> m a | Input generator. |
-> Wire m a String | Wire to evolve. |
-> m () |
This function provides a convenient way to test wires. It wraps a default loop around your wire, which just displays the output on your stdout in a single line (it uses an ANSI escape sequence to clear the line). It uses real time.
Pure wires
stepSF :: Time -> a -> SF a b -> (Output b, SF a b)Source
Perform the next instant of a pure wire over the identity monad.
stepWirePure :: Monad m => Time -> a -> Wire m a b -> m (Output b, Wire m a b)Source
Perform the next instant of a pure wire.
Inhibition
data InhibitException Source
Inhibition exception with an informative message. This exception is the result of signal inhibition, where no further exception information is available.
inhibitEx :: String -> SomeExceptionSource
Construct an InhibitException
wrapped in a SomeException
.
noEvent :: SomeExceptionSource
Construct an InhibitException
wrapped in a SomeException
with a
message indicating that a certain event did not happen.
Netwire Reexports
module FRP.NetWire.Analyze
module FRP.NetWire.Calculus
module FRP.NetWire.Event
module FRP.NetWire.IO
module FRP.NetWire.Random
module FRP.NetWire.Request
module FRP.NetWire.Switch
module FRP.NetWire.Tools
Other convenience reexports
module Control.Monad.IO.Class
module Control.Monad.IO.Control
module Data.Functor.Identity