From dustin.deweese at gmail.com Wed Jan 12 00:32:09 2011 From: dustin.deweese at gmail.com (Dustin DeWeese) Date: Tue, 11 Jan 2011 18:32:09 -0500 Subject: [reactive] Reactive space leak Message-ID: 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 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: From conal at conal.net Wed Jan 12 01:21:29 2011 From: conal at conal.net (Conal Elliott) Date: Tue, 11 Jan 2011 16:21:29 -0800 Subject: [reactive] Reactive space leak In-Reply-To: References: Message-ID: Hi Dustin, Sorry about that. There are some serious space leaks no one has figured out yet (afaik). :( - Conal On Tue, Jan 11, 2011 at 3:32 PM, Dustin DeWeese wrote: > 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 > 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) > > > _______________________________________________ > Reactive mailing list > Reactive at haskell.org > http://www.haskell.org/mailman/listinfo/reactive > > -------------- next part -------------- An HTML attachment was scrubbed... URL: