Stack usage with a state monad
Koji Nakahara
yu- at div.club.ne.jp
Wed Dec 31 02:54:18 EST 2003
Hi,
I think the problem is in the State Monad itself;
State Monad is lazy to compute its state.
I am not a haskell expert, and there may be better ideas. But anyhow,
when I use these >>>= and >>> instead of >>= and >>,
your example runs fine. I hope it becomes some help.
m >>>= k = State $ \s -> let (a, s') = runState m s
in s `seq` runState (k a) s' -- force evaluation of the state
m >>> k = m >>>= \_ -> k
--
Koji Nakahara
More information about the Haskell-Cafe
mailing list