{-# LANGUAGE DerivingStrategies #-}
{-# LANGUAGE FlexibleInstances #-}
{-# LANGUAGE GeneralizedNewtypeDeriving #-}
{-# LANGUAGE MultiParamTypeClasses #-}

module Control.Monad.Except.Catch
    ( ExceptCatchT (..)
    , runExceptCatchT
    , module Control.Monad.Error.Class
    , modifyError
    ) where

import Control.Applicative
import Control.Monad
import Control.Monad.Catch
import Control.Monad.Error.Class hiding (modifyError)
import Control.Monad.Fix
import Control.Monad.IO.Unlift
import Control.Monad.Reader
import Control.Monad.State
import Control.Monad.Writer

-- | 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
newtype ExceptCatchT e m a = ExceptCatchT { forall e (m :: * -> *) a. ExceptCatchT e m a -> m a
unsafeRunExceptCatchT :: m a }
    deriving newtype
        ( (forall a b. (a -> b) -> ExceptCatchT e m a -> ExceptCatchT e m b)
-> (forall a b. a -> ExceptCatchT e m b -> ExceptCatchT e m a)
-> Functor (ExceptCatchT e m)
forall a b. a -> ExceptCatchT e m b -> ExceptCatchT e m a
forall a b. (a -> b) -> ExceptCatchT e m a -> ExceptCatchT e m b
forall e (m :: * -> *) a b.
Functor m =>
a -> ExceptCatchT e m b -> ExceptCatchT e m a
forall e (m :: * -> *) a b.
Functor m =>
(a -> b) -> ExceptCatchT e m a -> ExceptCatchT e m b
forall (f :: * -> *).
(forall a b. (a -> b) -> f a -> f b)
-> (forall a b. a -> f b -> f a) -> Functor f
$cfmap :: forall e (m :: * -> *) a b.
Functor m =>
(a -> b) -> ExceptCatchT e m a -> ExceptCatchT e m b
fmap :: forall a b. (a -> b) -> ExceptCatchT e m a -> ExceptCatchT e m b
$c<$ :: forall e (m :: * -> *) a b.
Functor m =>
a -> ExceptCatchT e m b -> ExceptCatchT e m a
<$ :: forall a b. a -> ExceptCatchT e m b -> ExceptCatchT e m a
Functor, Functor (ExceptCatchT e m)
Functor (ExceptCatchT e m) =>
(forall a. a -> ExceptCatchT e m a)
-> (forall a b.
    ExceptCatchT e m (a -> b)
    -> ExceptCatchT e m a -> ExceptCatchT e m b)
-> (forall a b c.
    (a -> b -> c)
    -> ExceptCatchT e m a -> ExceptCatchT e m b -> ExceptCatchT e m c)
-> (forall a b.
    ExceptCatchT e m a -> ExceptCatchT e m b -> ExceptCatchT e m b)
-> (forall a b.
    ExceptCatchT e m a -> ExceptCatchT e m b -> ExceptCatchT e m a)
-> Applicative (ExceptCatchT e m)
forall a. a -> ExceptCatchT e m a
forall a b.
ExceptCatchT e m a -> ExceptCatchT e m b -> ExceptCatchT e m a
forall a b.
ExceptCatchT e m a -> ExceptCatchT e m b -> ExceptCatchT e m b
forall a b.
ExceptCatchT e m (a -> b)
-> ExceptCatchT e m a -> ExceptCatchT e m b
forall a b c.
(a -> b -> c)
-> ExceptCatchT e m a -> ExceptCatchT e m b -> ExceptCatchT e m c
forall e (m :: * -> *). Applicative m => Functor (ExceptCatchT e m)
forall e (m :: * -> *) a. Applicative m => a -> ExceptCatchT e m a
forall e (m :: * -> *) a b.
Applicative m =>
ExceptCatchT e m a -> ExceptCatchT e m b -> ExceptCatchT e m a
forall e (m :: * -> *) a b.
Applicative m =>
ExceptCatchT e m a -> ExceptCatchT e m b -> ExceptCatchT e m b
forall e (m :: * -> *) a b.
Applicative m =>
ExceptCatchT e m (a -> b)
-> ExceptCatchT e m a -> ExceptCatchT e m b
forall e (m :: * -> *) a b c.
Applicative m =>
(a -> b -> c)
-> ExceptCatchT e m a -> ExceptCatchT e m b -> ExceptCatchT e m c
forall (f :: * -> *).
Functor f =>
(forall a. a -> f a)
-> (forall a b. f (a -> b) -> f a -> f b)
-> (forall a b c. (a -> b -> c) -> f a -> f b -> f c)
-> (forall a b. f a -> f b -> f b)
-> (forall a b. f a -> f b -> f a)
-> Applicative f
$cpure :: forall e (m :: * -> *) a. Applicative m => a -> ExceptCatchT e m a
pure :: forall a. a -> ExceptCatchT e m a
$c<*> :: forall e (m :: * -> *) a b.
Applicative m =>
ExceptCatchT e m (a -> b)
-> ExceptCatchT e m a -> ExceptCatchT e m b
<*> :: forall a b.
ExceptCatchT e m (a -> b)
-> ExceptCatchT e m a -> ExceptCatchT e m b
$cliftA2 :: forall e (m :: * -> *) a b c.
Applicative m =>
(a -> b -> c)
-> ExceptCatchT e m a -> ExceptCatchT e m b -> ExceptCatchT e m c
liftA2 :: forall a b c.
(a -> b -> c)
-> ExceptCatchT e m a -> ExceptCatchT e m b -> ExceptCatchT e m c
$c*> :: forall e (m :: * -> *) a b.
Applicative m =>
ExceptCatchT e m a -> ExceptCatchT e m b -> ExceptCatchT e m b
*> :: forall a b.
ExceptCatchT e m a -> ExceptCatchT e m b -> ExceptCatchT e m b
$c<* :: forall e (m :: * -> *) a b.
Applicative m =>
ExceptCatchT e m a -> ExceptCatchT e m b -> ExceptCatchT e m a
<* :: forall a b.
ExceptCatchT e m a -> ExceptCatchT e m b -> ExceptCatchT e m a
Applicative, Applicative (ExceptCatchT e m)
Applicative (ExceptCatchT e m) =>
(forall a b.
 ExceptCatchT e m a
 -> (a -> ExceptCatchT e m b) -> ExceptCatchT e m b)
-> (forall a b.
    ExceptCatchT e m a -> ExceptCatchT e m b -> ExceptCatchT e m b)
-> (forall a. a -> ExceptCatchT e m a)
-> Monad (ExceptCatchT e m)
forall a. a -> ExceptCatchT e m a
forall a b.
ExceptCatchT e m a -> ExceptCatchT e m b -> ExceptCatchT e m b
forall a b.
ExceptCatchT e m a
-> (a -> ExceptCatchT e m b) -> ExceptCatchT e m b
forall e (m :: * -> *). Monad m => Applicative (ExceptCatchT e m)
forall e (m :: * -> *) a. Monad m => a -> ExceptCatchT e m a
forall e (m :: * -> *) a b.
Monad m =>
ExceptCatchT e m a -> ExceptCatchT e m b -> ExceptCatchT e m b
forall e (m :: * -> *) a b.
Monad m =>
ExceptCatchT e m a
-> (a -> ExceptCatchT e m b) -> ExceptCatchT e m b
forall (m :: * -> *).
Applicative m =>
(forall a b. m a -> (a -> m b) -> m b)
-> (forall a b. m a -> m b -> m b)
-> (forall a. a -> m a)
-> Monad m
$c>>= :: forall e (m :: * -> *) a b.
Monad m =>
ExceptCatchT e m a
-> (a -> ExceptCatchT e m b) -> ExceptCatchT e m b
>>= :: forall a b.
ExceptCatchT e m a
-> (a -> ExceptCatchT e m b) -> ExceptCatchT e m b
$c>> :: forall e (m :: * -> *) a b.
Monad m =>
ExceptCatchT e m a -> ExceptCatchT e m b -> ExceptCatchT e m b
>> :: forall a b.
ExceptCatchT e m a -> ExceptCatchT e m b -> ExceptCatchT e m b
$creturn :: forall e (m :: * -> *) a. Monad m => a -> ExceptCatchT e m a
return :: forall a. a -> ExceptCatchT e m a
Monad, Monad (ExceptCatchT e m)
Monad (ExceptCatchT e m) =>
(forall a. IO a -> ExceptCatchT e m a)
-> MonadIO (ExceptCatchT e m)
forall a. IO a -> ExceptCatchT e m a
forall e (m :: * -> *). MonadIO m => Monad (ExceptCatchT e m)
forall e (m :: * -> *) a. MonadIO m => IO a -> ExceptCatchT e m a
forall (m :: * -> *).
Monad m =>
(forall a. IO a -> m a) -> MonadIO m
$cliftIO :: forall e (m :: * -> *) a. MonadIO m => IO a -> ExceptCatchT e m a
liftIO :: forall a. IO a -> ExceptCatchT e m a
MonadIO, Monad (ExceptCatchT e m)
Alternative (ExceptCatchT e m)
(Alternative (ExceptCatchT e m), Monad (ExceptCatchT e m)) =>
(forall a. ExceptCatchT e m a)
-> (forall a.
    ExceptCatchT e m a -> ExceptCatchT e m a -> ExceptCatchT e m a)
-> MonadPlus (ExceptCatchT e m)
forall a. ExceptCatchT e m a
forall a.
ExceptCatchT e m a -> ExceptCatchT e m a -> ExceptCatchT e m a
forall e (m :: * -> *). MonadPlus m => Monad (ExceptCatchT e m)
forall e (m :: * -> *).
MonadPlus m =>
Alternative (ExceptCatchT e m)
forall e (m :: * -> *) a. MonadPlus m => ExceptCatchT e m a
forall e (m :: * -> *) a.
MonadPlus m =>
ExceptCatchT e m a -> ExceptCatchT e m a -> ExceptCatchT e m a
forall (m :: * -> *).
(Alternative m, Monad m) =>
(forall a. m a) -> (forall a. m a -> m a -> m a) -> MonadPlus m
$cmzero :: forall e (m :: * -> *) a. MonadPlus m => ExceptCatchT e m a
mzero :: forall a. ExceptCatchT e m a
$cmplus :: forall e (m :: * -> *) a.
MonadPlus m =>
ExceptCatchT e m a -> ExceptCatchT e m a -> ExceptCatchT e m a
mplus :: forall a.
ExceptCatchT e m a -> ExceptCatchT e m a -> ExceptCatchT e m a
MonadPlus, Applicative (ExceptCatchT e m)
Applicative (ExceptCatchT e m) =>
(forall a. ExceptCatchT e m a)
-> (forall a.
    ExceptCatchT e m a -> ExceptCatchT e m a -> ExceptCatchT e m a)
-> (forall a. ExceptCatchT e m a -> ExceptCatchT e m [a])
-> (forall a. ExceptCatchT e m a -> ExceptCatchT e m [a])
-> Alternative (ExceptCatchT e m)
forall a. ExceptCatchT e m a
forall a. ExceptCatchT e m a -> ExceptCatchT e m [a]
forall a.
ExceptCatchT e m a -> ExceptCatchT e m a -> ExceptCatchT e m a
forall e (m :: * -> *).
Alternative m =>
Applicative (ExceptCatchT e m)
forall e (m :: * -> *) a. Alternative m => ExceptCatchT e m a
forall e (m :: * -> *) a.
Alternative m =>
ExceptCatchT e m a -> ExceptCatchT e m [a]
forall e (m :: * -> *) a.
Alternative m =>
ExceptCatchT e m a -> ExceptCatchT e m a -> ExceptCatchT e m a
forall (f :: * -> *).
Applicative f =>
(forall a. f a)
-> (forall a. f a -> f a -> f a)
-> (forall a. f a -> f [a])
-> (forall a. f a -> f [a])
-> Alternative f
$cempty :: forall e (m :: * -> *) a. Alternative m => ExceptCatchT e m a
empty :: forall a. ExceptCatchT e m a
$c<|> :: forall e (m :: * -> *) a.
Alternative m =>
ExceptCatchT e m a -> ExceptCatchT e m a -> ExceptCatchT e m a
<|> :: forall a.
ExceptCatchT e m a -> ExceptCatchT e m a -> ExceptCatchT e m a
$csome :: forall e (m :: * -> *) a.
Alternative m =>
ExceptCatchT e m a -> ExceptCatchT e m [a]
some :: forall a. ExceptCatchT e m a -> ExceptCatchT e m [a]
$cmany :: forall e (m :: * -> *) a.
Alternative m =>
ExceptCatchT e m a -> ExceptCatchT e m [a]
many :: forall a. ExceptCatchT e m a -> ExceptCatchT e m [a]
Alternative
        , NonEmpty (ExceptCatchT e m a) -> ExceptCatchT e m a
ExceptCatchT e m a -> ExceptCatchT e m a -> ExceptCatchT e m a
(ExceptCatchT e m a -> ExceptCatchT e m a -> ExceptCatchT e m a)
-> (NonEmpty (ExceptCatchT e m a) -> ExceptCatchT e m a)
-> (forall b.
    Integral b =>
    b -> ExceptCatchT e m a -> ExceptCatchT e m a)
-> Semigroup (ExceptCatchT e m a)
forall b.
Integral b =>
b -> ExceptCatchT e m a -> ExceptCatchT e m a
forall a.
(a -> a -> a)
-> (NonEmpty a -> a)
-> (forall b. Integral b => b -> a -> a)
-> Semigroup a
forall e (m :: * -> *) a.
Semigroup (m a) =>
NonEmpty (ExceptCatchT e m a) -> ExceptCatchT e m a
forall e (m :: * -> *) a.
Semigroup (m a) =>
ExceptCatchT e m a -> ExceptCatchT e m a -> ExceptCatchT e m a
forall e (m :: * -> *) a b.
(Semigroup (m a), Integral b) =>
b -> ExceptCatchT e m a -> ExceptCatchT e m a
$c<> :: forall e (m :: * -> *) a.
Semigroup (m a) =>
ExceptCatchT e m a -> ExceptCatchT e m a -> ExceptCatchT e m a
<> :: ExceptCatchT e m a -> ExceptCatchT e m a -> ExceptCatchT e m a
$csconcat :: forall e (m :: * -> *) a.
Semigroup (m a) =>
NonEmpty (ExceptCatchT e m a) -> ExceptCatchT e m a
sconcat :: NonEmpty (ExceptCatchT e m a) -> ExceptCatchT e m a
$cstimes :: forall e (m :: * -> *) a b.
(Semigroup (m a), Integral b) =>
b -> ExceptCatchT e m a -> ExceptCatchT e m a
stimes :: forall b.
Integral b =>
b -> ExceptCatchT e m a -> ExceptCatchT e m a
Semigroup, Semigroup (ExceptCatchT e m a)
ExceptCatchT e m a
Semigroup (ExceptCatchT e m a) =>
ExceptCatchT e m a
-> (ExceptCatchT e m a -> ExceptCatchT e m a -> ExceptCatchT e m a)
-> ([ExceptCatchT e m a] -> ExceptCatchT e m a)
-> Monoid (ExceptCatchT e m a)
[ExceptCatchT e m a] -> ExceptCatchT e m a
ExceptCatchT e m a -> ExceptCatchT e m a -> ExceptCatchT e m a
forall a.
Semigroup a =>
a -> (a -> a -> a) -> ([a] -> a) -> Monoid a
forall e (m :: * -> *) a.
Monoid (m a) =>
Semigroup (ExceptCatchT e m a)
forall e (m :: * -> *) a. Monoid (m a) => ExceptCatchT e m a
forall e (m :: * -> *) a.
Monoid (m a) =>
[ExceptCatchT e m a] -> ExceptCatchT e m a
forall e (m :: * -> *) a.
Monoid (m a) =>
ExceptCatchT e m a -> ExceptCatchT e m a -> ExceptCatchT e m a
$cmempty :: forall e (m :: * -> *) a. Monoid (m a) => ExceptCatchT e m a
mempty :: ExceptCatchT e m a
$cmappend :: forall e (m :: * -> *) a.
Monoid (m a) =>
ExceptCatchT e m a -> ExceptCatchT e m a -> ExceptCatchT e m a
mappend :: ExceptCatchT e m a -> ExceptCatchT e m a -> ExceptCatchT e m a
$cmconcat :: forall e (m :: * -> *) a.
Monoid (m a) =>
[ExceptCatchT e m a] -> ExceptCatchT e m a
mconcat :: [ExceptCatchT e m a] -> ExceptCatchT e m a
Monoid, MonadIO (ExceptCatchT e m)
MonadIO (ExceptCatchT e m) =>
(forall b.
 ((forall a. ExceptCatchT e m a -> IO a) -> IO b)
 -> ExceptCatchT e m b)
-> MonadUnliftIO (ExceptCatchT e m)
forall b.
((forall a. ExceptCatchT e m a -> IO a) -> IO b)
-> ExceptCatchT e m b
forall e (m :: * -> *).
MonadUnliftIO m =>
MonadIO (ExceptCatchT e m)
forall e (m :: * -> *) b.
MonadUnliftIO m =>
((forall a. ExceptCatchT e m a -> IO a) -> IO b)
-> ExceptCatchT e m b
forall (m :: * -> *).
MonadIO m =>
(forall b. ((forall a. m a -> IO a) -> IO b) -> m b)
-> MonadUnliftIO m
$cwithRunInIO :: forall e (m :: * -> *) b.
MonadUnliftIO m =>
((forall a. ExceptCatchT e m a -> IO a) -> IO b)
-> ExceptCatchT e m b
withRunInIO :: forall b.
((forall a. ExceptCatchT e m a -> IO a) -> IO b)
-> ExceptCatchT e m b
MonadUnliftIO, MonadReader r, MonadState s
        , MonadWriter w , Monad (ExceptCatchT e m)
Monad (ExceptCatchT e m) =>
(forall a. (a -> ExceptCatchT e m a) -> ExceptCatchT e m a)
-> MonadFix (ExceptCatchT e m)
forall a. (a -> ExceptCatchT e m a) -> ExceptCatchT e m a
forall e (m :: * -> *). MonadFix m => Monad (ExceptCatchT e m)
forall e (m :: * -> *) a.
MonadFix m =>
(a -> ExceptCatchT e m a) -> ExceptCatchT e m a
forall (m :: * -> *).
Monad m =>
(forall a. (a -> m a) -> m a) -> MonadFix m
$cmfix :: forall e (m :: * -> *) a.
MonadFix m =>
(a -> ExceptCatchT e m a) -> ExceptCatchT e m a
mfix :: forall a. (a -> ExceptCatchT e m a) -> ExceptCatchT e m a
MonadFix, Monad (ExceptCatchT e m)
Monad (ExceptCatchT e m) =>
(forall a. String -> ExceptCatchT e m a)
-> MonadFail (ExceptCatchT e m)
forall a. String -> ExceptCatchT e m a
forall e (m :: * -> *). MonadFail m => Monad (ExceptCatchT e m)
forall e (m :: * -> *) a.
MonadFail m =>
String -> ExceptCatchT e m a
forall (m :: * -> *).
Monad m =>
(forall a. String -> m a) -> MonadFail m
$cfail :: forall e (m :: * -> *) a.
MonadFail m =>
String -> ExceptCatchT e m a
fail :: forall a. String -> ExceptCatchT e m a
MonadFail, Monad (ExceptCatchT e m)
Monad (ExceptCatchT e m) =>
(forall e a.
 (HasCallStack, Exception e) =>
 e -> ExceptCatchT e m a)
-> MonadThrow (ExceptCatchT e m)
forall e a. (HasCallStack, Exception e) => e -> ExceptCatchT e m a
forall e (m :: * -> *). MonadThrow m => Monad (ExceptCatchT e m)
forall e (m :: * -> *) e a.
(MonadThrow m, HasCallStack, Exception e) =>
e -> ExceptCatchT e m a
forall (m :: * -> *).
Monad m =>
(forall e a. (HasCallStack, Exception e) => e -> m a)
-> MonadThrow m
$cthrowM :: forall e (m :: * -> *) e a.
(MonadThrow m, HasCallStack, Exception e) =>
e -> ExceptCatchT e m a
throwM :: forall e a. (HasCallStack, Exception e) => e -> ExceptCatchT e m a
MonadThrow, MonadThrow (ExceptCatchT e m)
MonadThrow (ExceptCatchT e m) =>
(forall e a.
 (HasCallStack, Exception e) =>
 ExceptCatchT e m a
 -> (e -> ExceptCatchT e m a) -> ExceptCatchT e m a)
-> MonadCatch (ExceptCatchT e m)
forall e a.
(HasCallStack, Exception e) =>
ExceptCatchT e m a
-> (e -> ExceptCatchT e m a) -> ExceptCatchT e m a
forall e (m :: * -> *).
MonadCatch m =>
MonadThrow (ExceptCatchT e m)
forall e (m :: * -> *) e a.
(MonadCatch m, HasCallStack, Exception e) =>
ExceptCatchT e m a
-> (e -> ExceptCatchT e m a) -> ExceptCatchT e m a
forall (m :: * -> *).
MonadThrow m =>
(forall e a.
 (HasCallStack, Exception e) =>
 m a -> (e -> m a) -> m a)
-> MonadCatch m
$ccatch :: forall e (m :: * -> *) e a.
(MonadCatch m, HasCallStack, Exception e) =>
ExceptCatchT e m a
-> (e -> ExceptCatchT e m a) -> ExceptCatchT e m a
catch :: forall e a.
(HasCallStack, Exception e) =>
ExceptCatchT e m a
-> (e -> ExceptCatchT e m a) -> ExceptCatchT e m a
MonadCatch, MonadCatch (ExceptCatchT e m)
MonadCatch (ExceptCatchT e m) =>
(forall b.
 HasCallStack =>
 ((forall a. ExceptCatchT e m a -> ExceptCatchT e m a)
  -> ExceptCatchT e m b)
 -> ExceptCatchT e m b)
-> (forall b.
    HasCallStack =>
    ((forall a. ExceptCatchT e m a -> ExceptCatchT e m a)
     -> ExceptCatchT e m b)
    -> ExceptCatchT e m b)
-> (forall a b c.
    HasCallStack =>
    ExceptCatchT e m a
    -> (a -> ExitCase b -> ExceptCatchT e m c)
    -> (a -> ExceptCatchT e m b)
    -> ExceptCatchT e m (b, c))
-> MonadMask (ExceptCatchT e m)
forall b.
HasCallStack =>
((forall a. ExceptCatchT e m a -> ExceptCatchT e m a)
 -> ExceptCatchT e m b)
-> ExceptCatchT e m b
forall a b c.
HasCallStack =>
ExceptCatchT e m a
-> (a -> ExitCase b -> ExceptCatchT e m c)
-> (a -> ExceptCatchT e m b)
-> ExceptCatchT e m (b, c)
forall e (m :: * -> *).
MonadMask m =>
MonadCatch (ExceptCatchT e m)
forall e (m :: * -> *) b.
(MonadMask m, HasCallStack) =>
((forall a. ExceptCatchT e m a -> ExceptCatchT e m a)
 -> ExceptCatchT e m b)
-> ExceptCatchT e m b
forall e (m :: * -> *) a b c.
(MonadMask m, HasCallStack) =>
ExceptCatchT e m a
-> (a -> ExitCase b -> ExceptCatchT e m c)
-> (a -> ExceptCatchT e m b)
-> ExceptCatchT e m (b, c)
forall (m :: * -> *).
MonadCatch m =>
(forall b. HasCallStack => ((forall a. m a -> m a) -> m b) -> m b)
-> (forall b.
    HasCallStack =>
    ((forall a. m a -> m a) -> m b) -> m b)
-> (forall a b c.
    HasCallStack =>
    m a -> (a -> ExitCase b -> m c) -> (a -> m b) -> m (b, c))
-> MonadMask m
$cmask :: forall e (m :: * -> *) b.
(MonadMask m, HasCallStack) =>
((forall a. ExceptCatchT e m a -> ExceptCatchT e m a)
 -> ExceptCatchT e m b)
-> ExceptCatchT e m b
mask :: forall b.
HasCallStack =>
((forall a. ExceptCatchT e m a -> ExceptCatchT e m a)
 -> ExceptCatchT e m b)
-> ExceptCatchT e m b
$cuninterruptibleMask :: forall e (m :: * -> *) b.
(MonadMask m, HasCallStack) =>
((forall a. ExceptCatchT e m a -> ExceptCatchT e m a)
 -> ExceptCatchT e m b)
-> ExceptCatchT e m b
uninterruptibleMask :: forall b.
HasCallStack =>
((forall a. ExceptCatchT e m a -> ExceptCatchT e m a)
 -> ExceptCatchT e m b)
-> ExceptCatchT e m b
$cgeneralBracket :: forall e (m :: * -> *) a b c.
(MonadMask m, HasCallStack) =>
ExceptCatchT e m a
-> (a -> ExitCase b -> ExceptCatchT e m c)
-> (a -> ExceptCatchT e m b)
-> ExceptCatchT e m (b, c)
generalBracket :: forall a b c.
HasCallStack =>
ExceptCatchT e m a
-> (a -> ExitCase b -> ExceptCatchT e m c)
-> (a -> ExceptCatchT e m b)
-> ExceptCatchT e m (b, c)
MonadMask
        )

-- |
--
-- @since 0.1.0.0
instance (MonadCatch m, Exception e) => MonadError e (ExceptCatchT e m) where
    throwError :: forall a. e -> ExceptCatchT e m a
throwError = e -> ExceptCatchT e m a
forall e a. (HasCallStack, Exception e) => e -> ExceptCatchT e m a
forall (m :: * -> *) e a.
(MonadThrow m, HasCallStack, Exception e) =>
e -> m a
throwM
    catchError :: forall a.
ExceptCatchT e m a
-> (e -> ExceptCatchT e m a) -> ExceptCatchT e m a
catchError = ExceptCatchT e m a
-> (e -> ExceptCatchT e m a) -> ExceptCatchT e m a
forall e a.
(HasCallStack, Exception e) =>
ExceptCatchT e m a
-> (e -> ExceptCatchT e m a) -> ExceptCatchT e m a
forall (m :: * -> *) e a.
(MonadCatch m, HasCallStack, Exception e) =>
m a -> (e -> m a) -> m a
catch

-- | 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
runExceptCatchT :: (Exception e, MonadCatch m) => ExceptCatchT e m a -> m (Either e a)
runExceptCatchT :: forall e (m :: * -> *) a.
(Exception e, MonadCatch m) =>
ExceptCatchT e m a -> m (Either e a)
runExceptCatchT = m a -> m (Either e a)
forall (m :: * -> *) e a.
(HasCallStack, MonadCatch m, Exception e) =>
m a -> m (Either e a)
try (m a -> m (Either e a))
-> (ExceptCatchT e m a -> m a)
-> ExceptCatchT e m a
-> m (Either e a)
forall b c a. (b -> c) -> (a -> b) -> a -> c
. ExceptCatchT e m a -> m a
forall e (m :: * -> *) a. ExceptCatchT e m a -> m a
unsafeRunExceptCatchT

-- | Like 'Control.Monad.Except.modifyError', but it selects the 'ExceptCatchT' instance for 'IO'
-- exceptions instead of the 'ExceptT' instance with an 'Either' error.
--
-- @since 0.1.0.0
modifyError
    :: (Exception e, MonadCatch m, MonadError e' m)
    => (e -> e') -> ExceptCatchT e m a -> m a
modifyError :: forall e (m :: * -> *) e' a.
(Exception e, MonadCatch m, MonadError e' m) =>
(e -> e') -> ExceptCatchT e m a -> m a
modifyError e -> e'
f ExceptCatchT e m a
action =
    ExceptCatchT e m a -> m (Either e a)
forall e (m :: * -> *) a.
(Exception e, MonadCatch m) =>
ExceptCatchT e m a -> m (Either e a)
runExceptCatchT ExceptCatchT e m a
action m (Either e a) -> (Either e a -> m a) -> m a
forall a b. m a -> (a -> m b) -> m b
forall (m :: * -> *) a b. Monad m => m a -> (a -> m b) -> m b
>>= (e -> m a) -> (a -> m a) -> Either e a -> m a
forall a c b. (a -> c) -> (b -> c) -> Either a b -> c
either (e' -> m a
forall a. e' -> m a
forall e (m :: * -> *) a. MonadError e m => e -> m a
throwError (e' -> m a) -> (e -> e') -> e -> m a
forall b c a. (b -> c) -> (a -> b) -> a -> c
. e -> e'
f) a -> m a
forall a. a -> m a
forall (f :: * -> *) a. Applicative f => a -> f a
pure