]> Git — Sourcephile - tmp/julm/arpeggigon.git/blob - RMCA/Auxiliary/RV.hs
RCMA -> RMCA
[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