[project @ 1999-07-14 08:33:38 by simonmar]
[ghc-hetmet.git] / ghc / lib / std / PrelException.lhs
index 7f9b54f..56d116e 100644 (file)
@@ -1,5 +1,5 @@
 % -----------------------------------------------------------------------------
-% $Id: PrelException.lhs,v 1.5 1999/03/17 13:19:20 simonm Exp $
+% $Id: PrelException.lhs,v 1.8 1999/07/14 08:33:38 simonmar Exp $
 %
 % (c) The GRAP/AQUA Project, Glasgow University, 1998
 %
@@ -13,6 +13,7 @@ Exceptions and exception-handling functions.
 module PrelException where
 
 import PrelBase
+import PrelShow
 import PrelIOBase
 import PrelST          ( STret(..) )
 import PrelDynamic
@@ -37,6 +38,7 @@ data Exception
   | AssertionFailed    String          -- Assertions
   | DynException       Dynamic         -- Dynamic exceptions
   | AsyncException     AsyncException  -- Externally generated errors
+  | NonTermination
 
 data ArithException
   = Overflow
@@ -81,6 +83,7 @@ instance Show Exception where
   showsPrec _ (AssertionFailed err)      = showString err
   showsPrec _ (AsyncException e)        = shows e
   showsPrec _ (DynException _err)        = showString "unknown exception"
+  showsPrec _ (NonTermination)           = showString "<<loop>>"
 
 -- Primitives:
 
@@ -115,8 +118,14 @@ catch           :: IO a -> (IOError -> IO a) -> IO a
 catch m k      =  catchException m handler
   where handler (IOException err) = k err
        handler other             = throw other
+
+catchNonIO      :: IO a -> (Exception -> IO a) -> IO a 
+catchNonIO m k =  catchException m handler
+  where handler (IOException err) = ioError err
+       handler other             = k other
 \end{code}
 
+
 Why is this stuff here?  To avoid recursive module dependencies of
 course.