A quick look at the source looks like both GHC and NHC will simply pass on errors from the OS, so for example with
module Main where
import IO import Directory
main :: IO() main = do catch (createDirectory "this/does/not/exist/foo") (\e -> putStrLn $ show $ map (flip ($) e) errors)
errors :: [(IOError -> Bool)] errors = [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. Cheers, Simon
participants (1)
-
Simon Marlow