midair-0.2.0.1: 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

Instances
Arrow SFlow Source # 
Instance details

Defined in Midair.Core

Methods

arr :: (b -> c) -> SFlow b c #

first :: SFlow b c -> SFlow (b, d) (c, d) #

second :: SFlow b c -> SFlow (d, b) (d, c) #

(***) :: SFlow b c -> SFlow b' c' -> SFlow (b, b') (c, c') #

(&&&) :: SFlow b c -> SFlow b c' -> SFlow b (c, c') #

Functor (SFlow a) Source # 
Instance details

Defined in Midair.Core

Methods

fmap :: (a0 -> b) -> SFlow a a0 -> SFlow a b #

(<$) :: a0 -> SFlow a b -> SFlow a a0 #

Applicative (SFlow a) Source # 
Instance details

Defined in Midair.Core

Methods

pure :: a0 -> SFlow a a0 #

(<*>) :: SFlow a (a0 -> b) -> SFlow a a0 -> SFlow a b #

liftA2 :: (a0 -> b -> c) -> SFlow a a0 -> SFlow a b -> SFlow a c #

(*>) :: SFlow a a0 -> SFlow a b -> SFlow a b #

(<*) :: SFlow a a0 -> SFlow a b -> SFlow a a0 #

Category SFlow Source # 
Instance details

Defined in Midair.Core

Methods

id :: SFlow a a #

(.) :: SFlow b c -> SFlow a b -> SFlow a 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 #