reactive-banana-0.8.1.1: Library for functional reactive programming (FRP).

Safe HaskellNone
LanguageHaskell98

Reactive.Banana.Prim

Contents

Synopsis

Synopsis

This is an internal module, useful if you want to implemented your own FRP library. If you just want to use FRP in your project, have a look at Reactive.Banana instead.

Evaluation

type Step = EvalNetwork (IO ()) Source

data Network Source

A Network represents the state of a pulse/latch network, which consists of a Graph and the values of all accumulated latches in the network.

Instances

emptyNetwork :: Network Source

The Network that contains no pulses or latches.

Build FRP networks

type BuildT = RWST () BuildConf Network Source

liftBuild :: Monad m => Build a -> BuildT m a Source

compile :: BuildIO a -> Network -> IO (a, Network) Source

Change a Network of pulses and latches by executing a BuildIO action.

Testing

interpret :: (Pulse a -> BuildIO (Pulse b)) -> [Maybe a] -> IO [Maybe b] Source

Simple interpreter for pulse/latch networks.

Mainly useful for testing functionality

Note: The result is not computed lazily, for similar reasons that the sequence function does not compute its result lazily.

mapAccumM :: Monad m => (a -> s -> m (b, s)) -> s -> [a] -> m [b] Source

mapAccum for a monad.

mapAccumM_ :: Monad m => (a -> s -> m (b, s)) -> s -> [a] -> m () Source

Strict mapAccum for a monad. Discards results.

runSpaceProfile :: (Pulse a -> BuildIO void) -> [a] -> IO () Source

Execute an FRP network with a sequence of inputs, but discard results.

Mainly useful for testing whether there are space leaks.

IO

newInput :: Key a -> Build (Pulse a, a -> Step) Source

Create a new pulse in the network and a function to trigger it.

Together with addHandler, this function can be used to operate with pulses as with standard callback-based events.

addHandler :: Pulse (Future a) -> (a -> IO ()) -> Build () Source

Register a handler to be executed whenever a pulse occurs.

The pulse may refer to future latch values.

readLatch :: Latch a -> Build a Source

Read the value of a Latch at a particular moment in time.

Pulse

data Pulse a Source

neverP :: Build (Pulse a) Source

Pulse that never fires.

mapP :: (a -> b) -> Pulse a -> Build (Pulse b) Source

type Future = Dated Source

tagFuture :: Latch a -> Pulse b -> Build (Pulse (Future a)) Source

Tag a Pulse with future values of a Latch.

This is in contrast to applyP which applies the current value of a Latch to a pulse.

unsafeMapIOP :: (a -> IO b) -> Pulse a -> Build (Pulse b) Source

unionWithP :: (a -> a -> a) -> Pulse a -> Pulse a -> Build (Pulse a) Source

Latch

data Latch a Source

pureL :: a -> Latch a Source

mapL :: (a -> b) -> Latch a -> Latch b Source

applyL :: Latch (a -> b) -> Latch a -> Latch b Source

accumL :: a -> Pulse (a -> a) -> Build (Latch a, Pulse a) Source

applyP :: Latch (a -> b) -> Pulse a -> Build (Pulse b) Source

Dynamic event switching

executeP :: Pulse (b -> BuildIO a) -> b -> Build (Pulse a) Source