> Arguably, readFile is too strict: why is the file opened, if there
> aren't any characters needed. What is the motivation for opening the
> file eagerly?

Once we've started reading lazilly, it's hard to generate errors.  The file
is opened eagerly so that any errors generated (such as if the file doesn't
exist) can be propogated immediately to the caller.

I checked the Haskell Report, which doesn't seem to specify the correct
behaviour - I guess this should be clarified.  The report also contains the
sentence "The exceptions raised by the I/O functions in the Prelude are
defined in the Library Report", but I can't find any reference to
readFile/writeFile in the library report.

Cheers,
        Simon

Reply via email to