exceptiot-0.0.1.1: ExceptT, but uses IO instead of Either
Safe HaskellSafe-Inferred
LanguageHaskell2010

Control.Monad.Except.Catch

Synopsis

Documentation

newtype ExceptCatchT e m a Source #

This type is useful for translating a MonadError constraint into MonadCatch. This type does not have an Either return, which means we can provide a MonadUnliftIO instance.

Since: 0.1.0.0

Constructors

ExceptCatchT 

Fields

Instances

Instances details
(MonadCatch m, Exception e) => MonadError e (ExceptCatchT e m) Source #

Since: 0.1.0.0

Instance details

Defined in Control.Monad.Except.Catch

Methods

throwError :: e -> ExceptCatchT e m a #

catchError :: ExceptCatchT e m a -> (e -> ExceptCatchT e m a) -> ExceptCatchT e m a #

MonadReader r m => MonadReader r (ExceptCatchT e m) Source # 
Instance details

Defined in Control.Monad.Except.Catch

Methods

ask :: ExceptCatchT e m r #

local :: (r -> r) -> ExceptCatchT e m a -> ExceptCatchT e m a #

reader :: (r -> a) -> ExceptCatchT e m a #

MonadState s m => MonadState s (ExceptCatchT e m) Source # 
Instance details

Defined in Control.Monad.Except.Catch

Methods

get :: ExceptCatchT e m s #

put :: s -> ExceptCatchT e m () #

state :: (s -> (a, s)) -> ExceptCatchT e m a #

MonadWriter w m => MonadWriter w (ExceptCatchT e m) Source # 
Instance details

Defined in Control.Monad.Except.Catch

Methods

writer :: (a, w) -> ExceptCatchT e m a #

tell :: w -> ExceptCatchT e m () #

listen :: ExceptCatchT e m a -> ExceptCatchT e m (a, w) #

pass :: ExceptCatchT e m (a, w -> w) -> ExceptCatchT e m a #

MonadFail m => MonadFail (ExceptCatchT e m) Source # 
Instance details

Defined in Control.Monad.Except.Catch

Methods

fail :: String -> ExceptCatchT e m a #

MonadFix m => MonadFix (ExceptCatchT e m) Source # 
Instance details

Defined in Control.Monad.Except.Catch

Methods

mfix :: (a -> ExceptCatchT e m a) -> ExceptCatchT e m a #

MonadIO m => MonadIO (ExceptCatchT e m) Source # 
Instance details

Defined in Control.Monad.Except.Catch

Methods

liftIO :: IO a -> ExceptCatchT e m a #

Alternative m => Alternative (ExceptCatchT e m) Source # 
Instance details

Defined in Control.Monad.Except.Catch

Methods

empty :: ExceptCatchT e m a #

(<|>) :: ExceptCatchT e m a -> ExceptCatchT e m a -> ExceptCatchT e m a #

some :: ExceptCatchT e m a -> ExceptCatchT e m [a] #

many :: ExceptCatchT e m a -> ExceptCatchT e m [a] #

Applicative m => Applicative (ExceptCatchT e m) Source # 
Instance details

Defined in Control.Monad.Except.Catch

Methods

pure :: a -> ExceptCatchT e m a #

(<*>) :: ExceptCatchT e m (a -> b) -> ExceptCatchT e m a -> ExceptCatchT e m b #

liftA2 :: (a -> b -> c) -> ExceptCatchT e m a -> ExceptCatchT e m b -> ExceptCatchT e m c #

(*>) :: ExceptCatchT e m a -> ExceptCatchT e m b -> ExceptCatchT e m b #

(<*) :: ExceptCatchT e m a -> ExceptCatchT e m b -> ExceptCatchT e m a #

Functor m => Functor (ExceptCatchT e m) Source # 
Instance details

Defined in Control.Monad.Except.Catch

Methods

fmap :: (a -> b) -> ExceptCatchT e m a -> ExceptCatchT e m b #

(<$) :: a -> ExceptCatchT e m b -> ExceptCatchT e m a #

Monad m => Monad (ExceptCatchT e m) Source # 
Instance details

Defined in Control.Monad.Except.Catch

Methods

(>>=) :: ExceptCatchT e m a -> (a -> ExceptCatchT e m b) -> ExceptCatchT e m b #

(>>) :: ExceptCatchT e m a -> ExceptCatchT e m b -> ExceptCatchT e m b #

return :: a -> ExceptCatchT e m a #

MonadPlus m => MonadPlus (ExceptCatchT e m) Source # 
Instance details

Defined in Control.Monad.Except.Catch

Methods

mzero :: ExceptCatchT e m a #

mplus :: ExceptCatchT e m a -> ExceptCatchT e m a -> ExceptCatchT e m a #

MonadCatch m => MonadCatch (ExceptCatchT e m) Source # 
Instance details

Defined in Control.Monad.Except.Catch

Methods

