|Subject:||Re: [Haskell-cafe] Strictness leak|
|Date:||Wed, 31 Oct 2007 01:05:25 -0400|
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 lazily.
> take 10 $ execWriter $ sequence $ repeat $ tell (::[Int])
This is a good example. Note that the computation of sequence itself is infinite.
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.
_______________________________________________ Haskell-Cafe mailing list [email protected] http://www.haskell.org/mailman/listinfo/haskell-cafe
|<Prev in Thread]||Current Thread||[Next in Thread>|
|Previous by Date:||Re: [Haskell-cafe] Type inference problem with division (/), Shachaf Ben-Kiki|
|Next by Date:||[Haskell-cafe] help needed packaging curl bindings, brad clawsie|
|Previous by Thread:||Re: [Haskell-cafe] Type inference problem with division (/), Shachaf Ben-Kiki|
|Next by Thread:||Re: [Haskell-cafe] Strictness leak, Ketil Malde|
|Indexes:||[Date] [Thread] [Top] [All Lists]|