Skip to content

GHC has lots of extra hidden IOErrorType values

I was fixing bytestring's hGet (see #3514 (closed)) and I discover that I cannot produce the same exception as System.IO.hGet does in the same circumstance.

There are two problems:

One is that GHC's internal IOError has more information than one can set via System.IO.Error.mkIOError. In particular it has a function name.

The other is that System.IO.hGet throws an InvalidArgument IOErrorType, however this is not exported and there are no smart constructors or testers for this error type. This is problematic for two reasons, portable code cannot generate these error types to mirror the standard System.IO and secondly no code can actually catch these errors except in a general "catch all" style because they cannot be distinguished from each other.

Code that wants to mirror System.IO (like bytestring or utf8-string) has to import GHC.IO.Exception and use cpp to do it differently for hugs and nhc.

Trac metadata
Trac field Value
Version
Type Bug
TypeOfFailure OtherFailure
Priority normal
Resolution Unresolved
Component libraries/base
Test case
Differential revisions
BlockedBy
Related
Blocking
CC
Operating system
Architecture
To upload designs, you'll need to enable LFS and have an admin enable hashed storage. More information