ContentsIndex
Prime.Exception
Portabilitynon-portable
Stabilityexperimental
Maintainer-- not in the library at the moment!
Description

This module provides support for raising and catching both built-in and user-defined exceptions in user defined monads. It is adapted from Control.Exception and extends the code supplied by oleg at pobox.com on the Haskell mailing list to lift all functions in Control.Exception to all monads formed by applying common monad transformers to monads based on IO.

Refs: http://www.haskell.org/pipermail/haskell/2006-February/017547.html

To use this you should hide all the conflicting Prelude functions or disable implicit Prelude and use a minimal Prelude as suggested in http://hackage.haskell.org/trac/haskell-prime/wiki/Prelude

THIS MODULE HAS NOT BEEN FULLY TESTED AND IS JUST PROVIDED AS AN EXAMPLE FOR DISCUSSION. In particular, you should read Oleg's comments above regarding semantics of the different monads under exceptions, and if in doubt, consider ReaderT instead of StateT.

If you find any bugs in this module, please send an email to brianh at metamilk.com

Synopsis
class MonadIO m => MonadException m where
catch :: m a -> (Exception -> m a) -> m a
block :: m a -> m a
unblock :: m a -> m a
setUncaughtExceptionHandler :: (Exception -> m ()) -> m ()
Exception
IOException
ArithException
ArrayException
AsyncException
mapException
ioErrors
arithExceptions
errorCalls
dynExceptions
assertions
asyncExceptions
userErrors
assert
ioError :: MonadIO m => IOError -> m a
evaluate :: MonadIO m => a -> m a
getUncaughtExceptionHandler :: MonadIO m => m (Exception -> m ())
throw
throwDyn
throwM :: MonadIO m => Exception -> m a
throwTo :: MonadIO m => ThreadId -> Exception -> m ()
throwDynTo :: (MonadIO m, Typeable exception) => ThreadId -> exception -> m ()
handle :: MonadException m => (Exception -> m a) -> m a -> m a
handleDyn :: (Typeable exception, MonadException m) => (exception -> m a) -> m a -> m a
handleJust :: MonadException m => (Exception -> Maybe b) -> (b -> m a) -> m a -> m a
catchDyn :: (Typeable exception, MonadException m) => m a -> (exception -> m a) -> m a
catchJust :: MonadException m => (Exception -> Maybe b) -> m a -> (b -> m a) -> m a
try :: MonadException m => m a -> m (Either Exception a)
tryJust :: MonadException m => (Exception -> Maybe b) -> m a -> m (Either b a)
bracket :: MonadException m => m a -> (a -> m b) -> (a -> m c) -> m c
bracket_ :: MonadException m => m a -> m b -> m c -> m c
finally :: MonadException m => m a -> m b -> m a
Documentation
class MonadIO m => MonadException m where
It is debatable whether or not MonadException should derive from MonadIO since none of the functions require MonadIO. However a MonadException context will usually also involve use of liftIO or throwM etc which needs a MonadIO
Methods
catch :: m a -> (Exception -> m a) -> m a
block :: m a -> m a
unblock :: m a -> m a
setUncaughtExceptionHandler :: (Exception -> m ()) -> m ()
show/hide Instances
MonadException IO
MonadException m => MonadException (ListT m)
(MonadException m, Error e) => MonadException (ErrorT e m)
MonadException m => MonadException (ReaderT r m)
MonadException m => MonadException (StateT s m)
(MonadException m, Monoid w) => MonadException (WriterT w m)
(MonadException m, Monoid w) => MonadException (RWST r w s m)
Exception
IOException
ArithException
ArrayException
AsyncException
mapException
ioErrors
arithExceptions
errorCalls
dynExceptions
assertions
asyncExceptions
userErrors
assert
ioError :: MonadIO m => IOError -> m a
evaluate :: MonadIO m => a -> m a
getUncaughtExceptionHandler :: MonadIO m => m (Exception -> m ())
throw
throwDyn
throwM :: MonadIO m => Exception -> m a
throwTo :: MonadIO m => ThreadId -> Exception -> m ()
throwDynTo :: (MonadIO m, Typeable exception) => ThreadId -> exception -> m ()
handle :: MonadException m => (Exception -> m a) -> m a -> m a
handleDyn :: (Typeable exception, MonadException m) => (exception -> m a) -> m a -> m a
handleJust :: MonadException m => (Exception -> Maybe b) -> (b -> m a) -> m a -> m a
catchDyn :: (Typeable exception, MonadException m) => m a -> (exception -> m a) -> m a
catchJust :: MonadException m => (Exception -> Maybe b) -> m a -> (b -> m a) -> m a
try :: MonadException m => m a -> m (Either Exception a)
tryJust :: MonadException m => (Exception -> Maybe b) -> m a -> m (Either b a)
bracket :: MonadException m => m a -> (a -> m b) -> (a -> m c) -> m c
bracket_ :: MonadException m => m a -> m b -> m c -> m c
finally :: MonadException m => m a -> m b -> m a
Produced by Haddock version 0.8