> So, the question is, "Should readFile on a directory throw an IO
> error?"  If so, then there is a bug in Hugs; if not, there is a bug
> (or at least a severe misfeature) in Green Card (and a bug in the ghc
> libraries, which do throw an IO error).

I rather think that openning a directory fail, because attempting to perform
any other operations on that directory (such as reading from it) will fail
anyway, and we have the Directory module for dealing with directories.

In GHC, we have an non-std IOError called InapropriateType which is thrown
if you try to open a directory.  Unfortunately I just noticed we don't also
have the isInapropriateTypeError predicate to go with it :-(  

I think this aspect of the I/O library definition should be clarified,
though.  Reading from directories is at best non-portable, and is disallowed
on most OSs.  There should at least be a way to tell whether the file you
were trying to open was indeed a directory.

Cheers,
        Simon

Reply via email to