[Haskell-cafe] IO and lazyness.

D.V. dav.vire+haskell at gmail.com
Tue Mar 6 18:37:12 EST 2007

On 3/7/07, Daniel McAllansmith <dm.maillists at gmail.com> wrote:

> Your program actually says:
> 1) open file handle
> 2) create a String that will be read _on demand_ from file handle
> 3) close file handle
> 4) print the value which is computed from the String

Thanks for a clear explanation and that's also where I've got lost.
Claus' explanation was helpfull too.

I thought that the order things were done is

1) print the value which is computed from rechf
to do so,
2) open file handle
3) create a String ....
4) close file handle

hence my confusion.

I think I kinda understand now what's going on, but the docs are
definitely lacking here :(

by the way, what would be a safe version of hGetContents ? and why
hGetContents is unsafe ?

More information about the Haskell-Cafe mailing list