Here is a minimal example program:
{-# LANGUAGE RecursiveDo #-}
import Control.FRPNow
import Control.Monad
import System.IO
main :: IO ()
main =
do hSetBuffering stdin NoBuffering
hSetBuffering stdout NoBuffering
runNowMaster
(mdo (keyPressed,keyPress) <- callbackStream
-- State begins in state "1", and when a key is pressed it switches to state 2
state <-
sample (fromChanges
1
(2 <$ (keyPressed `during` (fmap (1 ==) state))))
-- Whenever the state changes, print it
callIOStream (print :: Int -> IO ())
(toChanges state)
async (forever (getChar >>= keyPress)))
When ran, if you press any key the process begins using all the memory it can, until it blows the stack.
If I change fmap (1 ==) state to pure True it works fine, but obviously is a different program :) Perhaps a missing call to futuristic somewhere?
Here is a minimal example program:
{-# LANGUAGE RecursiveDo #-} import Control.FRPNow import Control.Monad import System.IO main :: IO () main = do hSetBuffering stdin NoBuffering hSetBuffering stdout NoBuffering runNowMaster (mdo (keyPressed,keyPress) <- callbackStream -- State begins in state "1", and when a key is pressed it switches to state 2 state <- sample (fromChanges 1 (2 <$ (keyPressed `during` (fmap (1 ==) state)))) -- Whenever the state changes, print it callIOStream (print :: Int -> IO ()) (toChanges state) async (forever (getChar >>= keyPress)))When ran, if you press any key the process begins using all the memory it can, until it blows the stack.
If I change
fmap (1 ==) statetopure Trueit works fine, but obviously is a different program :) Perhaps a missing call tofuturisticsomewhere?