[Haskell-cafe] Strictness leak
jeff.polakow at db.com
Wed Oct 31 01:05:25 EDT 2007
I forgot to send this reponse to haskell-cafe earlier...
> 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
> take 10 $ execWriter $ sequence $ repeat $ tell (::[Int])
This is a good example. Note that the computation of sequence itself is
snd $ runWriter $ sequence (repeat $ tell ) >>= return . take 10
will result in an infinite list, but
fst $ runWriter $ sequence (repeat $ tell ) >>= return . take 10
will return a 10 element list.
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...
More information about the Haskell-Cafe