summaryrefslogtreecommitdiff
path: root/compiler/utils/Exception.hs
diff options
context:
space:
mode:
authorIan Lynagh <igloo@earth.li>2008-07-31 17:33:54 +0000
committerIan Lynagh <igloo@earth.li>2008-07-31 17:33:54 +0000
commit81466110ff8104ca60e20d617bab83f6f78f0ec2 (patch)
treebf6432b8838cbd01c6c2a2a00c39f4af5e462fb9 /compiler/utils/Exception.hs
parente61fe59d9567fbad053a87f897e6c8198dc95794 (diff)
downloadhaskell-81466110ff8104ca60e20d617bab83f6f78f0ec2.tar.gz
Follow changes in the base library
TopHandler now uses the new extensible exceptions module, so we need to interact with it using the new types.
Diffstat (limited to 'compiler/utils/Exception.hs')
-rw-r--r--compiler/utils/Exception.hs37
1 files changed, 30 insertions, 7 deletions
diff --git a/compiler/utils/Exception.hs b/compiler/utils/Exception.hs
index 11172b59b1..a316c56ba5 100644
--- a/compiler/utils/Exception.hs
+++ b/compiler/utils/Exception.hs
@@ -1,19 +1,42 @@
module Exception
(
+ module Control.Exception,
+ module Exception
+ )
+ where
+
+import Prelude hiding (catch)
+import Control.Exception
+
+#if __GLASGOW_HASKELL__ < 609
+type SomeException = Exception
+
+onException :: IO a -> IO () -> IO a
+onException io what = io `catch` \e -> do what
+ throw e
+#endif
+
+catchIO :: IO a -> (IOException -> IO a) -> IO a
#if __GLASGOW_HASKELL__ >= 609
- module Control.OldException
+catchIO = catch
#else
- module Control.Exception
+catchIO io handler = io `catch` handler'
+ where handler' (IOException ioe) = handler ioe
+ handler' e = throw e
#endif
- )
- where
-import Prelude ()
+handleIO :: (IOException -> IO a) -> IO a -> IO a
+handleIO = flip catchIO
+tryIO :: IO a -> IO (Either IOException a)
#if __GLASGOW_HASKELL__ >= 609
-import Control.OldException
+tryIO = try
#else
-import Control.Exception
+tryIO io = do ei <- try io
+ case ei of
+ Right v -> return (Right v)
+ Left (IOException ioe) -> return (Left ioe)
+ Left e -> throwIO e
#endif