The recursive let from RecursiveDois in the monad IO. The monad Reactivealso has an instance MonadFix. You can fully define bwithin Reactive, and then use syncto complete the entire definition as a transaction.
main = do
(e, t) <- sync newEvent
b <- sync $
do
rec
b <- hold 0 $ snapshot (\_ i -> i + 1) e b
return b
sync $ listen (value b) (\i -> putStrLn $ "value of i: " ++ show i)
...
RecursiveDo . mfix.
main = do
(e, t) <- sync newEvent
b <- sync . mfix $ hold 0 . snapshot (\_ i -> i + 1) e
sync $ listen (value b) (\i -> putStrLn $ "value of i: " ++ show i)
...
, , Behavior Event accum.
b <- sync $ accum 0 (const (+1) <$> e)
hold, snapshot mfix.
accum :: Context r => a -> Event r (a -> a) -> Reactive r (Behavior r a)
accum z efa = do
rec
s <- hold z $ snapshot ($) efa s
return s