|Maintainer||tov at ccs dot neu dot edu|
THIS PACKAGE HAS BEEN SUPERSEDED.
For GHC >= 6.10, check out the control-monad-exception
package at Hackage at
It does everything this package does and works with the new
A generalization of exception handling, both inside and outside the
IO monad. Based on Oleg Kiselyov's Control.Exception.MonadIO.
In the GHC library, catch has type
IO a -> (Exception -> IO a) -> IO a. If you are using monad
transformers on top of IO, this means that you can still use liftIO
to catch exceptions, but the handler has to be written in the IO
monad, not the richer monad that you're working in.
This module provides an API to fix this problem: Simply define an
instances of EMonad for your monad transformer, and then use gcatch
to catch exceptions and glift rather than lift to faithfully
propogate exceptions out of the lifted term.
|Classes and types
|class Monad m => EMonad m where|
|Minimal complete definition: gthrow, and one of gcatch,
ghandle, or gtry. (It turns out to be slightly useful to be able
to define in terms of any of these; e.g., for the EMonad Either
instance, gtry = Right.)
|gthrow :: Exception -> m a|
|gcatch :: m a -> (Exception -> m a) -> m a|
|ghandle :: (Exception -> m a) -> m a -> m a|
|gtry :: m a -> m (Either Exception a)|
|class (EMonad m, MonadIO m) => EMonadIO m |
|Exception types (re-exported)
|glift :: (MonadTrans t, EMonad m, EMonad (t m)) => m a -> t m a|
|This is like lift, but it catches exceptions on the inside and
lifts them on the outside.
|guntry :: EMonad m => Either Exception a -> m a|
|This is kind of a useful function -- it's the opposite of gtry.
|Lots of functions
|These are based on the functions in Control.Exception; they
all do the things indicated clearly by their types.
|gthrowStr :: EMonad m => String -> m a|
|gcatchJust :: EMonad m => (Exception -> Maybe b) -> m a -> (b -> m a) -> m a|
|ghandleJust :: EMonad m => (Exception -> Maybe b) -> (b -> m a) -> m a -> m a|
|gtryJust :: EMonad m => (Exception -> Maybe b) -> m b1 -> m (Either b b1)|
|gignore :: EMonad m => m a -> m ()|
|gignoreJust :: EMonad m => (Exception -> Maybe b) -> m a -> m ()|
|gthrowDyn :: (Typeable exc, EMonad m) => exc -> m a|
|gcatchDyn :: (Typeable exc, EMonad m) => m a -> (exc -> m a) -> m a|
|ghandleDyn :: (Typeable exc, EMonad m) => (exc -> m a) -> m a -> m a|
|gtryDyn :: (Typeable exc, EMonad m) => m a -> m (Either exc a)|
|This is cool -- it's a gtry variant that only pulls out
dynamic exceptions of one type.
|gbracket :: EMonad m => m a -> (a -> m b) -> (a -> m c) -> m c|
|Note that this gbracket does not protect the cleanup code; I
contend that it shouldn't, because starting the cleanup again if it
throws the first time is almost never the right thing to do.
|gbracket_ :: EMonad m => m a -> m b -> m c -> m c|
|gfinally :: EMonad m => m a -> m b -> m a|
|tests__Control_Exception_Generic :: Test|
|Test cases. Most of these functions are suffciently constrained
by their types that they can't do the wrong thing unless there's
something obviously absurd in them.
|Produced by Haddock version 2.4.1|