netwire-1.1.0: Arrowized FRP implementation

MaintainerErtugrul Soeylemez <es@ertes.de>

FRP.NetWire.Wire

Contents

Description

The module contains the main Wire type.

Synopsis

Wires

data Wire whereSource

A wire is a network of signal transformers.

Constructors

WArr :: (a -> b) -> Wire m a b 
WConst :: b -> Wire m a b 
WGen :: (WireState m -> a -> m (Output b, Wire m a b)) -> Wire m a b 
WId :: Wire m a a 

Instances

Monad m => Arrow (Wire m) 
Monad m => ArrowZero (Wire m) 
Monad m => ArrowPlus (Wire m) 
Monad m => ArrowChoice (Wire m) 
Monad m => Category (Wire m) 
Monad m => Functor (Wire m a) 
Monad m => Applicative (Wire m a) 
Monad m => Alternative (Wire m a) 

data WireState whereSource

The state of the wire.

Constructors

ImpureState :: MonadIO m => Double -> MTGen -> TVar Int -> WireState m 

Fields

wsDTime :: Double

Time difference for current instant.

wsRndGen :: MTGen

Random number generator.

wsReqVar :: TVar Int

Request counter.

PureState :: Double -> WireState m 

Fields

wsDTime :: Double

Time difference for current instant.

Auxilliary types

type Event = MaybeSource

Events are signals, which can be absent. They usually denote discrete occurences of certain events.

data InhibitException Source

Inhibition exception with an informative message. This exception is the result of signal inhibition, where no further exception information is available.

type Output = Either SomeExceptionSource

The output of a wire. When the wire inhibits, then this will be a Left value with an exception.

type SF = Wire IdentitySource

Signal functions are wires over the identity monad.

type Time = DoubleSource

Time.

Utilities

cleanupWireState :: WireState m -> IO ()Source

Clean up wire state.

initWireState :: MonadIO m => IO (WireState m)Source

Initialize wire state.

mkGen :: (WireState m -> a -> m (Output b, Wire m a b)) -> Wire m a bSource

Create a generic wire from the given function. This is a smart constructor. Please use it instead of the WGen constructor.

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.