]> Git — Sourcephile - tmp/julm/arpeggigon.git/blob - RMCA/Auxiliary/RV.hs
System producing sound apparently correctly (though this needs verification).
[tmp/julm/arpeggigon.git] / RMCA / Auxiliary / RV.hs
1 {-# LANGUAGE ScopedTypeVariables #-}
2
3 module RMCA.Auxiliary.RV where
4
5 import Data.CBMVar
6 import Data.ReactiveValue
7
8 newCBMVarRW :: forall a. a -> IO (ReactiveFieldReadWrite IO a)
9 newCBMVarRW val = do
10 mvar <- newCBMVar val
11 let getter :: IO a
12 getter = readCBMVar mvar
13 setter :: a -> IO ()
14 setter = writeCBMVar mvar
15 notifier :: IO () -> IO ()
16 notifier = installCallbackCBMVar mvar
17 return $ ReactiveFieldReadWrite setter getter notifier
18
19 emptyRW :: (Monoid b, ReactiveValueReadWrite a b m) => a -> m b
20 emptyRW rv = do
21 val <- reactiveValueRead rv
22 reactiveValueWrite rv mempty
23 return val
24
25 emptyW :: (Monoid b, ReactiveValueWrite a b m) => a -> m ()
26 emptyW rv = reactiveValueWrite rv mempty