haskell-cafe@haskell.org
[Top] [All Lists]

Re: [Haskell-cafe] Strictness leak

Subject: Re: [Haskell-cafe] Strictness leak
From: Jeff Polakow
Date: Wed, 31 Oct 2007 01:05:25 -0400

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.
_______________________________________________
Haskell-Cafe mailing list
Haskell-Cafe@xxxxxxxxxxx
http://www.haskell.org/mailman/listinfo/haskell-cafe
<Prev in Thread] Current Thread [Next in Thread>