[Haskell-cafe] Strictness leak
Jeff Polakow
jeff.polakow at db.com
Wed Oct 31 01:05:25 EDT 2007
I forgot to send this reponse to haskell-cafe earlier...
Hello,
> You mean for the IO monad, right?
>
Sorry. I meant divergence is unavoidable for any strict Monad, such as IO.
However, sequence will always compute over the entire list; if the
resulting computation itself is lazy then the result can be inspected
lazily.
> take 10 $ execWriter $ sequence $ repeat $ tell ([3]::[Int])
>
This is a good example. Note that the computation of sequence itself is
infinite.
snd $ runWriter $ sequence (repeat $ tell [3]) >>= return . take 10
will result in an infinite list, but
fst $ runWriter $ sequence (repeat $ tell [3]) >>= return . take 10
will return a 10 element list.
-Jeff
---
This e-mail may contain confidential and/or privileged information. If you
are not the intended recipient (or have received this e-mail in error)
please notify the sender immediately and destroy this e-mail. Any
unauthorized copying, disclosure or distribution of the material in this
e-mail is strictly forbidden.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://www.haskell.org/pipermail/haskell-cafe/attachments/20071031/78e21347/attachment.htm
More information about the Haskell-Cafe
mailing list