catch :: (HasCallStack, Exception e0) => ExceptCatchT e m a -> (e0 -> ExceptCatchT e m a) -> ExceptCatchT e m a #

MonadMask m => MonadMask (ExceptCatchT e m) Source # 
Instance details

Defined in Control.Monad.Except.Catch

Methods

mask :: HasCallStack => ((forall a. ExceptCatchT e m a -> ExceptCatchT e m a) -> ExceptCatchT e m b) -> ExceptCatchT e m b #

uninterruptibleMask :: HasCallStack => ((forall a. ExceptCatchT e m a -> ExceptCatchT e m a) -> ExceptCatchT e m b) -> ExceptCatchT e m b #

generalBracket :: HasCallStack => ExceptCatchT e m a -> (a -> ExitCase b -> ExceptCatchT e m c) -> (a -> ExceptCatchT e m b) -> ExceptCatchT e m (b, c) #

MonadThrow m => MonadThrow (ExceptCatchT e m) Source # 
Instance details

Defined in Control.Monad.Except.Catch

Methods

throwM :: (HasCallStack, Exception e0) => e0 -> ExceptCatchT e m a #

MonadUnliftIO m => MonadUnliftIO (ExceptCatchT e m) Source # 
Instance details

Defined in Control.Monad.Except.Catch

Methods

withRunInIO :: ((forall a. ExceptCatchT e m a -> IO a) -> IO b) -> ExceptCatchT e m b #

Monoid (m a) => Monoid (ExceptCatchT e m a) Source # 
Instance details

Defined in Control.Monad.Except.Catch

Methods

mempty :: ExceptCatchT e m a #

mappend :: ExceptCatchT e m a -> ExceptCatchT e m a -> ExceptCatchT e m a #

mconcat :: [ExceptCatchT e m a] -> ExceptCatchT e m a #

Semigroup (m a) => Semigroup (ExceptCatchT e m a) Source # 
Instance details

Defined in Control.Monad.Except.Catch

Methods

(<>) :: ExceptCatchT e m a -> ExceptCatchT e m a -> ExceptCatchT e m a #

sconcat :: NonEmpty (ExceptCatchT e m a) -> ExceptCatchT e m a #

stimes :: Integral b => b -> ExceptCatchT e m a -> ExceptCatchT e m a #

runExceptCatchT :: (Exception e, MonadCatch m) => ExceptCatchT e m a -> m (Either e a) Source #

Run an ExceptCatchT action. This will catch any thrown e exceptions, regardless of whether you used throwM or throwError.

Any exception that is not mentioned in e will be thrown - this does not catch all exceptions!

Since: 0.1.0.0

class Monad m => MonadError e (m :: Type -> Type) | m -> e where #

The strategy of combining computations that can throw exceptions by bypassing bound functions from the point an exception is thrown to the point that it is handled.

Is parameterized over the type of error information and the monad type constructor. It is common to use Either String as the monad type constructor for an error monad in which error descriptions take the form of strings. In that case and many other common cases the resulting monad is already defined as an instance of the MonadError class. You can also define your own error type and/or use a monad type constructor other than Either String or Either IOError. In these cases you will have to explicitly define instances of the MonadError class. (If you are using the deprecated Control.Monad.Error or Control.Monad.Trans.Error, you may also have to define an Error instance.)

Methods

throwError :: e -> m a #

Is used within a monadic computation to begin exception processing.

catchError :: m a -> (e -> m a) -> m a #

A handler function to handle previous errors and return to normal execution. A common idiom is:

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

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

Instances

Instances details
MonadError IOException IO 
Instance details

Defined in Control.Monad.Error.Class

Methods

throwError :: IOException -> IO a #

catchError :: IO a -> (IOException -> IO a) -> IO a #

MonadError () Maybe

Since: mtl-2.2.2

Instance details

Defined in Control.Monad.Error.Class

Methods

throwError :: () -> Maybe a #

catchError :: Maybe a -> (() -> Maybe a) -> Maybe a #

MonadError e (Either e) 
Instance details

Defined in Control.Monad.Error.Class

Methods

throwError :: e -> Either e a #

catchError :: Either e a -> (e -> Either e a) -> Either e a #

MonadError e m => MonadError e (MaybeT m) 
Instance details

Defined in Control.Monad.Error.Class

Methods

throwError :: e -> MaybeT m a #

catchError :: MaybeT m a -> (e -> MaybeT m a) -> MaybeT m a #

(MonadCatch m, Exception e) => MonadError e (ExceptCatchT e m) Source #

Since: 0.1.0.0

Instance details

Defined in Control.Monad.Except.Catch

Methods

throwError :: e -> ExceptCatchT e m a #

catchError :: ExceptCatchT e m a -> (e -> ExceptCatchT e m a) -> ExceptCatchT e m a #

(MonadUnliftIO m, Exception e) => MonadError e (ExceptIOT e m) Source #

