netwire-1.2.7: Arrowized FRP implementation

MaintainerErtugrul Soeylemez <es@ertes.de>

FRP.NetWire.Session

Contents

Description

Wire sessions.

Synopsis

Sessions

data Session m a b Source

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.

Constructors

Session 

Fields

sessFreeVar :: TVar Bool

False, if in use.

sessStateRef :: IORef (WireState m)

State of the last instant.

sessTimeRef :: IORef UTCTime

Time of the last instant.

sessWireRef :: IORef (Wire m a b)

Wire for the next instant.

stepWireSource

Arguments

:: 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.

stepWireDeltaSource

Arguments

:: 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.

stepWireTimeSource

Arguments

:: 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.

stepWireTime'Source

Arguments

:: MonadIO 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 not thread-safe.

withWireSource

Arguments

:: (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

testWireSource

Arguments

:: 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.

testWireStrSource

Arguments

:: 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.

Low level

sessionStart :: MonadIO m => Wire m a b -> IO (Session m a b)Source

Start a wire session.

sessionStop :: Session m a b -> IO ()Source

Clean up a wire session.