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) =>
20 -> IO (ReactiveFieldRead IO b)
21 yampaReactiveWithMetronome sf rv dt = do
23 init <- reactiveValueRead rv
24 (input,output) <- yampaReactiveDual init sf
26 reactiveValueOnCanRead clock $
27 reactiveValueRead rv >>= reactiveValueWrite input
30 yampaReactiveWithTick :: (ReactiveValueRead c a IO) =>
31 a -> SF a b -> c -> IOTick
32 -> IO (ReactiveFieldRead IO b)
33 yampaReactiveWithTick init sf rv tick = do
34 (input,output) <- yampaReactiveDual init sf
36 reactiveValueOnCanRead tick $
37 reactiveValueRead rv >>= reactiveValueWrite input