IO errors

Simon Marlow
Thu, 29 Nov 2001 10:18:30 -0000

> A quick look at the source looks like both GHC and NHC will=20
> simply pass
> on errors from the OS, so for example with
>     module Main where
>     import IO
>     import Directory
>     main :: IO()
>     main =3D do catch (createDirectory "this/does/not/exist/foo")
>                     (\e -> putStrLn $ show $ map (flip ($) e) errors)
>     errors :: [(IOError -> Bool)]
>     errors =3D [isDoesNotExistError,
>               isIllegalOperation,
>               isPermissionError,
>               isAlreadyExistsError]
> both GHC and NHC give [True,False,False,False] (I don't seem to have a
> hugs Directory.hs) while the library report only allows
> isIllegalOperation, isPermissionError and isAlreadyExistsError. I
> haven't looked for other cases of this.

Two possibilities: either createDirectory should act like 'mkdir -p' and
make the whole path, or the library report should document
isDoesNotExistError as a possible error thrown by createDirectory.  I'd
vote for the latter.

No doubt there are many other cases of this, we should really do a full
audit of the I/O library specs.