Removed: catchAny, handleAny, ignoreExceptions
These make it easy to eat /any/ exception, which is rarely what you want.
Normally you either want to:
* only catch exceptions in a certain part of the hierarchy, e.g.
"file not found", in which case you should only catch exceptions
of the appropriate type,
or
* you want to do some cleanup when an exception happens, and then rethrow
the exception, in which case you should use onException, or one of the
bracketing functions.
-- ** The @catch@ functions
catch, -- :: IO a -> (Exception -> IO a) -> IO a
catches, Handler(..),
-- ** The @catch@ functions
catch, -- :: IO a -> (Exception -> IO a) -> IO a
catches, Handler(..),
catchJust, -- :: (Exception -> Maybe b) -> IO a -> (b -> IO a) -> IO a
-- ** The @handle@ functions
handle, -- :: (Exception -> IO a) -> IO a -> IO a
catchJust, -- :: (Exception -> Maybe b) -> IO a -> (b -> IO a) -> IO a
-- ** The @handle@ functions
handle, -- :: (Exception -> IO a) -> IO a -> IO a
handleJust,-- :: (Exception -> Maybe b) -> (b -> IO a) -> IO a -> IO a
-- ** The @try@ functions
try, -- :: IO a -> IO (Either Exception a)
tryJust, -- :: (Exception -> Maybe b) -> a -> IO (Either b a)
handleJust,-- :: (Exception -> Maybe b) -> (b -> IO a) -> IO a -> IO a
-- ** The @try@ functions
try, -- :: IO a -> IO (Either Exception a)
tryJust, -- :: (Exception -> Maybe b) -> a -> IO (Either b a)
onException,
-- ** The @evaluate@ function
onException,
-- ** The @evaluate@ function
handle :: Exception e => (e -> IO a) -> IO a -> IO a
handle = flip catch
handle :: Exception e => (e -> IO a) -> IO a -> IO a
handle = flip catch
-handleAny :: (forall e . Exception e => e -> IO a) -> IO a -> IO a
-handleAny = flip catchAny
-
-- | A version of 'catchJust' with the arguments swapped around (see
-- 'handle').
handleJust :: Exception e => (e -> Maybe b) -> (b -> IO a) -> IO a -> IO a
-- | A version of 'catchJust' with the arguments swapped around (see
-- 'handle').
handleJust :: Exception e => (e -> Maybe b) -> (b -> IO a) -> IO a -> IO a
Nothing -> throw e
Just b -> return (Left b)
Nothing -> throw e
Just b -> return (Left b)
-ignoreExceptions :: IO () -> IO ()
-ignoreExceptions io = io `catchAny` \_ -> return ()
-
onException :: IO a -> IO () -> IO a
onException io what = io `catch` \e -> do what
throw (e :: SomeException)
onException :: IO a -> IO () -> IO a
onException io what = io `catch` \e -> do what
throw (e :: SomeException)
bracket before after thing =
block (do
a <- before
bracket before after thing =
block (do
a <- before
- r <- catchAny
- (unblock (thing a))
- (\e -> do { after a; throw e })
+ r <- unblock (thing a) `onException` after a
-> IO a -- returns the value from the first computation
a `finally` sequel =
block (do
-> IO a -- returns the value from the first computation
a `finally` sequel =
block (do
- r <- catchAny
- (unblock a)
- (\e -> do { sequel; throw e })
+ r <- unblock a `onException` sequel
bracketOnError before after thing =
block (do
a <- before
bracketOnError before after thing =
block (do
a <- before
- catchAny
- (unblock (thing a))
- (\e -> do { after a; throw e })
+ unblock (thing a) `onException` after a
)
-- -----------------------------------------------------------------------------
)
-- -----------------------------------------------------------------------------