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

Control.Monad.Except.IO

Synopsis

Documentation

newtype ExceptIOT e m a Source #

This type is useful for providing a MonadError constraint to an IO action for a given type. It can replace ExceptT.

Note that catchError will use the behavior from UnliftIO - so catch won't catch an asynchronous exception.

Since: 0.1.0.0

Constructors

ExceptIOT 

Fields

Instances

Instances details
(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 #

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

Defined in Control.Monad.Except.IO

Methods

ask :: ExceptIOT e m r #

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

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

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

Defined in Control.Monad.Except.IO

Methods

get :: ExceptIOT e m s #

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

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

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

Defined in Control.Monad.Except.IO

Methods

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

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

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

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

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

Defined in Control.Monad.Except.IO

Methods

fail :: String -> ExceptIOT e m a #

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

Defined in Control.Monad.Except.IO

Methods

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

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

Defined in Control.Monad.Except.IO

Methods

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

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

Defined in Control.Monad.Except.IO

Methods

empty :: ExceptIOT e m a #

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

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

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

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

Defined in Control.Monad.Except.IO

Methods

pure :: a -> ExceptIOT e m a #

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

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

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

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

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

Defined in Control.Monad.Except.IO

Methods

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

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

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

Defined in Control.Monad.Except.IO

Methods

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

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

return :: a -> ExceptIOT e m a #

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

Defined in Control.Monad.Except.IO

Methods

mzero :: ExceptIOT e m a #

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

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

Defined in Control.Monad.Except.IO

Methods

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

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

Defined in Control.Monad.Except.IO

Methods

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

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

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

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

Defined in Control.Monad.Except.IO

Methods

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

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

Defined in Control.Monad.Except.IO

Methods

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

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

Defined in Control.Monad.Except.IO

Methods

mempty :: ExceptIOT e m a #

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

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

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

Defined in Control.Monad.Except.IO

Methods

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

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

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

runExceptIOT :: (Exception e, MonadUnliftIO m) => ExceptIOT e m a -> m (Either e a) Source #

Run an ExceptIOT action. This catches the thrown exception, but only if it is the e that the type mentions. All other exceptions will remain uncaught.

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, MonadUnliftIO m, MonadError e' m) => (e -> e') -> ExceptIOT e m a -> m a Source #

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

Since: 0.1.0.0