[Haskell-cafe] Insert a laziness break into strict ST
Henning Thielemann
lemming at henning-thielemann.de
Sun Dec 6 18:46:00 EST 2009
I have lot of ST actions that shall be bound strictly (they write to a
buffer), but somewhere between these actions I like to have a "laziness
break". I thought I could do this by temporarily switching to Lazy.ST,
but this does not work. It follows a simplified example
Prelude> :module Control.Monad.ST.Lazy
Prelude Control.Monad.ST.Lazy> runST (Monad.liftM2 (,) (return 'a')
(undefined::Monad m => m Char))
('a',*** Exception: Prelude.undefined
Prelude Control.Monad.ST.Lazy> Control.Monad.ST.runST (lazyToStrictST $
Monad.liftM2 (,) (return 'a') (undefined::Monad m => m Char))
*** Exception: Prelude.undefined
I hoped to get the first answer also for the second command. It seems
that conversion from lazy to strict ST also removes laziness breaks.
It seems that I have to stick to unsafeInterleaveIO, but I like to know,
why the above method does not work.
More information about the Haskell-Cafe
mailing list