[Haskell-cafe] Need some advice around lazy IO

Konstantin Litvinenko to.darkangel at gmail.com
Tue Mar 19 08:01:06 CET 2013


On 03/19/2013 07:12 AM, Edward Kmett wrote:
> Konstantin,
>
> Please allow me to elaborate on Dan's point -- or at least the point
> that I believe that Dan is making.
>
> Using,
>
>     let bug = Control.DeepSeq.rnf str `seq` fileContents2Bug str
>
>
> or ($!!)will create a value that *when forced* cause the rnfto occur.
>
> As you don't look at buguntil much later this causes the same problem as
> before!
>

Yes. You (and Dan) are totally right. 'Let' just bind expression, not 
evaluating it. Dan's evaluate trick force rnf to run before hClose. As I 
said - it's tricky part especially for newbie like me :)





More information about the Haskell-Cafe mailing list