1 {-# LANGUAGE FlexibleContexts, MultiParamTypeClasses #-}
3 module RMCA.YampaReactive where
5 import Data.ReactiveValue
8 import RMCA.IOClockworks
10 yampaReactiveFrom :: (ReactiveValueRead c a IO) => SF a b -> c
11 -> IO (ReactiveFieldRead IO b)
12 yampaReactiveFrom sf rv = do
13 init <- reactiveValueRead rv
14 (input,output) <- yampaReactiveDual init sf
18 yampaReactiveWithMetronome :: (ReactiveValueRead c a IO) =>
19 a -> SF a b -> c -> DTime
20 -> IO (ReactiveFieldRead IO b)
21 yampaReactiveWithMetronome init sf rv dt = do
23 (input,output) <- yampaReactiveDual init sf
25 reactiveValueOnCanRead clock $
26 reactiveValueRead rv >>= reactiveValueWrite input
29 yampaReactiveWithTick :: (ReactiveValueRead c a IO) =>
30 a -> SF a b -> c -> IOTick
31 -> IO (ReactiveFieldRead IO b)
32 yampaReactiveWithTick init sf rv tick = do
33 (input,output) <- yampaReactiveDual init sf
35 reactiveValueOnCanRead tick $
36 reactiveValueRead rv >>= reactiveValueWrite input