ghc-7.0.3: The GHC API

Exception

Synopsis

Documentation

catchIO :: IO a -> (IOException -> IO a) -> IO aSource

handleIO :: (IOException -> IO a) -> IO a -> IO aSource

class Monad m => ExceptionMonad m whereSource

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 aSource

Generalised version of catch, allowing an arbitrary exception handling monad instead of just IO.

gmask :: ((m a -> m a) -> m b) -> m bSource

Generalised version of mask_, allowing an arbitrary exception handling monad instead of just IO.

gbracket :: m a -> (a -> m b) -> (a -> m c) -> m cSource

Generalised version of bracket, allowing an arbitrary exception handling monad instead of just IO.

gfinally :: m a -> m b -> m aSource

Generalised version of finally, allowing an arbitrary exception handling monad instead of just IO.

gblock :: m a -> m aSource

DEPRECATED, here for backwards compatibilty. Instances can define either gmask, or both block and unblock.

gunblock :: m a -> m aSource

DEPRECATED, here for backwards compatibilty Instances can define either gmask, or both block and unblock.

gtry :: (ExceptionMonad m, Exception e) => m a -> m (Either e a)Source

ghandle :: (ExceptionMonad m, Exception e) => (e -> m a) -> m a -> m aSource

Generalised version of handle, allowing an arbitrary exception handling monad instead of just IO.

gonException :: ExceptionMonad m => m a -> m b -> m aSource

Always executes the first argument. If this throws an exception the second argument is executed and the exception is raised again.