catch-fd-0.2.0.0: MonadThrow and MonadCatch, using functional dependencies

Safe HaskellSafe-Inferred

Control.Monad.Catch

Synopsis

Documentation

class Monad m => MonadThrow e m | m -> e whereSource

The strategy of combining computations that can throw exceptions.

Is parameterized over the type of error information and the monad type constructor. It is common to use Either String. In some cases you will have to define an instance of MonadThrow, though rarely a definition of throw

Methods

throw :: e -> m aSource

Is used within a monadic computation to begin exception processing. If (MonadThrow e n, MonadTrans t) => t n ~ m, then throw = lift . throw is the default definition.

Instances

MonadThrow IOException IO 
(Monad (MaybeT m), MonadThrow e m) => MonadThrow e (MaybeT m) 
(Monad (ListT m), MonadThrow e m) => MonadThrow e (ListT m) 
(Monad (IdentityT m), MonadThrow e m) => MonadThrow e (IdentityT m) 
Monad (Either e) => MonadThrow e (Either e) 
(Monad (WrappedMonadCatch m), MonadThrow e m) => MonadThrow e (WrappedMonadCatch m) 
(Monad (WrappedMonadError m), MonadError e m) => MonadThrow e (WrappedMonadError m) 
(Monad (WriterT w m), Monoid w, MonadThrow e m) => MonadThrow e (WriterT w m) 
(Monad (WriterT w m), Monoid w, MonadThrow e m) => MonadThrow e (WriterT w m) 
(Monad (StateT s m), MonadThrow e m) => MonadThrow e (StateT s m) 
(Monad (StateT s m), MonadThrow e m) => MonadThrow e (StateT s m) 
(Monad (ReaderT r m), MonadThrow e m) => MonadThrow e (ReaderT r m) 
(Monad (ErrorT e m), Error e, Monad m) => MonadThrow e (ErrorT e m) 
(Monad (RWST r w s m), Monoid w, MonadThrow e m) => MonadThrow e (RWST r w s m) 
(Monad (RWST r w s m), Monoid w, MonadThrow e m) => MonadThrow e (RWST r w s m) 

class (MonadThrow e m, Monad n) => MonadCatch e m n | n e -> m whereSource

The strategy of combining computations that can handle thrown exceptions, as well as throwing exceptions in the original computation.

Is parameterized over the type of error information and the original monad type constructor, as well as the handler monad type constructor. The handler monad type constructor commonly differs from the original monad type constructor due to a change in the type of the error information.

Methods

catch :: m a -> (e -> n a) -> n aSource

A handler function to handle thrown values and return to normal execution. A common idiom is:

 do { action1; action2; action3 } `catch` handler

where the action functions can call throw. Note that handler and the do-block must have the same return type.

Instances

MonadCatch IOException IO IO 
(MonadThrow e (MaybeT m), Monad (MaybeT n), MonadCatch e m n) => MonadCatch e (MaybeT m) (MaybeT n) 
(MonadThrow e (ListT m), Monad (ListT n), MonadCatch e m n) => MonadCatch e (ListT m) (ListT n) 
(MonadThrow e (IdentityT m), Monad (IdentityT n), MonadCatch e m n) => MonadCatch e (IdentityT m) (IdentityT n) 
(MonadThrow e (Either e), Monad (Either e')) => MonadCatch e (Either e) (Either e') 
(MonadThrow e (WrappedMonadCatch m), Monad (WrappedMonadCatch n), MonadCatch e m n) => MonadCatch e (WrappedMonadCatch m) (WrappedMonadCatch n) 
(MonadThrow e (WrappedMonadError m), Monad (WrappedMonadError m), MonadError e m) => MonadCatch e (WrappedMonadError m) (WrappedMonadError m) 
(MonadThrow e (WriterT w m), Monad (WriterT w n), Monoid w, MonadCatch e m n) => MonadCatch e (WriterT w m) (WriterT w n) 
(MonadThrow e (WriterT w m), Monad (WriterT w n), Monoid w, MonadCatch e m n) => MonadCatch e (WriterT w m) (WriterT w n) 
(MonadThrow e (StateT s m), Monad (StateT s n), MonadCatch e m n) => MonadCatch e (StateT s m) (StateT s n) 
(MonadThrow e (StateT s m), Monad (StateT s n), MonadCatch e m n) => MonadCatch e (StateT s m) (StateT s n) 
(MonadThrow e (ReaderT r m), Monad (ReaderT r n), MonadCatch e m n) => MonadCatch e (ReaderT r m) (ReaderT r n) 
(MonadThrow e (ErrorT e m), Monad (ErrorT e' m), Error e, Error e', Monad m) => MonadCatch e (ErrorT e m) (ErrorT e' m) 
(MonadThrow e (RWST r w s m), Monad (RWST r w s n), Monoid w, MonadCatch e m n) => MonadCatch e (RWST r w s m) (RWST r w s n) 
(MonadThrow e (RWST r w s m), Monad (RWST r w s n), Monoid w, MonadCatch e m n) => MonadCatch e (RWST r w s m) (RWST r w s n) 

mapE :: (MonadCatch e m n, MonadThrow e' n) => (e -> e') -> m a -> n aSource

Map the thrown value using the given function

type MonadError e m = (MonadThrow e m, MonadCatch e m m)Source