ghc-8.2.2: The GHC API

Safe HaskellSafe
LanguageHaskell2010

Exception

Synopsis

Documentation

catchIO :: IO a -> (IOException -> IO a) -> IO a Source #

handleIO :: (IOException -> IO a) -> IO a -> IO a Source #

class MonadIO m => ExceptionMonad m where Source #

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

Implementations on top of IO should implement gmask to eventually call the primitive mask. These are used for implementations that support asynchronous exceptions. The default implementations of gbracket and gfinally use gmask thus rarely require overriding.

Minimal complete definition

gcatch, gmask

Methods

gcatch :: Exception e => m a -> (e -> m a) -> m a Source #

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

gmask :: ((m a -> m a) -> m b) -> m b Source #

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

gbracket :: m a -> (a -> m b) -> (a -> m c) -> m c Source #

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

gfinally :: m a -> m b -> m a Source #

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

Instances

ExceptionMonad IO Source # 

Methods

gcatch :: Exception e => IO a -> (e -> IO a) -> IO a Source #

gmask :: ((IO a -> IO a) -> IO b) -> IO b Source #

gbracket :: IO a -> (a -> IO b) -> (a -> IO c) -> IO c Source #

gfinally :: IO a -> IO b -> IO a Source #

ExceptionMonad Ghc Source # 

Methods

gcatch :: Exception e => Ghc a -> (e -> Ghc a) -> Ghc a Source #

gmask :: ((Ghc a -> Ghc a) -> Ghc b) -> Ghc b Source #

gbracket :: Ghc a -> (a -> Ghc b) -> (a -> Ghc c) -> Ghc c Source #

gfinally :: Ghc a -> Ghc b -> Ghc a Source #

ExceptionMonad (IOEnv a) Source # 

Methods

gcatch :: Exception e => IOEnv a a -> (e -> IOEnv a a) -> IOEnv a a Source #

gmask :: ((IOEnv a a -> IOEnv a a) -> IOEnv a b) -> IOEnv a b Source #

gbracket :: IOEnv a a -> (a -> IOEnv a b) -> (a -> IOEnv a c) -> IOEnv a c Source #

gfinally :: IOEnv a a -> IOEnv a b -> IOEnv a a Source #

ExceptionMonad m => ExceptionMonad (GhcT m) Source # 

Methods

gcatch :: Exception e => GhcT m a -> (e -> GhcT m a) -> GhcT m a Source #

gmask :: ((GhcT m a -> GhcT m a) -> GhcT m b) -> GhcT m b Source #

gbracket :: GhcT m a -> (a -> GhcT m b) -> (a -> GhcT m c) -> GhcT m c Source #

gfinally :: GhcT m a -> GhcT m b -> GhcT m a Source #

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

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

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

gonException :: ExceptionMonad m => m a -> m b -> m a Source #

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