-- Hoogle documentation, generated by Haddock -- See Hoogle, http://www.haskell.org/hoogle/ -- | ExceptT, but uses IO instead of Either -- -- Please see the README on Github at -- https://github.com/parsonsmatt/exceptiot#readme @package exceptiot @version 0.0.1.1 module Control.Monad.Except.Catch -- | 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. newtype ExceptCatchT e m a ExceptCatchT :: m a -> ExceptCatchT e m a [unsafeRunExceptCatchT] :: ExceptCatchT e m a -> m a -- | 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! runExceptCatchT :: (Exception e, MonadCatch m) => ExceptCatchT e m a -> m (Either e a) -- | 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.) class Monad m => MonadError e (m :: Type -> Type) | m -> e -- | Is used within a monadic computation to begin exception processing. throwError :: MonadError e m => e -> 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.
catchError :: MonadError e m => m a -> (e -> m a) -> m a
-- | Lifts an Either e into any MonadError
-- e.
--
--
-- do { val <- liftEither =<< action1; action2 }
--
--
-- where action1 returns an Either to represent errors.
liftEither :: MonadError e m => Either e a -> m a
-- | MonadError analogue to the try function.
tryError :: MonadError e m => m a -> m (Either e 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.
withError :: MonadError e m => (e -> e) -> m a -> m a
-- | As handle is flipped catch, handleError is
-- flipped catchError.
handleError :: MonadError e m => (e -> m a) -> m a -> m a
-- | 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.
mapError :: (MonadError e m, MonadError e' n) => (m (Either e a) -> n (Either e' b)) -> m a -> n b
-- | Like modifyError, but it selects the ExceptCatchT
-- instance for IO exceptions instead of the ExceptT
-- instance with an Either error.
modifyError :: (Exception e, MonadCatch m, MonadError e' m) => (e -> e') -> ExceptCatchT e m a -> m a
instance Control.Monad.Catch.MonadMask m => Control.Monad.Catch.MonadMask (Control.Monad.Except.Catch.ExceptCatchT e m)
instance Control.Monad.Catch.MonadCatch m => Control.Monad.Catch.MonadCatch (Control.Monad.Except.Catch.ExceptCatchT e m)
instance Control.Monad.Catch.MonadThrow m => Control.Monad.Catch.MonadThrow (Control.Monad.Except.Catch.ExceptCatchT e m)
instance Control.Monad.Fail.MonadFail m => Control.Monad.Fail.MonadFail (Control.Monad.Except.Catch.ExceptCatchT e m)
instance Control.Monad.Fix.MonadFix m => Control.Monad.Fix.MonadFix (Control.Monad.Except.Catch.ExceptCatchT e m)
instance Control.Monad.Writer.Class.MonadWriter w m => Control.Monad.Writer.Class.MonadWriter w (Control.Monad.Except.Catch.ExceptCatchT e m)
instance Control.Monad.State.Class.MonadState s m => Control.Monad.State.Class.MonadState s (Control.Monad.Except.Catch.ExceptCatchT e m)
instance Control.Monad.Reader.Class.MonadReader r m => Control.Monad.Reader.Class.MonadReader r (Control.Monad.Except.Catch.ExceptCatchT e m)
instance Control.Monad.IO.Unlift.MonadUnliftIO m => Control.Monad.IO.Unlift.MonadUnliftIO (Control.Monad.Except.Catch.ExceptCatchT e m)
instance GHC.Base.Monoid (m a) => GHC.Base.Monoid (Control.Monad.Except.Catch.ExceptCatchT e m a)
instance GHC.Base.Semigroup (m a) => GHC.Base.Semigroup (Control.Monad.Except.Catch.ExceptCatchT e m a)
instance GHC.Base.Alternative m => GHC.Base.Alternative (Control.Monad.Except.Catch.ExceptCatchT e m)
instance GHC.Base.MonadPlus m => GHC.Base.MonadPlus (Control.Monad.Except.Catch.ExceptCatchT e m)
instance Control.Monad.IO.Class.MonadIO m => Control.Monad.IO.Class.MonadIO (Control.Monad.Except.Catch.ExceptCatchT e m)
instance GHC.Base.Monad m => GHC.Base.Monad (Control.Monad.Except.Catch.ExceptCatchT e m)
instance GHC.Base.Applicative m => GHC.Base.Applicative (Control.Monad.Except.Catch.ExceptCatchT e m)
instance GHC.Base.Functor m => GHC.Base.Functor (Control.Monad.Except.Catch.ExceptCatchT e m)
instance (Control.Monad.Catch.MonadCatch m, GHC.Exception.Type.Exception e) => Control.Monad.Error.Class.MonadError e (Control.Monad.Except.Catch.ExceptCatchT e m)
module Control.Monad.Except.IO
-- | 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.
newtype ExceptIOT e m a
ExceptIOT :: m a -> ExceptIOT e m a
[unsafeRunExceptIOT] :: ExceptIOT e m a -> m a
-- | 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.
runExceptIOT :: (Exception e, MonadUnliftIO m) => ExceptIOT e m a -> m (Either e a)
-- | 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.)
class Monad m => MonadError e (m :: Type -> Type) | m -> e
-- | Is used within a monadic computation to begin exception processing.
throwError :: MonadError e m => e -> 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.
catchError :: MonadError e m => m a -> (e -> m a) -> m a
-- | Lifts an Either e into any MonadError
-- e.
--
--
-- do { val <- liftEither =<< action1; action2 }
--
--
-- where action1 returns an Either to represent errors.
liftEither :: MonadError e m => Either e a -> m a
-- | MonadError analogue to the try function.
tryError :: MonadError e m => m a -> m (Either e 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.
withError :: MonadError e m => (e -> e) -> m a -> m a
-- | As handle is flipped catch, handleError is
-- flipped catchError.
handleError :: MonadError e m => (e -> m a) -> m a -> m a
-- | 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.
mapError :: (MonadError e m, MonadError e' n) => (m (Either e a) -> n (Either e' b)) -> m a -> n b
-- | Like modifyError, but it selects the ExceptIOT instance
-- for IO exceptions instead of the ExceptT instance with
-- an Either error.
modifyError :: (Exception e, MonadUnliftIO m, MonadError e' m) => (e -> e') -> ExceptIOT e m a -> m a
instance Control.Monad.Catch.MonadMask m => Control.Monad.Catch.MonadMask (Control.Monad.Except.IO.ExceptIOT e m)
instance Control.Monad.Catch.MonadCatch m => Control.Monad.Catch.MonadCatch (Control.Monad.Except.IO.ExceptIOT e m)
instance Control.Monad.Catch.MonadThrow m => Control.Monad.Catch.MonadThrow (Control.Monad.Except.IO.ExceptIOT e m)
instance Control.Monad.Fail.MonadFail m => Control.Monad.Fail.MonadFail (Control.Monad.Except.IO.ExceptIOT e m)
instance Control.Monad.Fix.MonadFix m => Control.Monad.Fix.MonadFix (Control.Monad.Except.IO.ExceptIOT e m)
instance Control.Monad.Writer.Class.MonadWriter w m => Control.Monad.Writer.Class.MonadWriter w (Control.Monad.Except.IO.ExceptIOT e m)
instance Control.Monad.State.Class.MonadState s m => Control.Monad.State.Class.MonadState s (Control.Monad.Except.IO.ExceptIOT e m)
instance Control.Monad.Reader.Class.MonadReader r m => Control.Monad.Reader.Class.MonadReader r (Control.Monad.Except.IO.ExceptIOT e m)
instance Control.Monad.IO.Unlift.MonadUnliftIO m => Control.Monad.IO.Unlift.MonadUnliftIO (Control.Monad.Except.IO.ExceptIOT e m)
instance GHC.Base.Monoid (m a) => GHC.Base.Monoid (Control.Monad.Except.IO.ExceptIOT e m a)
instance GHC.Base.Semigroup (m a) => GHC.Base.Semigroup (Control.Monad.Except.IO.ExceptIOT e m a)
instance GHC.Base.Alternative m => GHC.Base.Alternative (Control.Monad.Except.IO.ExceptIOT e m)
instance GHC.Base.MonadPlus m => GHC.Base.MonadPlus (Control.Monad.Except.IO.ExceptIOT e m)
instance Control.Monad.IO.Class.MonadIO m => Control.Monad.IO.Class.MonadIO (Control.Monad.Except.IO.ExceptIOT e m)
instance GHC.Base.Monad m => GHC.Base.Monad (Control.Monad.Except.IO.ExceptIOT e m)
instance GHC.Base.Applicative m => GHC.Base.Applicative (Control.Monad.Except.IO.ExceptIOT e m)
instance GHC.Base.Functor m => GHC.Base.Functor (Control.Monad.Except.IO.ExceptIOT e m)
instance (Control.Monad.IO.Unlift.MonadUnliftIO m, GHC.Exception.Type.Exception e) => Control.Monad.Error.Class.MonadError e (Control.Monad.Except.IO.ExceptIOT e m)