midair-0.2.0.0: Hot-swappable FRP

Safe HaskellSafe
LanguageHaskell2010

Midair.Core

Contents

Synopsis

Fundamental units

data SFlow a c Source

Signal flow

A little like a function: takes a value of type a and returns one of type c

sMap :: (a -> c) -> SFlow a c Source

Apply a function to the input signal

sFold :: c -> (a -> c -> c) -> SFlow a c Source

Accumulate a value. "Folding over the past".

sFoldNoDefault :: (a -> Maybe c -> c) -> SFlow a c Source

Like sFold but with no default. Useful for functions like min which don't have a semantics of a result from one argument

sFoldAccum :: Maybe c -> (a -> Maybe c -> c) -> SFlow a c Source

This name may change

sCompose :: SFlow b c -> SFlow a b -> SFlow a c Source

Compose two signal flows into one. The equivalent of '(.)'

sZip :: SFlow a b -> SFlow a c -> SFlow a (b, c) Source

Zip two signal flows together into one which returns a signal of two-tuples

sFilter :: (b -> Bool) -> SFlow b (Maybe b) Source

Filter out the incoming signal by a predicate. Also check out sFilterWDefault

Hot-swapping

mkNodeRef :: SFlow i o -> IO (SFNodeRef i o) Source

Pass in a signal flow graph and get back a reference you can use to hot-swap with

data SFNodeRef a c Source

nRef :: SFNodeRef a c -> SFlow a c Source

Turn the result of mkNodeRef into something you can use in an SFlow graph

hotSwap :: SFNodeRef a c -> (Maybe c -> SFlow a c) -> IO () Source

Swap out part or whole of a signal flow graph with a new one of the same type.

hotSwapSTM :: SFNodeRef a c -> (Maybe c -> SFlow a c) -> STM () Source

Graph firing

fireGraph :: TVar (SFlow a c) -> a -> STM c Source

Given a node in the graph, and an input to that node, return the output of that node and the "new node" with updated state

fireGraphIO :: TVar (SFlow a c) -> a -> IO c Source