[commit: base] master: Use throwIO rather than throw where possible (c78232d)
Simon Peyton Jones
simonpj at microsoft.com
Fri Feb 17 15:03:13 CET 2012
Repository : ssh://darcs.haskell.org//srv/darcs/packages/base
On branch : master
http://hackage.haskell.org/trac/ghc/changeset/c78232da6d163fae9725a03128648f1015efd541
>---------------------------------------------------------------
commit c78232da6d163fae9725a03128648f1015efd541
Author: Simon Peyton Jones <simonpj at microsoft.com>
Date: Fri Feb 17 14:02:33 2012 +0000
Use throwIO rather than throw where possible
This makes exceptions more predictable.
>---------------------------------------------------------------
Control/OldException.hs | 16 ++++++++--------
1 files changed, 8 insertions(+), 8 deletions(-)
diff --git a/Control/OldException.hs b/Control/OldException.hs
index 0b4d751..865ebfa 100644
--- a/Control/OldException.hs
+++ b/Control/OldException.hs
@@ -286,7 +286,7 @@ catchJust
-> IO a
catchJust p a handler = catch a handler'
where handler' e = case p e of
- Nothing -> throw e
+ Nothing -> throwIO e
Just b -> handler b
-- | A version of 'catch' with the arguments swapped around; useful in
@@ -312,7 +312,7 @@ handleJust p = flip (catchJust p)
mapException :: (Exception -> Exception) -> a -> a
mapException f v = unsafePerformIO (catch (evaluate v)
- (\x -> throw (f x)))
+ (\x -> throwIO (f x)))
-----------------------------------------------------------------------------
-- 'try' and variations.
@@ -344,7 +344,7 @@ tryJust p a = do
case r of
Right v -> return (Right v)
Left e -> case p e of
- Nothing -> throw e
+ Nothing -> throwIO e
Just b -> return (Left b)
-----------------------------------------------------------------------------
@@ -389,8 +389,8 @@ catchDyn m k = New.catch m handler
(DynException dyn) ->
case fromDynamic dyn of
Just exception -> k exception
- Nothing -> throw ex
- _ -> throw ex
+ Nothing -> throwIO ex
+ _ -> throwIO ex
#endif
-----------------------------------------------------------------------------
@@ -463,7 +463,7 @@ bracket before after thing =
a <- before
r <- catch
(restore (thing a))
- (\e -> do { _ <- after a; throw e })
+ (\e -> do { _ <- after a; throwIO e })
_ <- after a
return r
#endif
@@ -479,7 +479,7 @@ a `finally` sequel =
mask $ \restore -> do
r <- catch
(restore a)
- (\e -> do { _ <- sequel; throw e })
+ (\e -> do { _ <- sequel; throwIO e })
_ <- sequel
return r
@@ -500,7 +500,7 @@ bracketOnError before after thing =
a <- before
catch
(restore (thing a))
- (\e -> do { _ <- after a; throw e })
+ (\e -> do { _ <- after a; throwIO e })
-- -----------------------------------------------------------------------------
-- Asynchronous exceptions
More information about the Cvs-libraries
mailing list