rhine-0.4.0.0: Functional Reactive Programming with type-level clocks

Safe HaskellNone
LanguageHaskell2010

FRP.Rhine.Reactimation

Contents

Synopsis

Documentation

data Rhine m cl a b Source #

An SF together with a clock of matching type cl, A Rhine is a reactive program, possibly with open inputs and outputs. If the input and output types a and b are both '()', that is, the Rhine is "closed", then it is a standalone reactive program that can be run with the function flow.

Constructors

Rhine 

Fields

Running a Rhine

flow :: (Monad m, Clock m cl, TimeDomainOf cl ~ TimeDomainOf (Leftmost cl), TimeDomainOf cl ~ TimeDomainOf (Rightmost cl)) => Rhine m cl () () -> m () Source #

Takes a closed Rhine (with trivial input and output), and runs it indefinitely. All input is created, and all output is consumed by means of side effects in a monad m.

Basic usage (synchronous case):

sensor :: SyncSF MyMonad MyClock () a
sensor = arrMSync_ produceData

processing :: SyncSF MyMonad MyClock a b
processing = ...

actuator :: SyncSF MyMonad MyClock b ()
actuator = arrMSync consumeData

mainSF :: SyncSF MyMonad MyClock () ()
mainSF = sensor >-> processing >-> actuator

main :: MyMonad ()
main = flow $ mainSF @@ clock