| Safe Haskell | Safe |
|---|---|
| Language | Haskell2010 |
Exception
Synopsis
- class MonadIO m => ExceptionMonad m where
- catchIO :: IO a -> (IOException -> IO a) -> IO a
- handleIO :: (IOException -> IO a) -> IO a -> IO a
- tryIO :: IO a -> IO (Either IOException 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
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.
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 # | |
| ExceptionMonad Ghc Source # | |
| ExceptionMonad (IOEnv a) Source # | |
| ExceptionMonad m => ExceptionMonad (GhcT m) 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.