[Haskell-cafe] Need some advice around lazy IO

Carlo Hamalainen carlo.hamalainen at gmail.com
Sun Mar 17 07:50:37 CET 2013


On Sun, Mar 17, 2013 at 3:08 PM, C K Kashyap <ckkashyap at gmail.com> wrote:

> It's a small snippet and I've put in the comments stating how I run into
> "out of file handles" or simply file not getting read due to lazy IO.
>
> I realize that putting ($!) using a trial/error approach is going to be
> futile. I'd appreciate some pointers into the tools I could use to get some
> idea of which expressions are building up huge thunks.
>

Have you tried System.IO.Strict's readFile? I had similar problems (too
many file handles) and fixed it with

import qualified System.IO.Strict as S

and then using S.readFile instead of the standard prelude's readFile.

This is where I used the strict IO readFile in my toy project:
https://github.com/carlohamalainen/checker/blob/master/Checker.hs

-- 
Carlo Hamalainen
http://carlo-hamalainen.net
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.haskell.org/pipermail/haskell-cafe/attachments/20130317/d8730a89/attachment.htm>


More information about the Haskell-Cafe mailing list