| ghc-6.10.4: The GHC API | Contents | Index

Exception

Synopsis

module Control.Exception
catchIO :: IO a -> (IOException -> IO a) -> IO a
handleIO :: (IOException -> IO a) -> IO a -> IO a
tryIO :: IO a -> IO (Either IOException a)
class Monad m => ExceptionMonad m where

gcatch :: Exception e => m a -> (e -> m a) -> m a
gblock :: m a -> m a
gunblock :: m a -> m a
gbracket :: m a -> (a -> m b) -> (a -> m c) -> m c
gfinally :: m a -> m b -> m a

gtry :: (ExceptionMonad m, Exception e) => m a -> m (Either e a)
ghandle :: (ExceptionMonad m, Exception e) => (e -> m a) -> m a -> m a
gonException :: ExceptionMonad m => m a -> m b -> m a

Documentation
module Control.Exception
catchIO :: IO a -> (IOException -> IO a) -> IO a
handleIO :: (IOException -> IO a) -> IO a -> IO a
tryIO :: IO a -> IO (Either IOException a)
class Monad m => ExceptionMonad m where

A monad that can catch exceptions. A minimal definition requires a definition of `gcatch`.

Implementations on top of `IO` should implement `gblock` and `gunblock` to eventually call the primitives `block` and `unblock` respectively. These are used for implementations that support asynchronous exceptions. The default implementations of `gbracket` and `gfinally` use `gblock` and `gunblock` thus rarely require overriding.

Methods

gcatch :: Exception e => m a -> (e -> m a) -> m a
Generalised version of `catch`, allowing an arbitrary exception handling monad instead of just `IO`.
gblock :: m a -> m a
Generalised version of `block`, allowing an arbitrary exception handling monad instead of just `IO`.
gunblock :: m a -> m a
Generalised version of `unblock`, allowing an arbitrary exception handling monad instead of just `IO`.
gbracket :: m a -> (a -> m b) -> (a -> m c) -> m c
Generalised version of `bracket`, allowing an arbitrary exception handling monad instead of just `IO`.
gfinally :: m a -> m b -> m a
Generalised version of `finally`, allowing an arbitrary exception handling monad instead of just `IO`.

Instances

ExceptionMonad IO
ExceptionMonad Ghc
ExceptionMonad m => ExceptionMonad (GhcT m)

gtry :: (ExceptionMonad m, Exception e) => m a -> m (Either e a)
ghandle :: (ExceptionMonad m, Exception e) => (e -> m a) -> m a -> m a
Generalised version of `handle`, allowing an arbitrary exception handling monad instead of just `IO`.
gonException :: ExceptionMonad m => m a -> m b -> m a
Always executes the first argument. If this throws an exception the second argument is executed and the exception is raised again.
Produced by Haddock version 2.4.2