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
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.