[Haskell-cafe] space leak when repeatedly calling Control.Monad.State.Strict.modify
joey at kitenet.net
Mon Jan 30 03:36:14 CET 2012
Claude Heiland-Allen wrote:
> Control.Monad.State.Strict is strict in the actions, but the state
> itself is still lazy, so you end up building a huge thunk in the
> state containing all the updates that ever took place to the initial
> Using this should fix it:
> modify' :: MonadState s m => (s -> s) -> m ()
> modify' f = do
> x <- get
> put $! f x -- force the new state when storing it
So, why does Control.Monad.State.Strict.modify not do that?
And, I still don't quite understand why this only happened
when the updated value is obtained using IO.
see shy jo
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Size: 828 bytes
Desc: Digital signature
More information about the Haskell-Cafe