[project @ 2001-10-11 22:27:04 by sof]
authorsof <unknown>
Thu, 11 Oct 2001 22:27:05 +0000 (22:27 +0000)
committersof <unknown>
Thu, 11 Oct 2001 22:27:05 +0000 (22:27 +0000)
- removed Win32-only IOErrorType.ComError
- added IOErrorType.(DynIOError Dynamic.Dynamic)

  Propagating dynamically-typed exceptions as Exception.DynException
  isn't always the right thing to do
  [ why? You cannot catch them with IO.catch & you don't get the
    'infrastructure' that IOError offers, so you're forced to
    reinvent that wheel for each dynamic exception.
  ]
- removed IOExts.isComError  :: IOError -> Bool
- added IOExts.isDynIOError  :: IOError -> Bool
- added IOExts.getDynIOError :: IOError -> Dynamic.Dynamic
- documented IOExts changes.

ghc/lib/std/PrelIOBase.lhs

index 9f36163..3179a5e 100644 (file)
@@ -1,5 +1,5 @@
 % ------------------------------------------------------------------------------
-% $Id: PrelIOBase.lhs,v 1.42 2001/06/01 13:06:01 sewardj Exp $
+% $Id: PrelIOBase.lhs,v 1.43 2001/10/11 22:27:04 sof Exp $
 % 
 % (c) The University of Glasgow, 1994-2001
 %
@@ -9,8 +9,6 @@
 
 \begin{code}
 {-# OPTIONS -fno-implicit-prelude #-}
-#include "config.h"
-
 module PrelIOBase where
 
 import PrelST
@@ -519,10 +517,13 @@ data IOErrorType
   | TimeExpired          | UnsatisfiedConstraints
   | UnsupportedOperation
   | EOF
-#if defined(cygwin32_TARGET_OS) || defined(mingw32_TARGET_OS)
-  | ComError Int           -- HRESULT
-#endif
-  deriving (Eq)
+  | DynIOError Dynamic -- cheap&cheerful extensible IO error type.
+
+instance Eq IOErrorType where
+   x == y = 
+     case x of
+       DynIOError{} -> False -- from a strictness POV, compatible with a derived Eq inst?
+       _ -> getTag# x ==# getTag# y
 
 instance Show IOErrorType where
   showsPrec _ e =
@@ -546,11 +547,7 @@ instance Show IOErrorType where
       UnsatisfiedConstraints -> "unsatisified constraints" -- ultra-precise!
       UnsupportedOperation -> "unsupported operation"
       EOF              -> "end of file"
-#if defined(cygwin32_TARGET_OS) || defined(mingw32_TARGET_OS)
-      ComError _       -> "COM error"
-#endif
-
-
+      DynIOError{}      -> "unknown IO error"
 
 userError       :: String  -> IOError
 userError str  =  UserError str