[reactive] Reactive space leak
Dustin DeWeese
dustin.deweese at gmail.com
Wed Jan 12 00:32:09 CET 2011
I cannot get Reactive to behave. I am trying to write a simple program that
feeds events to a function and prints 'DING!' when it receives an event from
the function. If the function is id or (join . return), it works
correctly. If the function is (>>= return), it consumes all of my RAM and
does nothing.
Why? I've spent several days trying to figure this out.
I am using GHC 6.12.1 for x86_64 Linux.
import FRP.Reactive
import FRP.Reactive.Reactive
import FRP.Reactive.Internal.Reactive
import FRP.Reactive.Internal.Timing
import FRP.Reactive.LegacyAdapters
import Control.Monad
import Control.Concurrent
import Control.Applicative
runEventProcessor :: (Event () -> Event ()) -> IO ()
runEventProcessor f = do
clk <- makeClock
(sink, ev) <- makeEvent clk
forkE (wait clk) . fmap (\_ -> putStrLn "DING!") . f $ ev
forever $ do getLine -- wait for <ENTER>
sink ()
putStrLn "<< button pressed >>"
threadDelay 100000 -- avoid pressing button too fast
wait clk = sleepPast (cGetTime clk) . exactNB
explodes1 = runEventProcessor (>>= return)
explodes2 = runEventProcessor (join . fmap (Event . pure . pure))
works1 = runEventProcessor (join . return)
works2 = runEventProcessor (fmap id)
works3 = runEventProcessor (join . Event . pure . pure)
-- requires joinE to be exported from FRP.Reactive.PrimReactive
-- works4 = runEventProcessor (joinE . return)
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.haskell.org/pipermail/reactive/attachments/20110111/b5ab7312/attachment.htm>
More information about the Reactive
mailing list