-#include "Typeable.h"
-INSTANCE_TYPEABLE0(Exception,exceptionTc,"Exception")
-INSTANCE_TYPEABLE0(IOException,ioExceptionTc,"IOException")
-INSTANCE_TYPEABLE0(ArithException,arithExceptionTc,"ArithException")
-INSTANCE_TYPEABLE0(ArrayException,arrayExceptionTc,"ArrayException")
-INSTANCE_TYPEABLE0(AsyncException,asyncExceptionTc,"AsyncException")
+#ifdef __NHC__
+import qualified System.IO.Error as H'98 (catch)
+import System.IO.Error (ioError)
+import IO (bracket)
+import DIOError -- defn of IOError type
+import System (ExitCode())
+
+-- minimum needed for nhc98 to pretend it has Exceptions
+data Exception = IOException IOException
+ | ArithException ArithException
+ | ArrayException ArrayException
+ | AsyncException AsyncException
+ | ExitException ExitCode
+type IOException = IOError
+data ArithException
+data ArrayException
+data AsyncException
+
+catch :: IO a -> (Exception -> IO a) -> IO a
+a `catch` b = a `H'98.catch` (b . IOException)
+
+throwIO :: Exception -> IO a
+throwIO (IOException e) = ioError e
+throwIO _ = ioError (UserError "Control.Exception.throwIO"
+ "unknown exception")
+throw :: Exception -> a
+throw = unsafePerformIO . throwIO
+
+evaluate :: a -> IO a
+evaluate x = x `seq` return x
+
+ioErrors :: Exception -> Maybe IOError
+ioErrors (IOException e) = Just e
+ioErrors _ = Nothing
+arithExceptions :: Exception -> Maybe ArithException
+arithExceptions (ArithException e) = Just e
+arithExceptions _ = Nothing
+errorCalls :: Exception -> Maybe String
+errorCalls = const Nothing
+dynExceptions :: Exception -> Maybe Dynamic
+dynExceptions = const Nothing
+assertions :: Exception -> Maybe String
+assertions = const Nothing
+asyncExceptions :: Exception -> Maybe AsyncException
+asyncExceptions = const Nothing
+userErrors :: Exception -> Maybe String
+userErrors (IOException (UserError _ s)) = Just s
+userErrors _ = Nothing
+
+assert :: Bool -> a -> a
+assert True x = x
+assert False _ = throw (IOException (UserError "" "Assertion failed"))
+#endif
+
+#ifndef __GLASGOW_HASKELL__
+-- Dummy definitions for implementations lacking asynchonous exceptions
+
+block :: IO a -> IO a
+block = id
+unblock :: IO a -> IO a
+unblock = id
+blocked :: IO Bool
+blocked = return False
+#endif