
Hi, I've found Sasha's example
import FRP.Reactive import FRP.Reactive.LegacyAdapters import Control.Concurrent type BellMachine = Event () -> Event () doorBell :: BellMachine doorBell = id runMachine :: BellMachine -> IO () runMachine machine = do -- get button press clock <- makeClock (buttonPressed, buttonPressedSink) <- makeEvent clock forkIO $ buttonPresses buttonPressedSink adaptE (fmap bell $ machine buttonPressed) -- run the machine where bell = const $ print "beep!" buttonPresses sink = sequence_ $ repeat $ (getChar >> sink ()) main = runMachine doorBell
and it fits my purposes, but notice that the values collected from the makeEvent function must be in reverse order, at least with reactive-0.11.
(buttonPressedSink, buttonPressed) <- makeEvent clock
Regards,
Alvaro.
---------- Mensaje reenviado ----------
De: Álvaro García Pérez