Since: 0.1.0.0

Instance details

Defined in Control.Monad.Except.IO

Methods

throwError :: e -> ExceptIOT e m a #

catchError :: ExceptIOT e m a -> (e -> ExceptIOT e m a) -> ExceptIOT e m a #

(Monoid w, MonadError e m) => MonadError e (AccumT w m)

Since: mtl-2.3

Instance details

Defined in Control.Monad.Error.Class

Methods

throwError :: e -> AccumT w m a #

catchError :: AccumT w m a -> (e -> AccumT w m a) -> AccumT w m a #

Monad m => MonadError e (ExceptT e m)

Since: mtl-2.2

Instance details

Defined in Control.Monad.Error.Class

Methods

throwError :: e -> ExceptT e m a #

catchError :: ExceptT e m a -> (e -> ExceptT e m a) -> ExceptT e m a #

MonadError e m => MonadError e (IdentityT m) 
Instance details

Defined in Control.Monad.Error.Class

Methods

throwError :: e -> IdentityT m a #

catchError :: IdentityT m a -> (e -> IdentityT m a) -> IdentityT m a #

MonadError e m => MonadError e (ReaderT r m) 
Instance details

Defined in Control.Monad.Error.Class

Methods

throwError :: e -> ReaderT r m a #

catchError :: ReaderT r m a -> (e -> ReaderT r m a) -> ReaderT r m a #

MonadError e m => MonadError e (StateT s m) 
Instance details

Defined in Control.Monad.Error.Class

Methods

throwError :: e -> StateT s m a #

catchError :: StateT s m a -> (e -> StateT s m a) -> StateT s m a #

MonadError e m => MonadError e (StateT s m) 
Instance details

Defined in Control.Monad.Error.Class

Methods

throwError :: e -> StateT s m a #

catchError :: StateT s m a -> (e -> StateT s m a) -> StateT s m a #

(Monoid w, MonadError e m) => MonadError e (WriterT w m)

Since: mtl-2.3

Instance details

Defined in Control.Monad.Error.Class

Methods

throwError :: e -> WriterT w m a #

catchError :: WriterT w m a -> (e -> WriterT w m a) -> WriterT w m a #

(Monoid w, MonadError e m) => MonadError e (WriterT w m) 
Instance details

Defined in Control.Monad.Error.Class

Methods

throwError :: e -> WriterT w m a #

catchError :: WriterT w m a -> (e -> WriterT w m a) -> WriterT w m a #

(Monoid w, MonadError e m) => MonadError e (WriterT w m) 
Instance details

Defined in Control.Monad.Error.Class

Methods

throwError :: e -> WriterT w m a #

catchError :: WriterT w m a -> (e -> WriterT w m a) -> WriterT w m a #

(Monoid w, MonadError e m) => MonadError e (RWST r w s m)

Since: mtl-2.3

Instance details

Defined in Control.Monad.Error.Class

Methods

throwError :: e -> RWST r w s m a #

catchError :: RWST r w s m a -> (e -> RWST r w s m a) -> RWST r w s m a #

(Monoid w, MonadError e m) => MonadError e (RWST r w s m) 
Instance details

Defined in Control.Monad.Error.Class

Methods

throwError :: e -> RWST r w s m a #

catchError :: RWST r w s m a -> (e -> RWST r w s m a) -> RWST r w s m a #

(Monoid w, MonadError e m) => MonadError e (RWST r w s m) 
Instance details

Defined in Control.Monad.Error.Class

Methods

throwError :: e -> RWST r w s m a #

catchError :: RWST r w s m a -> (e -> RWST r w s m a) -> RWST r w s m a #

liftEither :: MonadError e m => Either e a -> m a #

Lifts an Either e into any MonadError e.

do { val <- liftEither =<< action1; action2 }

where action1 returns an Either to represent errors.

Since: mtl-2.2.2

tryError :: MonadError e m => m a -> m (Either e a) #

MonadError analogue to the try function.

withError :: MonadError e m => (e -> e) -> m a -> m a #

MonadError analogue to the withExceptT function. Modify the value (but not the type) of an error. The type is fixed because of the functional dependency m -> e. If you need to change the type of e use mapError or modifyError.

handleError :: MonadError e m => (e -> m a) -> m a -> m a #

As handle is flipped catch, handleError is flipped catchError.

mapError :: (MonadError e m, MonadError e' n) => (m (Either e a) -> n (Either e' b)) -> m a -> n b #

MonadError analogue of the mapExceptT function. The computation is unwrapped, a function is applied to the Either, and the result is lifted into the second MonadError instance.

modifyError :: (Exception e, MonadCatch m, MonadError e' m) => (e -> e') -> ExceptCatchT e m a -> m a Source #

Like modifyError, but it selects the ExceptCatchT instance for IO exceptions instead of the ExceptT instance with an Either error.

Since: 0.1.0.0