{-# LANGUAGE DerivingVia #-}
module Control.Effect.Exceptional
(
Exceptional
, SafeError
, catching
, trying
, throwing
, catchSafe
, trySafe
, runExceptional
, runExceptionalJust
, safeErrorToError
, runSafeError
, safeErrorToIO
, safeErrorToErrorIO
, runExceptionalJustSimple
, safeErrorToIOSimple
, safeErrorToErrorIOSimple
, ErrorThreads
, MonadCatch
, ExceptionallyC
, ExceptionalC
, SafeErrorToErrorC
, SafeErrorC
, SafeErrorToIOC'
, SafeErrorToIOC
, SafeErrorToErrorIOC'
, SafeErrorToErrorIOC
, SafeErrorToIOSimpleC
, SafeErrorToErrorIOSimpleC
) where
import Data.Coerce
import Data.Either
import Control.Effect
import Control.Effect.Error
import Control.Effect.ErrorIO
import Control.Effect.Union
import Control.Effect.Carrier
import Control.Effect.Internal.Utils
import Control.Monad.Trans.Identity
import Control.Monad.Trans.Except
import Control.Effect.Internal.Error
import Control.Effect.Carrier.Internal.Interpret
import Control.Effect.Carrier.Internal.Intro
import Control.Effect.Carrier.Internal.Compose
newtype Exceptional eff exc m a = Exceptional (Union '[eff, Catch exc] m a)
type SafeError exc = Exceptional (Throw exc) exc
newtype ExceptionallyC (eff :: Effect) (exc :: *) m a = ExceptionallyC {
ExceptionallyC eff exc m a -> m a
unExceptionallyC :: m a
}
deriving ( a -> ExceptionallyC eff exc m b -> ExceptionallyC eff exc m a
(a -> b)
-> ExceptionallyC eff exc m a -> ExceptionallyC eff exc m b
(forall a b.
(a -> b)
-> ExceptionallyC eff exc m a -> ExceptionallyC eff exc m b)
-> (forall a b.
a -> ExceptionallyC eff exc m b -> ExceptionallyC eff exc m a)
-> Functor (ExceptionallyC eff exc m)
forall a b.
a -> ExceptionallyC eff exc m b -> ExceptionallyC eff exc m a
forall a b.
(a -> b)
-> ExceptionallyC eff exc m a -> ExceptionallyC eff exc m b
forall (f :: * -> *).
(forall a b. (a -> b) -> f a -> f b)
-> (forall a b. a -> f b -> f a) -> Functor f
forall (eff :: Effect) exc (m :: * -> *) a b.
Functor m =>
a -> ExceptionallyC eff exc m b -> ExceptionallyC eff exc m a
forall (eff :: Effect) exc (m :: * -> *) a b.
Functor m =>
(a -> b)
-> ExceptionallyC eff exc m a -> ExceptionallyC eff exc m b
<$ :: a -> ExceptionallyC eff exc m b -> ExceptionallyC eff exc m a
$c<$ :: forall (eff :: Effect) exc (m :: * -> *) a b.
Functor m =>
a -> ExceptionallyC eff exc m b -> ExceptionallyC eff exc m a
fmap :: (a -> b)
-> ExceptionallyC eff exc m a -> ExceptionallyC eff exc m b
$cfmap :: forall (eff :: Effect) exc (m :: * -> *) a b.
Functor m =>
(a -> b)
-> ExceptionallyC eff exc m a -> ExceptionallyC eff exc m b
Functor, Functor (ExceptionallyC eff exc m)
a -> ExceptionallyC eff exc m a
Functor (ExceptionallyC eff exc m)
-> (forall a. a -> ExceptionallyC eff exc m a)
-> (forall a b.
ExceptionallyC eff exc m (a -> b)
-> ExceptionallyC eff exc m a -> ExceptionallyC eff exc m b)
-> (forall a b c.
(a -> b -> c)
-> ExceptionallyC eff exc m a
-> ExceptionallyC eff exc m b
-> ExceptionallyC eff exc m c)
-> (forall a b.
ExceptionallyC eff exc m a
-> ExceptionallyC eff exc m b -> ExceptionallyC eff exc m b)
-> (forall a b.
ExceptionallyC eff exc m a
-> ExceptionallyC eff exc m b -> ExceptionallyC eff exc m a)
-> Applicative (ExceptionallyC eff exc m)
ExceptionallyC eff exc m a
-> ExceptionallyC eff exc m b -> ExceptionallyC eff exc m b
ExceptionallyC eff exc m a
-> ExceptionallyC eff exc m b -> ExceptionallyC eff exc m a
ExceptionallyC eff exc m (a -> b)
-> ExceptionallyC eff exc m a -> ExceptionallyC eff exc m b
(a -> b -> c)
-> ExceptionallyC eff exc m a
-> ExceptionallyC eff exc m b
-> ExceptionallyC eff exc m c
forall a. a -> ExceptionallyC eff exc m a
forall a b.
ExceptionallyC eff exc m a
-> ExceptionallyC eff exc m b -> ExceptionallyC eff exc m a
forall a b.
ExceptionallyC eff exc m a
-> ExceptionallyC eff exc m b -> ExceptionallyC eff exc m b
forall a b.
ExceptionallyC eff exc m (a -> b)
-> ExceptionallyC eff exc m a -> ExceptionallyC eff exc m b
forall a b c.
(a -> b -> c)
-> ExceptionallyC eff exc m a
-> ExceptionallyC eff exc m b
-> ExceptionallyC eff exc 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
forall (eff :: Effect) exc (m :: * -> *).
Applicative m =>
Functor (ExceptionallyC eff exc m)
forall (eff :: Effect) exc (m :: * -> *) a.
Applicative m =>
a -> ExceptionallyC eff exc m a
forall (eff :: Effect) exc (m :: * -> *) a b.
Applicative m =>
ExceptionallyC eff exc m a
-> ExceptionallyC eff exc m b -> ExceptionallyC eff exc m a
forall (eff :: Effect) exc (m :: * -> *) a b.
Applicative m =>
ExceptionallyC eff exc m a
-> ExceptionallyC eff exc m b -> ExceptionallyC eff exc m b
forall (eff :: Effect) exc (m :: * -> *) a b.
Applicative m =>
ExceptionallyC eff exc m (a -> b)
-> ExceptionallyC eff exc m a -> ExceptionallyC eff exc m b
forall (eff :: Effect) exc (m :: * -> *) a b c.
Applicative m =>
(a -> b -> c)
-> ExceptionallyC eff exc m a
-> ExceptionallyC eff exc m b
-> ExceptionallyC eff exc m c
<* :: ExceptionallyC eff exc m a
-> ExceptionallyC eff exc m b -> ExceptionallyC eff exc m a
$c<* :: forall (eff :: Effect) exc (m :: * -> *) a b.
Applicative m =>
ExceptionallyC eff exc m a
-> ExceptionallyC eff exc m b -> ExceptionallyC eff exc m a
*> :: ExceptionallyC eff exc m a
-> ExceptionallyC eff exc m b -> ExceptionallyC eff exc m b
$c*> :: forall (eff :: Effect) exc (m :: * -> *) a b.
Applicative m =>
ExceptionallyC eff exc m a
-> ExceptionallyC eff exc m b -> ExceptionallyC eff exc m b
liftA2 :: (a -> b -> c)
-> ExceptionallyC eff exc m a
-> ExceptionallyC eff exc m b
-> ExceptionallyC eff exc m c
$cliftA2 :: forall (eff :: Effect) exc (m :: * -> *) a b c.
Applicative m =>
(a -> b -> c)
-> ExceptionallyC eff exc m a
-> ExceptionallyC eff exc m b
-> ExceptionallyC eff exc m c
<*> :: ExceptionallyC eff exc m (a -> b)
-> ExceptionallyC eff exc m a -> ExceptionallyC eff exc m b
$c<*> :: forall (eff :: Effect) exc (m :: * -> *) a b.
Applicative m =>
ExceptionallyC eff exc m (a -> b)
-> ExceptionallyC eff exc m a -> ExceptionallyC eff exc m b
pure :: a -> ExceptionallyC eff exc m a
$cpure :: forall (eff :: Effect) exc (m :: * -> *) a.
Applicative m =>
a -> ExceptionallyC eff exc m a
$cp1Applicative :: forall (eff :: Effect) exc (m :: * -> *).
Applicative m =>
Functor (ExceptionallyC eff exc m)
Applicative, Applicative (ExceptionallyC eff exc m)
a -> ExceptionallyC eff exc m a
Applicative (ExceptionallyC eff exc m)
-> (forall a b.
ExceptionallyC eff exc m a
-> (a -> ExceptionallyC eff exc m b) -> ExceptionallyC eff exc m b)
-> (forall a b.
ExceptionallyC eff exc m a
-> ExceptionallyC eff exc m b -> ExceptionallyC eff exc m b)
-> (forall a. a -> ExceptionallyC eff exc m a)
-> Monad (ExceptionallyC eff exc m)
ExceptionallyC eff exc m a
-> (a -> ExceptionallyC eff exc m b) -> ExceptionallyC eff exc m b
ExceptionallyC eff exc m a
-> ExceptionallyC eff exc m b -> ExceptionallyC eff exc m b
forall a. a -> ExceptionallyC eff exc m a
forall a b.
ExceptionallyC eff exc m a
-> ExceptionallyC eff exc m b -> ExceptionallyC eff exc m b
forall a b.
ExceptionallyC eff exc m a
-> (a -> ExceptionallyC eff exc m b) -> ExceptionallyC eff exc 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
forall (eff :: Effect) exc (m :: * -> *).
Monad m =>
Applicative (ExceptionallyC eff exc m)
forall (eff :: Effect) exc (m :: * -> *) a.
Monad m =>
a -> ExceptionallyC eff exc m a
forall (eff :: Effect) exc (m :: * -> *) a b.
Monad m =>
ExceptionallyC eff exc m a
-> ExceptionallyC eff exc m b -> ExceptionallyC eff exc m b
forall (eff :: Effect) exc (m :: * -> *) a b.
Monad m =>
ExceptionallyC eff exc m a
-> (a -> ExceptionallyC eff exc m b) -> ExceptionallyC eff exc m b
return :: a -> ExceptionallyC eff exc m a
$creturn :: forall (eff :: Effect) exc (m :: * -> *) a.
Monad m =>
a -> ExceptionallyC eff exc m a
>> :: ExceptionallyC eff exc m a
-> ExceptionallyC eff exc m b -> ExceptionallyC eff exc m b
$c>> :: forall (eff :: Effect) exc (m :: * -> *) a b.
Monad m =>
ExceptionallyC eff exc m a
-> ExceptionallyC eff exc m b -> ExceptionallyC eff exc m b
>>= :: ExceptionallyC eff exc m a
-> (a -> ExceptionallyC eff exc m b) -> ExceptionallyC eff exc m b
$c>>= :: forall (eff :: Effect) exc (m :: * -> *) a b.
Monad m =>
ExceptionallyC eff exc m a
-> (a -> ExceptionallyC eff exc m b) -> ExceptionallyC eff exc m b
$cp1Monad :: forall (eff :: Effect) exc (m :: * -> *).
Monad m =>
Applicative (ExceptionallyC eff exc m)
Monad
, Applicative (ExceptionallyC eff exc m)
ExceptionallyC eff exc m a
Applicative (ExceptionallyC eff exc m)
-> (forall a. ExceptionallyC eff exc m a)
-> (forall a.
ExceptionallyC eff exc m a
-> ExceptionallyC eff exc m a -> ExceptionallyC eff exc m a)
-> (forall a.
ExceptionallyC eff exc m a -> ExceptionallyC eff exc m [a])
-> (forall a.
ExceptionallyC eff exc m a -> ExceptionallyC eff exc m [a])
-> Alternative (ExceptionallyC eff exc m)
ExceptionallyC eff exc m a
-> ExceptionallyC eff exc m a -> ExceptionallyC eff exc m a
ExceptionallyC eff exc m a -> ExceptionallyC eff exc m [a]
ExceptionallyC eff exc m a -> ExceptionallyC eff exc m [a]
forall a. ExceptionallyC eff exc m a
forall a.
ExceptionallyC eff exc m a -> ExceptionallyC eff exc m [a]
forall a.
ExceptionallyC eff exc m a
-> ExceptionallyC eff exc m a -> ExceptionallyC eff exc 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
forall (eff :: Effect) exc (m :: * -> *).
Alternative m =>
Applicative (ExceptionallyC eff exc m)
forall (eff :: Effect) exc (m :: * -> *) a.
Alternative m =>
ExceptionallyC eff exc m a
forall (eff :: Effect) exc (m :: * -> *) a.
Alternative m =>
ExceptionallyC eff exc m a -> ExceptionallyC eff exc m [a]
forall (eff :: Effect) exc (m :: * -> *) a.
Alternative m =>
ExceptionallyC eff exc m a
-> ExceptionallyC eff exc m a -> ExceptionallyC eff exc m a
many :: ExceptionallyC eff exc m a -> ExceptionallyC eff exc m [a]
$cmany :: forall (eff :: Effect) exc (m :: * -> *) a.
Alternative m =>
ExceptionallyC eff exc m a -> ExceptionallyC eff exc m [a]
some :: ExceptionallyC eff exc m a -> ExceptionallyC eff exc m [a]
$csome :: forall (eff :: Effect) exc (m :: * -> *) a.
Alternative m =>
ExceptionallyC eff exc m a -> ExceptionallyC eff exc m [a]
<|> :: ExceptionallyC eff exc m a
-> ExceptionallyC eff exc m a -> ExceptionallyC eff exc m a
$c<|> :: forall (eff :: Effect) exc (m :: * -> *) a.
Alternative m =>
ExceptionallyC eff exc m a
-> ExceptionallyC eff exc m a -> ExceptionallyC eff exc m a
empty :: ExceptionallyC eff exc m a
$cempty :: forall (eff :: Effect) exc (m :: * -> *) a.
Alternative m =>
ExceptionallyC eff exc m a
$cp1Alternative :: forall (eff :: Effect) exc (m :: * -> *).
Alternative m =>
Applicative (ExceptionallyC eff exc m)
Alternative, Monad (ExceptionallyC eff exc m)
Alternative (ExceptionallyC eff exc m)
ExceptionallyC eff exc m a
Alternative (ExceptionallyC eff exc m)
-> Monad (ExceptionallyC eff exc m)
-> (forall a. ExceptionallyC eff exc m a)
-> (forall a.
ExceptionallyC eff exc m a
-> ExceptionallyC eff exc m a -> ExceptionallyC eff exc m a)
-> MonadPlus (ExceptionallyC eff exc m)
ExceptionallyC eff exc m a
-> ExceptionallyC eff exc m a -> ExceptionallyC eff exc m a
forall a. ExceptionallyC eff exc m a
forall a.
ExceptionallyC eff exc m a
-> ExceptionallyC eff exc m a -> ExceptionallyC eff exc m a
forall (m :: * -> *).
Alternative m
-> Monad m
-> (forall a. m a)
-> (forall a. m a -> m a -> m a)
-> MonadPlus m
forall (eff :: Effect) exc (m :: * -> *).
MonadPlus m =>
Monad (ExceptionallyC eff exc m)
forall (eff :: Effect) exc (m :: * -> *).
MonadPlus m =>
Alternative (ExceptionallyC eff exc m)
forall (eff :: Effect) exc (m :: * -> *) a.
MonadPlus m =>
ExceptionallyC eff exc m a
forall (eff :: Effect) exc (m :: * -> *) a.
MonadPlus m =>
ExceptionallyC eff exc m a
-> ExceptionallyC eff exc m a -> ExceptionallyC eff exc m a
mplus :: ExceptionallyC eff exc m a
-> ExceptionallyC eff exc m a -> ExceptionallyC eff exc m a
$cmplus :: forall (eff :: Effect) exc (m :: * -> *) a.
MonadPlus m =>
ExceptionallyC eff exc m a
-> ExceptionallyC eff exc m a -> ExceptionallyC eff exc m a
mzero :: ExceptionallyC eff exc m a
$cmzero :: forall (eff :: Effect) exc (m :: * -> *) a.
MonadPlus m =>
ExceptionallyC eff exc m a
$cp2MonadPlus :: forall (eff :: Effect) exc (m :: * -> *).
MonadPlus m =>
Monad (ExceptionallyC eff exc m)
$cp1MonadPlus :: forall (eff :: Effect) exc (m :: * -> *).
MonadPlus m =>
Alternative (ExceptionallyC eff exc m)
MonadPlus
, Monad (ExceptionallyC eff exc m)
Monad (ExceptionallyC eff exc m)
-> (forall a.
(a -> ExceptionallyC eff exc m a) -> ExceptionallyC eff exc m a)
-> MonadFix (ExceptionallyC eff exc m)
(a -> ExceptionallyC eff exc m a) -> ExceptionallyC eff exc m a
forall a.
(a -> ExceptionallyC eff exc m a) -> ExceptionallyC eff exc m a
forall (m :: * -> *).
Monad m -> (forall a. (a -> m a) -> m a) -> MonadFix m
forall (eff :: Effect) exc (m :: * -> *).
MonadFix m =>
Monad (ExceptionallyC eff exc m)
forall (eff :: Effect) exc (m :: * -> *) a.
MonadFix m =>
(a -> ExceptionallyC eff exc m a) -> ExceptionallyC eff exc m a
mfix :: (a -> ExceptionallyC eff exc m a) -> ExceptionallyC eff exc m a
$cmfix :: forall (eff :: Effect) exc (m :: * -> *) a.
MonadFix m =>
(a -> ExceptionallyC eff exc m a) -> ExceptionallyC eff exc m a
$cp1MonadFix :: forall (eff :: Effect) exc (m :: * -> *).
MonadFix m =>
Monad (ExceptionallyC eff exc m)
MonadFix, Monad (ExceptionallyC eff exc m)
Monad (ExceptionallyC eff exc m)
-> (forall a. String -> ExceptionallyC eff exc m a)
-> MonadFail (ExceptionallyC eff exc m)
String -> ExceptionallyC eff exc m a
forall a. String -> ExceptionallyC eff exc m a
forall (m :: * -> *).
Monad m -> (forall a. String -> m a) -> MonadFail m
forall (eff :: Effect) exc (m :: * -> *).
MonadFail m =>
Monad (ExceptionallyC eff exc m)
forall (eff :: Effect) exc (m :: * -> *) a.
MonadFail m =>
String -> ExceptionallyC eff exc m a
fail :: String -> ExceptionallyC eff exc m a
$cfail :: forall (eff :: Effect) exc (m :: * -> *) a.
MonadFail m =>
String -> ExceptionallyC eff exc m a
$cp1MonadFail :: forall (eff :: Effect) exc (m :: * -> *).
MonadFail m =>
Monad (ExceptionallyC eff exc m)
MonadFail, Monad (ExceptionallyC eff exc m)
Monad (ExceptionallyC eff exc m)
-> (forall a. IO a -> ExceptionallyC eff exc m a)
-> MonadIO (ExceptionallyC eff exc m)
IO a -> ExceptionallyC eff exc m a
forall a. IO a -> ExceptionallyC eff exc m a
forall (m :: * -> *).
Monad m -> (forall a. IO a -> m a) -> MonadIO m
forall (eff :: Effect) exc (m :: * -> *).
MonadIO m =>
Monad (ExceptionallyC eff exc m)
forall (eff :: Effect) exc (m :: * -> *) a.
MonadIO m =>
IO a -> ExceptionallyC eff exc m a
liftIO :: IO a -> ExceptionallyC eff exc m a
$cliftIO :: forall (eff :: Effect) exc (m :: * -> *) a.
MonadIO m =>
IO a -> ExceptionallyC eff exc m a
$cp1MonadIO :: forall (eff :: Effect) exc (m :: * -> *).
MonadIO m =>
Monad (ExceptionallyC eff exc m)
MonadIO
, Monad (ExceptionallyC eff exc m)
e -> ExceptionallyC eff exc m a
Monad (ExceptionallyC eff exc m)
-> (forall e a. Exception e => e -> ExceptionallyC eff exc m a)
-> MonadThrow (ExceptionallyC eff exc m)
forall e a. Exception e => e -> ExceptionallyC eff exc m a
forall (m :: * -> *).
Monad m -> (forall e a. Exception e => e -> m a) -> MonadThrow m
forall (eff :: Effect) exc (m :: * -> *).
MonadThrow m =>
Monad (ExceptionallyC eff exc m)
forall (eff :: Effect) exc (m :: * -> *) e a.
(MonadThrow m, Exception e) =>
e -> ExceptionallyC eff exc m a
throwM :: e -> ExceptionallyC eff exc m a
$cthrowM :: forall (eff :: Effect) exc (m :: * -> *) e a.
(MonadThrow m, Exception e) =>
e -> ExceptionallyC eff exc m a
$cp1MonadThrow :: forall (eff :: Effect) exc (m :: * -> *).
MonadThrow m =>
Monad (ExceptionallyC eff exc m)
MonadThrow, MonadThrow (ExceptionallyC eff exc m)
MonadThrow (ExceptionallyC eff exc m)
-> (forall e a.
Exception e =>
ExceptionallyC eff exc m a
-> (e -> ExceptionallyC eff exc m a) -> ExceptionallyC eff exc m a)
-> MonadCatch (ExceptionallyC eff exc m)
ExceptionallyC eff exc m a
-> (e -> ExceptionallyC eff exc m a) -> ExceptionallyC eff exc m a
forall e a.
Exception e =>
ExceptionallyC eff exc m a
-> (e -> ExceptionallyC eff exc m a) -> ExceptionallyC eff exc m a
forall (m :: * -> *).
MonadThrow m
-> (forall e a. Exception e => m a -> (e -> m a) -> m a)
-> MonadCatch m
forall (eff :: Effect) exc (m :: * -> *).
MonadCatch m =>
MonadThrow (ExceptionallyC eff exc m)
forall (eff :: Effect) exc (m :: * -> *) e a.
(MonadCatch m, Exception e) =>
ExceptionallyC eff exc m a
-> (e -> ExceptionallyC eff exc m a) -> ExceptionallyC eff exc m a
catch :: ExceptionallyC eff exc m a
-> (e -> ExceptionallyC eff exc m a) -> ExceptionallyC eff exc m a
$ccatch :: forall (eff :: Effect) exc (m :: * -> *) e a.
(MonadCatch m, Exception e) =>
ExceptionallyC eff exc m a
-> (e -> ExceptionallyC eff exc m a) -> ExceptionallyC eff exc m a
$cp1MonadCatch :: forall (eff :: Effect) exc (m :: * -> *).
MonadCatch m =>
MonadThrow (ExceptionallyC eff exc m)
MonadCatch, MonadCatch (ExceptionallyC eff exc m)
MonadCatch (ExceptionallyC eff exc m)
-> (forall b.
((forall a.
ExceptionallyC eff exc m a -> ExceptionallyC eff exc m a)
-> ExceptionallyC eff exc m b)
-> ExceptionallyC eff exc m b)
-> (forall b.
((forall a.
ExceptionallyC eff exc m a -> ExceptionallyC eff exc m a)
-> ExceptionallyC eff exc m b)
-> ExceptionallyC eff exc m b)
-> (forall a b c.
ExceptionallyC eff exc m a
-> (a -> ExitCase b -> ExceptionallyC eff exc m c)
-> (a -> ExceptionallyC eff exc m b)
-> ExceptionallyC eff exc m (b, c))
-> MonadMask (ExceptionallyC eff exc m)
ExceptionallyC eff exc m a
-> (a -> ExitCase b -> ExceptionallyC eff exc m c)
-> (a -> ExceptionallyC eff exc m b)
-> ExceptionallyC eff exc m (b, c)
((forall a.
ExceptionallyC eff exc m a -> ExceptionallyC eff exc m a)
-> ExceptionallyC eff exc m b)
-> ExceptionallyC eff exc m b
((forall a.
ExceptionallyC eff exc m a -> ExceptionallyC eff exc m a)
-> ExceptionallyC eff exc m b)
-> ExceptionallyC eff exc m b
forall b.
((forall a.
ExceptionallyC eff exc m a -> ExceptionallyC eff exc m a)
-> ExceptionallyC eff exc m b)
-> ExceptionallyC eff exc m b
forall a b c.
ExceptionallyC eff exc m a
-> (a -> ExitCase b -> ExceptionallyC eff exc m c)
-> (a -> ExceptionallyC eff exc m b)
-> ExceptionallyC eff exc m (b, c)
forall (m :: * -> *).
MonadCatch m
-> (forall b. ((forall a. m a -> m a) -> m b) -> m b)
-> (forall b. ((forall a. m a -> m a) -> m b) -> m b)
-> (forall a b c.
m a -> (a -> ExitCase b -> m c) -> (a -> m b) -> m (b, c))
-> MonadMask m
forall (eff :: Effect) exc (m :: * -> *).
MonadMask m =>
MonadCatch (ExceptionallyC eff exc m)
forall (eff :: Effect) exc (m :: * -> *) b.
MonadMask m =>
((forall a.
ExceptionallyC eff exc m a -> ExceptionallyC eff exc m a)
-> ExceptionallyC eff exc m b)
-> ExceptionallyC eff exc m b
forall (eff :: Effect) exc (m :: * -> *) a b c.
MonadMask m =>
ExceptionallyC eff exc m a
-> (a -> ExitCase b -> ExceptionallyC eff exc m c)
-> (a -> ExceptionallyC eff exc m b)
-> ExceptionallyC eff exc m (b, c)
generalBracket :: ExceptionallyC eff exc m a
-> (a -> ExitCase b -> ExceptionallyC eff exc m c)
-> (a -> ExceptionallyC eff exc m b)
-> ExceptionallyC eff exc m (b, c)
$cgeneralBracket :: forall (eff :: Effect) exc (m :: * -> *) a b c.
MonadMask m =>
ExceptionallyC eff exc m a
-> (a -> ExitCase b -> ExceptionallyC eff exc m c)
-> (a -> ExceptionallyC eff exc m b)
-> ExceptionallyC eff exc m (b, c)
uninterruptibleMask :: ((forall a.
ExceptionallyC eff exc m a -> ExceptionallyC eff exc m a)
-> ExceptionallyC eff exc m b)
-> ExceptionallyC eff exc m b
$cuninterruptibleMask :: forall (eff :: Effect) exc (m :: * -> *) b.
MonadMask m =>
((forall a.
ExceptionallyC eff exc m a -> ExceptionallyC eff exc m a)
-> ExceptionallyC eff exc m b)
-> ExceptionallyC eff exc m b
mask :: ((forall a.
ExceptionallyC eff exc m a -> ExceptionallyC eff exc m a)
-> ExceptionallyC eff exc m b)
-> ExceptionallyC eff exc m b
$cmask :: forall (eff :: Effect) exc (m :: * -> *) b.
MonadMask m =>
((forall a.
ExceptionallyC eff exc m a -> ExceptionallyC eff exc m a)
-> ExceptionallyC eff exc m b)
-> ExceptionallyC eff exc m b
$cp1MonadMask :: forall (eff :: Effect) exc (m :: * -> *).
MonadMask m =>
MonadCatch (ExceptionallyC eff exc m)
MonadMask
, MonadBase b, MonadBaseControl b
)
deriving (m a -> ExceptionallyC eff exc m a
(forall (m :: * -> *) a.
Monad m =>
m a -> ExceptionallyC eff exc m a)
-> MonadTrans (ExceptionallyC eff exc)
forall (m :: * -> *) a.
Monad m =>
m a -> ExceptionallyC eff exc m a
forall (t :: Effect).
(forall (m :: * -> *) a. Monad m => m a -> t m a) -> MonadTrans t
forall (eff :: Effect) exc (m :: * -> *) a.
Monad m =>
m a -> ExceptionallyC eff exc m a
lift :: m a -> ExceptionallyC eff exc m a
$clift :: forall (eff :: Effect) exc (m :: * -> *) a.
Monad m =>
m a -> ExceptionallyC eff exc m a
MonadTrans, MonadTrans (ExceptionallyC eff exc)
m (StT (ExceptionallyC eff exc) a) -> ExceptionallyC eff exc m a
MonadTrans (ExceptionallyC eff exc)
-> (forall (m :: * -> *) a.
Monad m =>
(Run (ExceptionallyC eff exc) -> m a)
-> ExceptionallyC eff exc m a)
-> (forall (m :: * -> *) a.
Monad m =>
m (StT (ExceptionallyC eff exc) a) -> ExceptionallyC eff exc m a)
-> MonadTransControl (ExceptionallyC eff exc)
(Run (ExceptionallyC eff exc) -> m a) -> ExceptionallyC eff exc m a
forall (m :: * -> *) a.
Monad m =>
m (StT (ExceptionallyC eff exc) a) -> ExceptionallyC eff exc m a
forall (m :: * -> *) a.
Monad m =>
(Run (ExceptionallyC eff exc) -> m a) -> ExceptionallyC eff exc m a
forall (t :: Effect).
MonadTrans t
-> (forall (m :: * -> *) a. Monad m => (Run t -> m a) -> t m a)
-> (forall (m :: * -> *) a. Monad m => m (StT t a) -> t m a)
-> MonadTransControl t
forall (eff :: Effect) exc. MonadTrans (ExceptionallyC eff exc)
forall (eff :: Effect) exc (m :: * -> *) a.
Monad m =>
m (StT (ExceptionallyC eff exc) a) -> ExceptionallyC eff exc m a
forall (eff :: Effect) exc (m :: * -> *) a.
Monad m =>
(Run (ExceptionallyC eff exc) -> m a) -> ExceptionallyC eff exc m a
restoreT :: m (StT (ExceptionallyC eff exc) a) -> ExceptionallyC eff exc m a
$crestoreT :: forall (eff :: Effect) exc (m :: * -> *) a.
Monad m =>
m (StT (ExceptionallyC eff exc) a) -> ExceptionallyC eff exc m a
liftWith :: (Run (ExceptionallyC eff exc) -> m a) -> ExceptionallyC eff exc m a
$cliftWith :: forall (eff :: Effect) exc (m :: * -> *) a.
Monad m =>
(Run (ExceptionallyC eff exc) -> m a) -> ExceptionallyC eff exc m a
$cp1MonadTransControl :: forall (eff :: Effect) exc. MonadTrans (ExceptionallyC eff exc)
MonadTransControl) via IdentityT
instance Eff (Exceptional eff exc) m
=> Carrier (ExceptionallyC eff exc m) where
type Derivs (ExceptionallyC eff exc m) = eff ': Catch exc ': Derivs m
type Prims (ExceptionallyC eff exc m) = Prims m
algPrims :: Algebra'
(Prims (ExceptionallyC eff exc m)) (ExceptionallyC eff exc m) a
algPrims = (Union (Prims m) m a -> m a)
-> Algebra' (Prims m) (ExceptionallyC eff exc m) a
coerce (forall a. Carrier m => Algebra' (Prims m) m a
forall (m :: * -> *) a. Carrier m => Algebra' (Prims m) m a
algPrims @m)
{-# INLINEABLE algPrims #-}
reformulate :: Reformulation'
(Derivs (ExceptionallyC eff exc m))
(Prims (ExceptionallyC eff exc m))
(ExceptionallyC eff exc m)
z
a
reformulate forall x. ExceptionallyC eff exc m x -> z x
n Algebra (Prims (ExceptionallyC eff exc m)) z
alg =
Algebra' (Catch exc : Derivs m) z a
-> (forall (z :: * -> *). Coercible z z => eff z a -> z a)
-> Algebra' (eff : Catch exc : Derivs m) z a
forall (e :: Effect) (r :: [Effect]) (m :: * -> *) a.
Algebra' r m a
-> (forall (z :: * -> *). Coercible z m => e z a -> m a)
-> Algebra' (e : r) m a
powerAlg' (
Algebra' (Derivs m) z a
-> (Catch exc z a -> z a) -> Algebra' (Catch exc : Derivs m) z a
forall (e :: Effect) (r :: [Effect]) (m :: * -> *) a.
RepresentationalEff e =>
Algebra' r m a -> (e m a -> m a) -> Algebra' (e : r) m a
powerAlg (
Reformulation' (Derivs m) (Prims m) m z a
forall (m :: * -> *) (z :: * -> *) a.
(Carrier m, Monad z) =>
Reformulation' (Derivs m) (Prims m) m z a
reformulate (ExceptionallyC eff exc m x -> z x
forall x. ExceptionallyC eff exc m x -> z x
n (ExceptionallyC eff exc m x -> z x)
-> (m x -> ExceptionallyC eff exc m x) -> m x -> z x
forall b a c. Coercible b a => (b -> c) -> (a -> b) -> a -> c
.# m x -> ExceptionallyC eff exc m x
forall (t :: Effect) (m :: * -> *) a.
(MonadTrans t, Monad m) =>
m a -> t m a
lift) forall x. Union (Prims m) z x -> z x
Algebra (Prims (ExceptionallyC eff exc m)) z
alg
) ((Catch exc z a -> z a) -> Algebra' (Catch exc : Derivs m) z a)
-> (Catch exc z a -> z a) -> Algebra' (Catch exc : Derivs m) z a
forall a b. (a -> b) -> a -> b
$ \Catch exc z a
e ->
Reformulation' (Derivs m) (Prims m) m z a
forall (m :: * -> *) (z :: * -> *) a.
(Carrier m, Monad z) =>
Reformulation' (Derivs m) (Prims m) m z a
reformulate (ExceptionallyC eff exc m x -> z x
forall x. ExceptionallyC eff exc m x -> z x
n (ExceptionallyC eff exc m x -> z x)
-> (m x -> ExceptionallyC eff exc m x) -> m x -> z x
forall b a c. Coercible b a => (b -> c) -> (a -> b) -> a -> c
.# m x -> ExceptionallyC eff exc m x
forall (t :: Effect) (m :: * -> *) a.
(MonadTrans t, Monad m) =>
m a -> t m a
lift) forall x. Union (Prims m) z x -> z x
Algebra (Prims (ExceptionallyC eff exc m)) z
alg Algebra' (Derivs m) z a -> Algebra' (Derivs m) z a
forall a b. (a -> b) -> a -> b
$ Exceptional eff exc z a -> Union (Derivs m) z a
forall (e :: Effect) (r :: [Effect]) (m :: * -> *) a.
Member e r =>
e m a -> Union r m a
inj (Exceptional eff exc z a -> Union (Derivs m) z a)
-> Exceptional eff exc z a -> Union (Derivs m) z a
forall a b. (a -> b) -> a -> b
$
Union '[eff, Catch exc] z a -> Exceptional eff exc z a
forall (eff :: Effect) exc (m :: * -> *) a.
Union '[eff, Catch exc] m a -> Exceptional eff exc m a
Exceptional @eff @exc (ElemOf (Catch exc) '[eff, Catch exc]
-> Catch exc z a -> Union '[eff, Catch exc] z a
forall (z :: * -> *) (m :: * -> *) (e :: Effect) (r :: [Effect]) a.
Coercible z m =>
ElemOf e r -> e z a -> Union r m a
Union (ElemOf (Catch exc) '[Catch exc]
-> ElemOf (Catch exc) '[eff, Catch exc]
forall a (e :: a) (r :: [a]) (_e :: a).
ElemOf e r -> ElemOf e (_e : r)
There ElemOf (Catch exc) '[Catch exc]
forall a (e :: a) (r :: [a]). ElemOf e (e : r)
Here) Catch exc z a
e)
) ((forall (z :: * -> *). Coercible z z => eff z a -> z a)
-> Algebra' (eff : Catch exc : Derivs m) z a)
-> (forall (z :: * -> *). Coercible z z => eff z a -> z a)
-> Algebra' (eff : Catch exc : Derivs m) z a
forall a b. (a -> b) -> a -> b
$ \eff z a
e ->
Reformulation' (Derivs m) (Prims m) m z a
forall (m :: * -> *) (z :: * -> *) a.
(Carrier m, Monad z) =>
Reformulation' (Derivs m) (Prims m) m z a
reformulate (ExceptionallyC eff exc m x -> z x
forall x. ExceptionallyC eff exc m x -> z x
n (ExceptionallyC eff exc m x -> z x)
-> (m x -> ExceptionallyC eff exc m x) -> m x -> z x
forall b a c. Coercible b a => (b -> c) -> (a -> b) -> a -> c
.# m x -> ExceptionallyC eff exc m x
forall (t :: Effect) (m :: * -> *) a.
(MonadTrans t, Monad m) =>
m a -> t m a
lift) forall x. Union (Prims m) z x -> z x
Algebra (Prims (ExceptionallyC eff exc m)) z
alg Algebra' (Derivs m) z a -> Algebra' (Derivs m) z a
forall a b. (a -> b) -> a -> b
$ Exceptional eff exc z a -> Union (Derivs m) z a
forall (e :: Effect) (r :: [Effect]) (m :: * -> *) a.
Member e r =>
e m a -> Union r m a
inj (Exceptional eff exc z a -> Union (Derivs m) z a)
-> Exceptional eff exc z a -> Union (Derivs m) z a
forall a b. (a -> b) -> a -> b
$
Union '[eff, Catch exc] z a -> Exceptional eff exc z a
forall (eff :: Effect) exc (m :: * -> *) a.
Union '[eff, Catch exc] m a -> Exceptional eff exc m a
Exceptional @eff @exc (ElemOf eff '[eff, Catch exc]
-> eff z a -> Union '[eff, Catch exc] z a
forall (z :: * -> *) (m :: * -> *) (e :: Effect) (r :: [Effect]) a.
Coercible z m =>
ElemOf e r -> e z a -> Union r m a
Union ElemOf eff '[eff, Catch exc]
forall a (e :: a) (r :: [a]). ElemOf e (e : r)
Here eff z a
e)
{-# INLINEABLE reformulate #-}
algDerivs :: Algebra'
(Derivs (ExceptionallyC eff exc m)) (ExceptionallyC eff exc m) a
algDerivs =
Algebra' (Catch exc : Derivs m) (ExceptionallyC eff exc m) a
-> (forall (z :: * -> *).
Coercible z (ExceptionallyC eff exc m) =>
eff z a -> ExceptionallyC eff exc m a)
-> Algebra'
(eff : Catch exc : Derivs m) (ExceptionallyC eff exc m) a
forall (e :: Effect) (r :: [Effect]) (m :: * -> *) a.
Algebra' r m a
-> (forall (z :: * -> *). Coercible z m => e z a -> m a)
-> Algebra' (e : r) m a
powerAlg' (
Algebra' (Derivs m) (ExceptionallyC eff exc m) a
-> (Catch exc (ExceptionallyC eff exc m) a
-> ExceptionallyC eff exc m a)
-> Algebra' (Catch exc : Derivs m) (ExceptionallyC eff exc m) a
forall (e :: Effect) (r :: [Effect]) (m :: * -> *) a.
RepresentationalEff e =>
Algebra' r m a -> (e m a -> m a) -> Algebra' (e : r) m a
powerAlg (
Algebra' (Derivs m) m a
-> Algebra' (Derivs m) (ExceptionallyC eff exc m) a
coerce (forall a. Carrier m => Algebra' (Derivs m) m a
forall (m :: * -> *) a. Carrier m => Algebra' (Derivs m) m a
algDerivs @m)
) ((Catch exc (ExceptionallyC eff exc m) a
-> ExceptionallyC eff exc m a)
-> Algebra' (Catch exc : Derivs m) (ExceptionallyC eff exc m) a)
-> (Catch exc (ExceptionallyC eff exc m) a
-> ExceptionallyC eff exc m a)
-> Algebra' (Catch exc : Derivs m) (ExceptionallyC eff exc m) a
forall a b. (a -> b) -> a -> b
$ \Catch exc (ExceptionallyC eff exc m) a
e ->
Algebra' (Derivs m) m a
-> Algebra' (Derivs m) (ExceptionallyC eff exc m) a
forall (n :: * -> *) (m :: * -> *) (e :: Effect) a b.
(Coercible n m, RepresentationalEff e) =>
(e m a -> m b) -> e n a -> n b
coerceAlg (forall a. Carrier m => Algebra' (Derivs m) m a
forall (m :: * -> *) a. Carrier m => Algebra' (Derivs m) m a
algDerivs @m) Algebra' (Derivs m) (ExceptionallyC eff exc m) a
-> Algebra' (Derivs m) (ExceptionallyC eff exc m) a
forall a b. (a -> b) -> a -> b
$ Exceptional eff exc (ExceptionallyC eff exc m) a
-> Union (Derivs m) (ExceptionallyC eff exc m) a
forall (e :: Effect) (r :: [Effect]) (m :: * -> *) a.
Member e r =>
e m a -> Union r m a
inj (Exceptional eff exc (ExceptionallyC eff exc m) a
-> Union (Derivs m) (ExceptionallyC eff exc m) a)
-> Exceptional eff exc (ExceptionallyC eff exc m) a
-> Union (Derivs m) (ExceptionallyC eff exc m) a
forall a b. (a -> b) -> a -> b
$ Union '[eff, Catch exc] (ExceptionallyC eff exc m) a
-> Exceptional eff exc (ExceptionallyC eff exc m) a
forall (eff :: Effect) exc (m :: * -> *) a.
Union '[eff, Catch exc] m a -> Exceptional eff exc m a
Exceptional @eff @exc (ElemOf (Catch exc) '[eff, Catch exc]
-> Catch exc (ExceptionallyC eff exc m) a
-> Union '[eff, Catch exc] (ExceptionallyC eff exc m) a
forall (z :: * -> *) (m :: * -> *) (e :: Effect) (r :: [Effect]) a.
Coercible z m =>
ElemOf e r -> e z a -> Union r m a
Union (ElemOf (Catch exc) '[Catch exc]
-> ElemOf (Catch exc) '[eff, Catch exc]
forall a (e :: a) (r :: [a]) (_e :: a).
ElemOf e r -> ElemOf e (_e : r)
There ElemOf (Catch exc) '[Catch exc]
forall a (e :: a) (r :: [a]). ElemOf e (e : r)
Here) Catch exc (ExceptionallyC eff exc m) a
e)
) ((forall (z :: * -> *).
Coercible z (ExceptionallyC eff exc m) =>
eff z a -> ExceptionallyC eff exc m a)
-> Algebra'
(eff : Catch exc : Derivs m) (ExceptionallyC eff exc m) a)
-> (forall (z :: * -> *).
Coercible z (ExceptionallyC eff exc m) =>
eff z a -> ExceptionallyC eff exc m a)
-> Algebra'
(eff : Catch exc : Derivs m) (ExceptionallyC eff exc m) a
forall a b. (a -> b) -> a -> b
$ \eff z a
e ->
Algebra' (Derivs m) m a
-> Algebra' (Derivs m) (ExceptionallyC eff exc m) a
forall (n :: * -> *) (m :: * -> *) (e :: Effect) a b.
(Coercible n m, RepresentationalEff e) =>
(e m a -> m b) -> e n a -> n b
coerceAlg (forall a. Carrier m => Algebra' (Derivs m) m a
forall (m :: * -> *) a. Carrier m => Algebra' (Derivs m) m a
algDerivs @m) Algebra' (Derivs m) (ExceptionallyC eff exc m) a
-> Algebra' (Derivs m) (ExceptionallyC eff exc m) a
forall a b. (a -> b) -> a -> b
$ Exceptional eff exc (ExceptionallyC eff exc m) a
-> Union (Derivs m) (ExceptionallyC eff exc m) a
forall (e :: Effect) (r :: [Effect]) (m :: * -> *) a.
Member e r =>
e m a -> Union r m a
inj (Exceptional eff exc (ExceptionallyC eff exc m) a
-> Union (Derivs m) (ExceptionallyC eff exc m) a)
-> Exceptional eff exc (ExceptionallyC eff exc m) a
-> Union (Derivs m) (ExceptionallyC eff exc m) a
forall a b. (a -> b) -> a -> b
$ Union '[eff, Catch exc] (ExceptionallyC eff exc m) a
-> Exceptional eff exc (ExceptionallyC eff exc m) a
forall (eff :: Effect) exc (m :: * -> *) a.
Union '[eff, Catch exc] m a -> Exceptional eff exc m a
Exceptional @eff @exc (ElemOf eff '[eff, Catch exc]
-> eff z a -> Union '[eff, Catch exc] (ExceptionallyC eff exc m) a
forall (z :: * -> *) (m :: * -> *) (e :: Effect) (r :: [Effect]) a.
Coercible z m =>
ElemOf e r -> e z a -> Union r m a
Union ElemOf eff '[eff, Catch exc]
forall a (e :: a) (r :: [a]). ElemOf e (e : r)
Here eff z a
e)
{-# INLINEABLE algDerivs #-}
catching :: forall eff exc m a
. Eff (Exceptional eff exc) m
=> ExceptionallyC eff exc m a
-> (exc -> m a)
-> m a
catching :: ExceptionallyC eff exc m a -> (exc -> m a) -> m a
catching ExceptionallyC eff exc m a
m exc -> m a
h =
Exceptional eff exc m a -> m a
forall (e :: Effect) (m :: * -> *) a.
(Member e (Derivs m), Carrier m) =>
e m a -> m a
send (Exceptional eff exc m a -> m a) -> Exceptional eff exc m a -> m a
forall a b. (a -> b) -> a -> b
$ forall (m :: * -> *) a.
Union '[eff, Catch exc] m a -> Exceptional eff exc m a
forall (eff :: Effect) exc (m :: * -> *) a.
Union '[eff, Catch exc] m a -> Exceptional eff exc m a
Exceptional @eff @exc (Union '[eff, Catch exc] m a -> Exceptional eff exc m a)
-> Union '[eff, Catch exc] m a -> Exceptional eff exc m a
forall a b. (a -> b) -> a -> b
$
ElemOf (Catch exc) '[eff, Catch exc]
-> Catch exc m a -> Union '[eff, Catch exc] m a
forall (z :: * -> *) (m :: * -> *) (e :: Effect) (r :: [Effect]) a.
Coercible z m =>
ElemOf e r -> e z a -> Union r m a
Union (ElemOf (Catch exc) '[Catch exc]
-> ElemOf (Catch exc) '[eff, Catch exc]
forall a (e :: a) (r :: [a]) (_e :: a).
ElemOf e r -> ElemOf e (_e : r)
There ElemOf (Catch exc) '[Catch exc]
forall a (e :: a) (r :: [a]). ElemOf e (e : r)
Here) (m a -> (exc -> m a) -> Catch exc m a
forall (m :: * -> *) a e. m a -> (e -> m a) -> Catch e m a
Catch (ExceptionallyC eff exc m a -> m a
forall (eff :: Effect) exc k (m :: k -> *) (a :: k).
ExceptionallyC eff exc m a -> m a
unExceptionallyC ExceptionallyC eff exc m a
m) exc -> m a
h)
{-# INLINE catching #-}
catchSafe :: forall exc m a
. Eff (SafeError exc) m
=> ExceptionallyC (Throw exc) exc m a
-> (exc -> m a)
-> m a
catchSafe :: ExceptionallyC (Throw exc) exc m a -> (exc -> m a) -> m a
catchSafe = ExceptionallyC (Throw exc) exc m a -> (exc -> m a) -> m a
forall (eff :: Effect) exc (m :: * -> *) a.
Eff (Exceptional eff exc) m =>
ExceptionallyC eff exc m a -> (exc -> m a) -> m a
catching
{-# INLINE catchSafe #-}
trying :: forall eff exc m a
. Eff (Exceptional eff exc) m
=> ExceptionallyC eff exc m a
-> m (Either exc a)
trying :: ExceptionallyC eff exc m a -> m (Either exc a)
trying ExceptionallyC eff exc m a
m = (a -> Either exc a)
-> ExceptionallyC eff exc m a
-> ExceptionallyC eff exc m (Either exc a)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
fmap a -> Either exc a
forall a b. b -> Either a b
Right ExceptionallyC eff exc m a
m ExceptionallyC eff exc m (Either exc a)
-> (exc -> m (Either exc a)) -> m (Either exc a)
forall (eff :: Effect) exc (m :: * -> *) a.
Eff (Exceptional eff exc) m =>
ExceptionallyC eff exc m a -> (exc -> m a) -> m a
`catching` (Either exc a -> m (Either exc a)
forall (m :: * -> *) a. Monad m => a -> m a
return (Either exc a -> m (Either exc a))
-> (exc -> Either exc a) -> exc -> m (Either exc a)
forall b c a. (b -> c) -> (a -> b) -> a -> c
. exc -> Either exc a
forall a b. a -> Either a b
Left)
{-# INLINE trying #-}
trySafe :: forall exc m a
. Eff (SafeError exc) m
=> ExceptionallyC (Throw exc) exc m a
-> m (Either exc a)
trySafe :: ExceptionallyC (Throw exc) exc m a -> m (Either exc a)
trySafe = ExceptionallyC (Throw exc) exc m a -> m (Either exc a)
forall (eff :: Effect) exc (m :: * -> *) a.
Eff (Exceptional eff exc) m =>
ExceptionallyC eff exc m a -> m (Either exc a)
trying
{-# INLINE trySafe #-}
throwing :: forall eff exc m a
. Effs [Exceptional eff exc, Throw exc] m
=> ExceptionallyC eff exc m a
-> m a
throwing :: ExceptionallyC eff exc m a -> m a
throwing ExceptionallyC eff exc m a
m = ExceptionallyC eff exc m a
m ExceptionallyC eff exc m a -> (exc -> m a) -> m a
forall (eff :: Effect) exc (m :: * -> *) a.
Eff (Exceptional eff exc) m =>
ExceptionallyC eff exc m a -> (exc -> m a) -> m a
`catching` exc -> m a
forall e (m :: * -> *) a. Eff (Throw e) m => e -> m a
throw
{-# INLINE throwing #-}
data ExceptionalH
instance ( Member eff (Derivs m)
, Eff (Catch exc) m
)
=> Handler ExceptionalH (Exceptional eff exc) m where
effHandler :: Exceptional eff exc (Effly z) x -> Effly z x
effHandler (Exceptional Union '[eff, Catch exc] (Effly z) x
e) = case Union '[eff, Catch exc] (Effly z) x
e of
Union ElemOf e '[eff, Catch exc]
Here e z x
eff -> Algebra' (Derivs (Effly z)) (Effly z) x
forall (m :: * -> *) a. Carrier m => Algebra' (Derivs m) m a
algDerivs (ElemOf e (Derivs m) -> e z x -> Union (Derivs m) (Effly z) x
forall (z :: * -> *) (m :: * -> *) (e :: Effect) (r :: [Effect]) a.
Coercible z m =>
ElemOf e r -> e z a -> Union r m a
Union ElemOf e (Derivs m)
forall k (e :: k) (r :: [k]). Member e r => ElemOf e r
membership e z x
eff)
Union (There ElemOf e r
Here) e z x
eff -> Algebra' (Derivs (Effly z)) (Effly z) x
forall (m :: * -> *) a. Carrier m => Algebra' (Derivs m) m a
algDerivs (ElemOf e (Derivs m) -> e z x -> Union (Derivs m) (Effly z) x
forall (z :: * -> *) (m :: * -> *) (e :: Effect) (r :: [Effect]) a.
Coercible z m =>
ElemOf e r -> e z a -> Union r m a
Union ElemOf e (Derivs m)
forall k (e :: k) (r :: [k]). Member e r => ElemOf e r
membership e z x
eff)
Union (There (There ElemOf e r
pr)) e z x
_ -> ElemOf e '[] -> Effly z x
forall a (e :: a) b. ElemOf e '[] -> b
absurdMember ElemOf e r
ElemOf e '[]
pr
{-# INLINEABLE effHandler #-}
type ExceptionalC eff exc = InterpretC ExceptionalH (Exceptional eff exc)
type SafeErrorToErrorC exc = ExceptionalC (Throw exc) exc
runExceptional :: forall eff exc m a
. ( Member eff (Derivs m)
, Eff (Catch exc) m
)
=> ExceptionalC eff exc m a
-> m a
runExceptional :: ExceptionalC eff exc m a -> m a
runExceptional = ExceptionalC eff exc m a -> m a
forall h (e :: Effect) (m :: * -> *) a.
Handler h e m =>
InterpretC h e m a -> m a
interpretViaHandler
{-# INLINE runExceptional #-}
runExceptionalJust :: forall eff smallExc bigExc m a
. ( Member eff (Derivs m)
, Eff (Error bigExc) m
)
=> (bigExc -> Maybe smallExc)
-> InterpretReifiedC (Exceptional eff smallExc) m a
-> m a
runExceptionalJust :: (bigExc -> Maybe smallExc)
-> InterpretReifiedC (Exceptional eff smallExc) m a -> m a
runExceptionalJust bigExc -> Maybe smallExc
from = EffHandler (Exceptional eff smallExc) m
-> InterpretReifiedC (Exceptional eff smallExc) m a -> m a
forall (e :: Effect) (m :: * -> *) a.
(RepresentationalEff e, Carrier m) =>
EffHandler e m -> InterpretReifiedC e m a -> m a
interpret (EffHandler (Exceptional eff smallExc) m
-> InterpretReifiedC (Exceptional eff smallExc) m a -> m a)
-> EffHandler (Exceptional eff smallExc) m
-> InterpretReifiedC (Exceptional eff smallExc) m a
-> m a
forall a b. (a -> b) -> a -> b
$ \(Exceptional e) -> case Union '[eff, Catch smallExc] (Effly z) x
e of
Union ElemOf e '[eff, Catch smallExc]
Here e z x
eff -> Algebra' (Derivs (Effly z)) (Effly z) x
forall (m :: * -> *) a. Carrier m => Algebra' (Derivs m) m a
algDerivs (ElemOf e (Derivs m) -> e z x -> Union (Derivs m) (Effly z) x
forall (z :: * -> *) (m :: * -> *) (e :: Effect) (r :: [Effect]) a.
Coercible z m =>
ElemOf e r -> e z a -> Union r m a
Union ElemOf e (Derivs m)
forall k (e :: k) (r :: [k]). Member e r => ElemOf e r
membership e z x
eff)
Union (There ElemOf e r
pr) e z x
eff -> case Union '[Catch smallExc] (Effly z) x -> Catch smallExc (Effly z) x
forall (e :: Effect) (m :: * -> *) a.
RepresentationalEff e =>
Union '[e] m a -> e m a
extract (ElemOf e r -> e z x -> Union r (Effly z) x
forall (z :: * -> *) (m :: * -> *) (e :: Effect) (r :: [Effect]) a.
Coercible z m =>
ElemOf e r -> e z a -> Union r m a
Union ElemOf e r
pr e z x
eff) of
Catch Effly z x
m smallExc -> Effly z x
h -> (bigExc -> Maybe smallExc)
-> Effly z x -> (smallExc -> Effly z x) -> Effly z x
forall smallExc bigExc (m :: * -> *) a.
Eff (Error bigExc) m =>
(bigExc -> Maybe smallExc) -> m a -> (smallExc -> m a) -> m a
catchJust bigExc -> Maybe smallExc
from Effly z x
m smallExc -> Effly z x
h
{-# INLINE runExceptionalJust #-}
runExceptionalJustSimple :: forall eff smallExc bigExc m a p
. ( Member eff (Derivs m)
, Eff (Error bigExc) m
, Threaders '[ReaderThreads] m p
)
=> (bigExc -> Maybe smallExc)
-> InterpretSimpleC (Exceptional eff smallExc) m a
-> m a
runExceptionalJustSimple :: (bigExc -> Maybe smallExc)
-> InterpretSimpleC (Exceptional eff smallExc) m a -> m a
runExceptionalJustSimple bigExc -> Maybe smallExc
from = EffHandler (Exceptional eff smallExc) m
-> InterpretSimpleC (Exceptional eff smallExc) m a -> m a
forall (e :: Effect) (m :: * -> *) a (p :: [Effect]).
(RepresentationalEff e, Threaders '[ReaderThreads] m p,
Carrier m) =>
EffHandler e m -> InterpretSimpleC e m a -> m a
interpretSimple (EffHandler (Exceptional eff smallExc) m
-> InterpretSimpleC (Exceptional eff smallExc) m a -> m a)
-> EffHandler (Exceptional eff smallExc) m
-> InterpretSimpleC (Exceptional eff smallExc) m a
-> m a
forall a b. (a -> b) -> a -> b
$ \(Exceptional e) -> case Union '[eff, Catch smallExc] (Effly z) x
e of
Union ElemOf e '[eff, Catch smallExc]
Here e z x
eff -> Algebra' (Derivs (Effly z)) (Effly z) x
forall (m :: * -> *) a. Carrier m => Algebra' (Derivs m) m a
algDerivs (ElemOf e (Derivs m) -> e z x -> Union (Derivs m) (Effly z) x
forall (z :: * -> *) (m :: * -> *) (e :: Effect) (r :: [Effect]) a.
Coercible z m =>
ElemOf e r -> e z a -> Union r m a
Union ElemOf e (Derivs m)
forall k (e :: k) (r :: [k]). Member e r => ElemOf e r
membership e z x
eff)
Union (There ElemOf e r
pr) e z x
eff -> case Union '[Catch smallExc] (Effly z) x -> Catch smallExc (Effly z) x
forall (e :: Effect) (m :: * -> *) a.
RepresentationalEff e =>
Union '[e] m a -> e m a
extract (ElemOf e r -> e z x -> Union r (Effly z) x
forall (z :: * -> *) (m :: * -> *) (e :: Effect) (r :: [Effect]) a.
Coercible z m =>
ElemOf e r -> e z a -> Union r m a
Union ElemOf e r
pr e z x
eff) of
Catch Effly z x
m smallExc -> Effly z x
h -> (bigExc -> Maybe smallExc)
-> Effly z x -> (smallExc -> Effly z x) -> Effly z x
forall smallExc bigExc (m :: * -> *) a.
Eff (Error bigExc) m =>
(bigExc -> Maybe smallExc) -> m a -> (smallExc -> m a) -> m a
catchJust bigExc -> Maybe smallExc
from Effly z x
m smallExc -> Effly z x
h
{-# INLINE runExceptionalJustSimple #-}
safeErrorToError :: forall exc m a
. Eff (Error exc) m
=> SafeErrorToErrorC exc m a
-> m a
safeErrorToError :: SafeErrorToErrorC exc m a -> m a
safeErrorToError = SafeErrorToErrorC exc m a -> m a
forall (eff :: Effect) exc (m :: * -> *) a.
(Member eff (Derivs m), Eff (Catch exc) m) =>
ExceptionalC eff exc m a -> m a
runExceptional
{-# INLINE safeErrorToError #-}
type SafeErrorC exc = CompositionC
'[ IntroUnderC (SafeError exc) '[Catch exc, Throw exc]
, SafeErrorToErrorC exc
, ErrorC exc
]
runSafeError :: forall e m a p
. ( Carrier m
, Threaders '[ErrorThreads] m p
)
=> SafeErrorC e m a
-> m a
runSafeError :: SafeErrorC e m a -> m a
runSafeError =
(Either e a -> a) -> m (Either e a) -> m a
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
fmap (a -> Either e a -> a
forall b a. b -> Either a b -> b
fromRight a
forall a. a
bombPure)
(m (Either e a) -> m a)
-> (ErrorC e m a -> m (Either e a)) -> ErrorC e m a -> m a
forall b a c. Coercible b a => (b -> c) -> (a -> b) -> a -> c
.# ErrorC e m a -> m (Either e a)
forall e (m :: * -> *) a (p :: [Effect]).
(Carrier m, Threaders '[ErrorThreads] m p) =>
ErrorC e m a -> m (Either e a)
runError
(ErrorC e m a -> m a)
-> (SafeErrorToErrorC e (ErrorC e m) a -> ErrorC e m a)
-> SafeErrorToErrorC e (ErrorC e m) a
-> m a
forall b a c. Coercible b a => (b -> c) -> (a -> b) -> a -> c
.# SafeErrorToErrorC e (ErrorC e m) a -> ErrorC e m a
forall exc (m :: * -> *) a.
Eff (Error exc) m =>
SafeErrorToErrorC exc m a -> m a
safeErrorToError
(SafeErrorToErrorC e (ErrorC e m) a -> m a)
-> (IntroUnderC
(Exceptional (Throw e) e)
'[Catch e, Throw e]
(InterpretC ExceptionalH (Exceptional (Throw e) e) (ErrorC e m))
a
-> SafeErrorToErrorC e (ErrorC e m) a)
-> IntroUnderC
(Exceptional (Throw e) e)
'[Catch e, Throw e]
(InterpretC ExceptionalH (Exceptional (Throw e) e) (ErrorC e m))
a
-> m a
forall b a c. Coercible b a => (b -> c) -> (a -> b) -> a -> c
.# IntroUnderC
(Exceptional (Throw e) e)
'[Catch e, Throw e]
(InterpretC ExceptionalH (Exceptional (Throw e) e) (ErrorC e m))
a
-> SafeErrorToErrorC e (ErrorC e m) a
forall (new :: [Effect]) (e :: Effect) (m :: * -> *) a.
(KnownList new, IntroConsistent '[e] new m) =>
IntroUnderC e new m a -> m a
introUnder
(IntroUnderC
(Exceptional (Throw e) e)
'[Catch e, Throw e]
(InterpretC ExceptionalH (Exceptional (Throw e) e) (ErrorC e m))
a
-> m a)
-> (SafeErrorC e m a
-> IntroUnderC
(Exceptional (Throw e) e)
'[Catch e, Throw e]
(InterpretC ExceptionalH (Exceptional (Throw e) e) (ErrorC e m))
a)
-> SafeErrorC e m a
-> m a
forall b a c. Coercible b a => (b -> c) -> (a -> b) -> a -> c
.# SafeErrorC e m a
-> IntroUnderC
(Exceptional (Throw e) e)
'[Catch e, Throw e]
(InterpretC ExceptionalH (Exceptional (Throw e) e) (ErrorC e m))
a
forall (ts :: [Effect]) (m :: * -> *) a.
CompositionC ts m a -> CompositionBaseM ts m a
runComposition
{-# INLINE runSafeError #-}
bombPure :: a
bombPure :: a
bombPure = String -> a
forall a. String -> a
errorWithoutStackTrace
String
"runSafeError: Escaped exception! Unless you've imported some internal \
\modules and did something REALLY stupid, this is a bug. Make an issue about \
\it on the GitHub repository for in-other-words."
bombIO :: String -> a
bombIO :: String -> a
bombIO String
str = String -> a
forall a. String -> a
errorWithoutStackTrace (String -> a) -> String -> a
forall a b. (a -> b) -> a -> b
$
String
str String -> String -> String
forall a. [a] -> [a] -> [a]
++ String
": Escaped exception! This is likely because an `async`ed exceptional \
\computation escaped a `catching` through an `Async`. See \
\Control.Effect.Exceptional.Exceptional. If that sounds unlikely, and you \
\didn't import any internal modules and do something really stupid, \
\then this could be a bug. If so, make an issue about \
\it on the GitHub repository for in-other-words."
type SafeErrorToIOC' s s' exc = CompositionC
'[ IntroUnderC (SafeError exc) '[Catch exc, Throw exc]
, SafeErrorToErrorC exc
, ErrorToIOC' s s' exc
]
type SafeErrorToIOC e m a =
forall s s'
. ReifiesErrorHandler s s' e (ErrorIOToIOC m)
=> SafeErrorToIOC' s s' e m a
safeErrorToIO :: forall e m a
. ( Eff (Embed IO) m
, MonadCatch m
)
=> SafeErrorToIOC e m a
-> m a
safeErrorToIO :: SafeErrorToIOC e m a -> m a
safeErrorToIO SafeErrorToIOC e m a
m =
(Either e a -> a) -> m (Either e a) -> m a
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
fmap (a -> Either e a -> a
forall b a. b -> Either a b -> b
fromRight (String -> a
forall a. String -> a
bombIO String
"safeErrorToIO"))
(m (Either e a) -> m a) -> m (Either e a) -> m a
forall a b. (a -> b) -> a -> b
$ ErrorToIOC e m a -> m (Either e a)
forall e (m :: * -> *) a.
(MonadCatch m, Eff (Embed IO) m) =>
ErrorToIOC e m a -> m (Either e a)
errorToIO
(ErrorToIOC e m a -> m (Either e a))
-> ErrorToIOC e m a -> m (Either e a)
forall a b. (a -> b) -> a -> b
$ SafeErrorToErrorC
e
(CompositionC
'[IntroC '[Catch e, Throw e] '[ErrorIO], InterpretErrorC' s s' e,
ErrorIOToIOC]
m)
a
-> CompositionC
'[IntroC '[Catch e, Throw e] '[ErrorIO], InterpretErrorC' s s' e,
ErrorIOToIOC]
m
a
forall exc (m :: * -> *) a.
Eff (Error exc) m =>
SafeErrorToErrorC exc m a -> m a
safeErrorToError
(SafeErrorToErrorC
e
(CompositionC
'[IntroC '[Catch e, Throw e] '[ErrorIO], InterpretErrorC' s s' e,
ErrorIOToIOC]
m)
a
-> CompositionC
'[IntroC '[Catch e, Throw e] '[ErrorIO], InterpretErrorC' s s' e,
ErrorIOToIOC]
m
a)
-> SafeErrorToErrorC
e
(CompositionC
'[IntroC '[Catch e, Throw e] '[ErrorIO], InterpretErrorC' s s' e,
ErrorIOToIOC]
m)
a
-> CompositionC
'[IntroC '[Catch e, Throw e] '[ErrorIO], InterpretErrorC' s s' e,
ErrorIOToIOC]
m
a
forall a b. (a -> b) -> a -> b
$ IntroUnderC
(Exceptional (Throw e) e)
'[Catch e, Throw e]
(InterpretC
ExceptionalH
(Exceptional (Throw e) e)
(CompositionC
'[IntroC '[Catch e, Throw e] '[ErrorIO], InterpretErrorC' s s' e,
ErrorIOToIOC]
m))
a
-> SafeErrorToErrorC
e
(CompositionC
'[IntroC '[Catch e, Throw e] '[ErrorIO], InterpretErrorC' s s' e,
ErrorIOToIOC]
m)
a
forall (new :: [Effect]) (e :: Effect) (m :: * -> *) a.
(KnownList new, IntroConsistent '[e] new m) =>
IntroUnderC e new m a -> m a
introUnder
(IntroUnderC
(Exceptional (Throw e) e)
'[Catch e, Throw e]
(InterpretC
ExceptionalH
(Exceptional (Throw e) e)
(CompositionC
'[IntroC '[Catch e, Throw e] '[ErrorIO], InterpretErrorC' s s' e,
ErrorIOToIOC]
m))
a
-> SafeErrorToErrorC
e
(CompositionC
'[IntroC '[Catch e, Throw e] '[ErrorIO], InterpretErrorC' s s' e,
ErrorIOToIOC]
m)
a)
-> IntroUnderC
(Exceptional (Throw e) e)
'[Catch e, Throw e]
(InterpretC
ExceptionalH
(Exceptional (Throw e) e)
(CompositionC
'[IntroC '[Catch e, Throw e] '[ErrorIO], InterpretErrorC' s s' e,
ErrorIOToIOC]
m))
a
-> SafeErrorToErrorC
e
(CompositionC
'[IntroC '[Catch e, Throw e] '[ErrorIO], InterpretErrorC' s s' e,
ErrorIOToIOC]
m)
a
forall a b. (a -> b) -> a -> b
$ CompositionC
'[IntroUnderC (Exceptional (Throw e) e) '[Catch e, Throw e],
SafeErrorToErrorC e, ErrorToIOC' s s' e]
m
a
-> CompositionBaseM
'[IntroUnderC (Exceptional (Throw e) e) '[Catch e, Throw e],
SafeErrorToErrorC e, ErrorToIOC' s s' e]
m
a
forall (ts :: [Effect]) (m :: * -> *) a.
CompositionC ts m a -> CompositionBaseM ts m a
runComposition
(CompositionC
'[IntroUnderC (Exceptional (Throw e) e) '[Catch e, Throw e],
SafeErrorToErrorC e, ErrorToIOC' s s' e]
m
a
-> CompositionBaseM
'[IntroUnderC (Exceptional (Throw e) e) '[Catch e, Throw e],
SafeErrorToErrorC e, ErrorToIOC' s s' e]
m
a)
-> CompositionC
'[IntroUnderC (Exceptional (Throw e) e) '[Catch e, Throw e],
SafeErrorToErrorC e, ErrorToIOC' s s' e]
m
a
-> CompositionBaseM
'[IntroUnderC (Exceptional (Throw e) e) '[Catch e, Throw e],
SafeErrorToErrorC e, ErrorToIOC' s s' e]
m
a
forall a b. (a -> b) -> a -> b
$ CompositionC
'[IntroUnderC (Exceptional (Throw e) e) '[Catch e, Throw e],
SafeErrorToErrorC e, ErrorToIOC' s s' e]
m
a
SafeErrorToIOC e m a
m
{-# INLINE safeErrorToIO #-}
type SafeErrorToErrorIOC' s s' exc = CompositionC
'[ IntroUnderC (SafeError exc) '[Catch exc, Throw exc]
, SafeErrorToErrorC exc
, InterpretErrorC' s s' exc
]
type SafeErrorToErrorIOC e m a =
forall s s'
. ReifiesErrorHandler s s' e m
=> SafeErrorToErrorIOC' s s' e m a
safeErrorToErrorIO :: forall e m a
. Effs '[Embed IO, ErrorIO] m
=> SafeErrorToErrorIOC e m a
-> m a
safeErrorToErrorIO :: SafeErrorToErrorIOC e m a -> m a
safeErrorToErrorIO SafeErrorToErrorIOC e m a
m =
(Either e a -> a) -> m (Either e a) -> m a
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
fmap (a -> Either e a -> a
forall b a. b -> Either a b -> b
fromRight (String -> a
forall a. String -> a
bombIO String
"safeErrorToErrorIO"))
(m (Either e a) -> m a) -> m (Either e a) -> m a
forall a b. (a -> b) -> a -> b
$ InterpretErrorC e m a -> m (Either e a)
forall e (m :: * -> *) a.
Effs '[ErrorIO, Embed IO] m =>
InterpretErrorC e m a -> m (Either e a)
errorToErrorIO
(InterpretErrorC e m a -> m (Either e a))
-> InterpretErrorC e m a -> m (Either e a)
forall a b. (a -> b) -> a -> b
$ SafeErrorToErrorC
e
(CompositionC
'[InterpretC (ViaReifiedH s) (Catch e),
InterpretC (ViaReifiedH s') (Throw e)]
m)
a
-> CompositionC
'[InterpretC (ViaReifiedH s) (Catch e),
InterpretC (ViaReifiedH s') (Throw e)]
m
a
forall exc (m :: * -> *) a.
Eff (Error exc) m =>
SafeErrorToErrorC exc m a -> m a
safeErrorToError
(SafeErrorToErrorC
e
(CompositionC
'[InterpretC (ViaReifiedH s) (Catch e),
InterpretC (ViaReifiedH s') (Throw e)]
m)
a
-> CompositionC
'[InterpretC (ViaReifiedH s) (Catch e),
InterpretC (ViaReifiedH s') (Throw e)]
m
a)
-> SafeErrorToErrorC
e
(CompositionC
'[InterpretC (ViaReifiedH s) (Catch e),
InterpretC (ViaReifiedH s') (Throw e)]
m)
a
-> CompositionC
'[InterpretC (ViaReifiedH s) (Catch e),
InterpretC (ViaReifiedH s') (Throw e)]
m
a
forall a b. (a -> b) -> a -> b
$ IntroUnderC
(Exceptional (Throw e) e)
'[Catch e, Throw e]
(InterpretC
ExceptionalH
(Exceptional (Throw e) e)
(CompositionC
'[InterpretC (ViaReifiedH s) (Catch e),
InterpretC (ViaReifiedH s') (Throw e)]
m))
a
-> SafeErrorToErrorC
e
(CompositionC
'[InterpretC (ViaReifiedH s) (Catch e),
InterpretC (ViaReifiedH s') (Throw e)]
m)
a
forall (new :: [Effect]) (e :: Effect) (m :: * -> *) a.
(KnownList new, IntroConsistent '[e] new m) =>
IntroUnderC e new m a -> m a
introUnder
(IntroUnderC
(Exceptional (Throw e) e)
'[Catch e, Throw e]
(InterpretC
ExceptionalH
(Exceptional (Throw e) e)
(CompositionC
'[InterpretC (ViaReifiedH s) (Catch e),
InterpretC (ViaReifiedH s') (Throw e)]
m))
a
-> SafeErrorToErrorC
e
(CompositionC
'[InterpretC (ViaReifiedH s) (Catch e),
InterpretC (ViaReifiedH s') (Throw e)]
m)
a)
-> IntroUnderC
(Exceptional (Throw e) e)
'[Catch e, Throw e]
(InterpretC
ExceptionalH
(Exceptional (Throw e) e)
(CompositionC
'[InterpretC (ViaReifiedH s) (Catch e),
InterpretC (ViaReifiedH s') (Throw e)]
m))
a
-> SafeErrorToErrorC
e
(CompositionC
'[InterpretC (ViaReifiedH s) (Catch e),
InterpretC (ViaReifiedH s') (Throw e)]
m)
a
forall a b. (a -> b) -> a -> b
$ CompositionC
'[IntroUnderC (Exceptional (Throw e) e) '[Catch e, Throw e],
SafeErrorToErrorC e, InterpretErrorC' s s' e]
m
a
-> CompositionBaseM
'[IntroUnderC (Exceptional (Throw e) e) '[Catch e, Throw e],
SafeErrorToErrorC e, InterpretErrorC' s s' e]
m
a
forall (ts :: [Effect]) (m :: * -> *) a.
CompositionC ts m a -> CompositionBaseM ts m a
runComposition
(CompositionC
'[IntroUnderC (Exceptional (Throw e) e) '[Catch e, Throw e],
SafeErrorToErrorC e, InterpretErrorC' s s' e]
m
a
-> CompositionBaseM
'[IntroUnderC (Exceptional (Throw e) e) '[Catch e, Throw e],
SafeErrorToErrorC e, InterpretErrorC' s s' e]
m
a)
-> CompositionC
'[IntroUnderC (Exceptional (Throw e) e) '[Catch e, Throw e],
SafeErrorToErrorC e, InterpretErrorC' s s' e]
m
a
-> CompositionBaseM
'[IntroUnderC (Exceptional (Throw e) e) '[Catch e, Throw e],
SafeErrorToErrorC e, InterpretErrorC' s s' e]
m
a
forall a b. (a -> b) -> a -> b
$ CompositionC
'[IntroUnderC (Exceptional (Throw e) e) '[Catch e, Throw e],
SafeErrorToErrorC e, InterpretErrorC' s s' e]
m
a
SafeErrorToErrorIOC e m a
m
{-# INLINE safeErrorToErrorIO #-}
type SafeErrorToIOSimpleC exc = CompositionC
'[ IntroUnderC (SafeError exc) '[Catch exc, Throw exc]
, SafeErrorToErrorC exc
, ErrorToIOSimpleC exc
]
safeErrorToIOSimple :: forall e m a p
. ( Eff (Embed IO) m
, MonadCatch m
, Threaders '[ReaderThreads] m p
)
=> SafeErrorToIOSimpleC e m a
-> m a
safeErrorToIOSimple :: SafeErrorToIOSimpleC e m a -> m a
safeErrorToIOSimple =
(Either e a -> a) -> m (Either e a) -> m a
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
fmap (a -> Either e a -> a
forall b a. b -> Either a b -> b
fromRight (String -> a
forall a. String -> a
bombIO String
"safeErrorToIOSimple"))
(m (Either e a) -> m a)
-> (ErrorToIOSimpleC e m a -> m (Either e a))
-> ErrorToIOSimpleC e m a
-> m a
forall b c a. (b -> c) -> (a -> b) -> a -> c
. ErrorToIOSimpleC e m a -> m (Either e a)
forall e (m :: * -> *) a (p :: [Effect]).
(Eff (Embed IO) m, MonadCatch m, Threaders '[ReaderThreads] m p) =>
ErrorToIOSimpleC e m a -> m (Either e a)
errorToIOSimple
(ErrorToIOSimpleC e m a -> m a)
-> (SafeErrorToErrorC
e
(CompositionC
'[IntroC '[Catch e, Throw e] '[ErrorIO], InterpretErrorSimpleC e,
ErrorIOToIOC]
m)
a
-> ErrorToIOSimpleC e m a)
-> SafeErrorToErrorC
e
(CompositionC
'[IntroC '[Catch e, Throw e] '[ErrorIO], InterpretErrorSimpleC e,
ErrorIOToIOC]
m)
a
-> m a
forall b a c. Coercible b a => (b -> c) -> (a -> b) -> a -> c
.# SafeErrorToErrorC
e
(CompositionC
'[IntroC '[Catch e, Throw e] '[ErrorIO], InterpretErrorSimpleC e,
ErrorIOToIOC]
m)
a
-> ErrorToIOSimpleC e m a
forall exc (m :: * -> *) a.
Eff (Error exc) m =>
SafeErrorToErrorC exc m a -> m a
safeErrorToError
(SafeErrorToErrorC
e
(CompositionC
'[IntroC '[Catch e, Throw e] '[ErrorIO], InterpretErrorSimpleC e,
ErrorIOToIOC]
m)
a
-> m a)
-> (IntroUnderC
(Exceptional (Throw e) e)
'[Catch e, Throw e]
(InterpretC
ExceptionalH
(Exceptional (Throw e) e)
(CompositionC
'[IntroC '[Catch e, Throw e] '[ErrorIO], InterpretErrorSimpleC e,
ErrorIOToIOC]
m))
a
-> SafeErrorToErrorC
e
(CompositionC
'[IntroC '[Catch e, Throw e] '[ErrorIO], InterpretErrorSimpleC e,
ErrorIOToIOC]
m)
a)
-> IntroUnderC
(Exceptional (Throw e) e)
'[Catch e, Throw e]
(InterpretC
ExceptionalH
(Exceptional (Throw e) e)
(CompositionC
'[IntroC '[Catch e, Throw e] '[ErrorIO], InterpretErrorSimpleC e,
ErrorIOToIOC]
m))
a
-> m a
forall b a c. Coercible b a => (b -> c) -> (a -> b) -> a -> c
.# IntroUnderC
(Exceptional (Throw e) e)
'[Catch e, Throw e]
(InterpretC
ExceptionalH
(Exceptional (Throw e) e)
(CompositionC
'[IntroC '[Catch e, Throw e] '[ErrorIO], InterpretErrorSimpleC e,
ErrorIOToIOC]
m))
a
-> SafeErrorToErrorC
e
(CompositionC
'[IntroC '[Catch e, Throw e] '[ErrorIO], InterpretErrorSimpleC e,
ErrorIOToIOC]
m)
a
forall (new :: [Effect]) (e :: Effect) (m :: * -> *) a.
(KnownList new, IntroConsistent '[e] new m) =>
IntroUnderC e new m a -> m a
introUnder
(IntroUnderC
(Exceptional (Throw e) e)
'[Catch e, Throw e]
(InterpretC
ExceptionalH
(Exceptional (Throw e) e)
(CompositionC
'[IntroC '[Catch e, Throw e] '[ErrorIO], InterpretErrorSimpleC e,
ErrorIOToIOC]
m))
a
-> m a)
-> (SafeErrorToIOSimpleC e m a
-> IntroUnderC
(Exceptional (Throw e) e)
'[Catch e, Throw e]
(InterpretC
ExceptionalH
(Exceptional (Throw e) e)
(CompositionC
'[IntroC '[Catch e, Throw e] '[ErrorIO], InterpretErrorSimpleC e,
ErrorIOToIOC]
m))
a)
-> SafeErrorToIOSimpleC e m a
-> m a
forall b a c. Coercible b a => (b -> c) -> (a -> b) -> a -> c
.# SafeErrorToIOSimpleC e m a
-> IntroUnderC
(Exceptional (Throw e) e)
'[Catch e, Throw e]
(InterpretC
ExceptionalH
(Exceptional (Throw e) e)
(CompositionC
'[IntroC '[Catch e, Throw e] '[ErrorIO], InterpretErrorSimpleC e,
ErrorIOToIOC]
m))
a
forall (ts :: [Effect]) (m :: * -> *) a.
CompositionC ts m a -> CompositionBaseM ts m a
runComposition
{-# INLINE safeErrorToIOSimple #-}
type SafeErrorToErrorIOSimpleC exc = CompositionC
'[ IntroUnderC (SafeError exc) '[Catch exc, Throw exc]
, SafeErrorToErrorC exc
, InterpretErrorSimpleC exc
]
safeErrorToErrorIOSimple :: forall e m a p
. ( Effs '[ErrorIO, Embed IO] m
, Threaders '[ReaderThreads] m p
)
=> SafeErrorToErrorIOSimpleC e m a
-> m a
safeErrorToErrorIOSimple :: SafeErrorToErrorIOSimpleC e m a -> m a
safeErrorToErrorIOSimple =
(Either e a -> a) -> m (Either e a) -> m a
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
fmap (a -> Either e a -> a
forall b a. b -> Either a b -> b
fromRight (String -> a
forall a. String -> a
bombIO String
"safeErrorToErrorIOSimple"))
(m (Either e a) -> m a)
-> (InterpretErrorSimpleC e m a -> m (Either e a))
-> InterpretErrorSimpleC e m a
-> m a
forall b c a. (b -> c) -> (a -> b) -> a -> c
. InterpretErrorSimpleC e m a -> m (Either e a)
forall e (m :: * -> *) a (p :: [Effect]).
(Effs '[ErrorIO, Embed IO] m, Threaders '[ReaderThreads] m p) =>
InterpretErrorSimpleC e m a -> m (Either e a)
errorToErrorIOSimple
(InterpretErrorSimpleC e m a -> m a)
-> (SafeErrorToErrorC
e
(CompositionC
'[InterpretSimpleC (Catch e), InterpretSimpleC (Throw e)] m)
a
-> InterpretErrorSimpleC e m a)
-> SafeErrorToErrorC
e
(CompositionC
'[InterpretSimpleC (Catch e), InterpretSimpleC (Throw e)] m)
a
-> m a
forall b a c. Coercible b a => (b -> c) -> (a -> b) -> a -> c
.# SafeErrorToErrorC
e
(CompositionC
'[InterpretSimpleC (Catch e), InterpretSimpleC (Throw e)] m)
a
-> InterpretErrorSimpleC e m a
forall exc (m :: * -> *) a.
Eff (Error exc) m =>
SafeErrorToErrorC exc m a -> m a
safeErrorToError
(SafeErrorToErrorC
e
(CompositionC
'[InterpretSimpleC (Catch e), InterpretSimpleC (Throw e)] m)
a
-> m a)
-> (IntroUnderC
(Exceptional (Throw e) e)
'[Catch e, Throw e]
(InterpretC
ExceptionalH
(Exceptional (Throw e) e)
(CompositionC
'[InterpretSimpleC (Catch e), InterpretSimpleC (Throw e)] m))
a
-> SafeErrorToErrorC
e
(CompositionC
'[InterpretSimpleC (Catch e), InterpretSimpleC (Throw e)] m)
a)
-> IntroUnderC
(Exceptional (Throw e) e)
'[Catch e, Throw e]
(InterpretC
ExceptionalH
(Exceptional (Throw e) e)
(CompositionC
'[InterpretSimpleC (Catch e), InterpretSimpleC (Throw e)] m))
a
-> m a
forall b a c. Coercible b a => (b -> c) -> (a -> b) -> a -> c
.# IntroUnderC
(Exceptional (Throw e) e)
'[Catch e, Throw e]
(InterpretC
ExceptionalH
(Exceptional (Throw e) e)
(CompositionC
'[InterpretSimpleC (Catch e), InterpretSimpleC (Throw e)] m))
a
-> SafeErrorToErrorC
e
(CompositionC
'[InterpretSimpleC (Catch e), InterpretSimpleC (Throw e)] m)
a
forall (new :: [Effect]) (e :: Effect) (m :: * -> *) a.
(KnownList new, IntroConsistent '[e] new m) =>
IntroUnderC e new m a -> m a
introUnder
(IntroUnderC
(Exceptional (Throw e) e)
'[Catch e, Throw e]
(InterpretC
ExceptionalH
(Exceptional (Throw e) e)
(CompositionC
'[InterpretSimpleC (Catch e), InterpretSimpleC (Throw e)] m))
a
-> m a)
-> (SafeErrorToErrorIOSimpleC e m a
-> IntroUnderC
(Exceptional (Throw e) e)
'[Catch e, Throw e]
(InterpretC
ExceptionalH
(Exceptional (Throw e) e)
(CompositionC
'[InterpretSimpleC (Catch e), InterpretSimpleC (Throw e)] m))
a)
-> SafeErrorToErrorIOSimpleC e m a
-> m a
forall b a c. Coercible b a => (b -> c) -> (a -> b) -> a -> c
.# SafeErrorToErrorIOSimpleC e m a
-> IntroUnderC
(Exceptional (Throw e) e)
'[Catch e, Throw e]
(InterpretC
ExceptionalH
(Exceptional (Throw e) e)
(CompositionC
'[InterpretSimpleC (Catch e), InterpretSimpleC (Throw e)] m))
a
forall (ts :: [Effect]) (m :: * -> *) a.
CompositionC ts m a -> CompositionBaseM ts m a
runComposition
{-# INLINE safeErrorToErrorIOSimple #-}