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

Safe HaskellNone
LanguageHaskell2010

FRP.Rhine.Reactimation

Contents

Description

Run closed Rhines (which are signal functions together with matching clocks) as main loops.

Synopsis

Running a Rhine

flow :: (Monad m, Clock m cl, Time cl ~ Time (In cl), Time cl ~ Time (Out cl)) => Rhine m cl () () -> m () Source #

Takes a closed Rhine (with trivial input and output), and runs it indefinitely. This is typically the main loop.

All input has to be created, and all output has to be consumed by means of side effects in a monad m.

Basic usage (synchronous case):

sensor :: ClSF MyMonad MyClock () a
sensor = constMCl produceData

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

actuator :: ClSF MyMonad MyClock b ()
actuator = arrMCl consumeData

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

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

reactimateCl :: (Monad m, Clock m cl, cl ~ In cl, cl ~ Out cl) => cl -> ClSF m cl () () -> m () Source #

Run a synchronous ClSF with its clock as a main loop, similar to Yampa's, or Dunai's, reactimate.