{-# LANGUAGE DeriveFunctor, DerivingVia #-}
{-# OPTIONS_HADDOCK not-home #-}
module Control.Effect.Internal.Optional where
import Control.Monad
import Control.Monad.Trans.Control
import Control.Monad.Trans.Identity
import Control.Effect
import Control.Effect.Carrier
import Control.Effect.Carrier.Internal.Interpret
import Control.Effect.Type.Optional
newtype HoistOptionCall b a = HoistOptionCall (forall x. (a -> x) -> b x -> b x)
deriving (a -> HoistOptionCall b b -> HoistOptionCall b a
(a -> b) -> HoistOptionCall b a -> HoistOptionCall b b
(forall a b.
(a -> b) -> HoistOptionCall b a -> HoistOptionCall b b)
-> (forall a b. a -> HoistOptionCall b b -> HoistOptionCall b a)
-> Functor (HoistOptionCall b)
forall a b. a -> HoistOptionCall b b -> HoistOptionCall b a
forall a b. (a -> b) -> HoistOptionCall b a -> HoistOptionCall b b
forall (f :: * -> *).
(forall a b. (a -> b) -> f a -> f b)
-> (forall a b. a -> f b -> f a) -> Functor f
forall (b :: * -> *) a b.
a -> HoistOptionCall b b -> HoistOptionCall b a
forall (b :: * -> *) a b.
(a -> b) -> HoistOptionCall b a -> HoistOptionCall b b
<$ :: a -> HoistOptionCall b b -> HoistOptionCall b a
$c<$ :: forall (b :: * -> *) a b.
a -> HoistOptionCall b b -> HoistOptionCall b a
fmap :: (a -> b) -> HoistOptionCall b a -> HoistOptionCall b b
$cfmap :: forall (b :: * -> *) a b.
(a -> b) -> HoistOptionCall b a -> HoistOptionCall b b
Functor)
type HoistOption (b :: * -> *) = Optional (HoistOptionCall b)
data HoistOptionH
instance Carrier m => PrimHandler HoistOptionH (HoistOption m) m where
effPrimHandler :: HoistOption m m x -> m x
effPrimHandler (Optionally (HoistOptionCall forall x. (x -> x) -> m x -> m x
b) m x
m) = (x -> x) -> m x -> m x
forall x. (x -> x) -> m x -> m x
b x -> x
forall a. a -> a
id m x
m
{-# INLINEABLE effPrimHandler #-}
newtype HoistOptionC m a = HoistOptionC {
HoistOptionC m a -> m a
unHoistOptionC :: m a
}
deriving ( a -> HoistOptionC m b -> HoistOptionC m a
(a -> b) -> HoistOptionC m a -> HoistOptionC m b
(forall a b. (a -> b) -> HoistOptionC m a -> HoistOptionC m b)
-> (forall a b. a -> HoistOptionC m b -> HoistOptionC m a)
-> Functor (HoistOptionC m)
forall a b. a -> HoistOptionC m b -> HoistOptionC m a
forall a b. (a -> b) -> HoistOptionC m a -> HoistOptionC m b
forall (m :: * -> *) a b.
Functor m =>
a -> HoistOptionC m b -> HoistOptionC m a
forall (m :: * -> *) a b.
Functor m =>
(a -> b) -> HoistOptionC m a -> HoistOptionC m b
forall (f :: * -> *).
(forall a b. (a -> b) -> f a -> f b)
-> (forall a b. a -> f b -> f a) -> Functor f
<$ :: a -> HoistOptionC m b -> HoistOptionC m a
$c<$ :: forall (m :: * -> *) a b.
Functor m =>
a -> HoistOptionC m b -> HoistOptionC m a
fmap :: (a -> b) -> HoistOptionC m a -> HoistOptionC m b
$cfmap :: forall (m :: * -> *) a b.
Functor m =>
(a -> b) -> HoistOptionC m a -> HoistOptionC m b
Functor, Functor (HoistOptionC m)
a -> HoistOptionC m a
Functor (HoistOptionC m)
-> (forall a. a -> HoistOptionC m a)
-> (forall a b.
HoistOptionC m (a -> b) -> HoistOptionC m a -> HoistOptionC m b)
-> (forall a b c.
(a -> b -> c)
-> HoistOptionC m a -> HoistOptionC m b -> HoistOptionC m c)
-> (forall a b.
HoistOptionC m a -> HoistOptionC m b -> HoistOptionC m b)
-> (forall a b.
HoistOptionC m a -> HoistOptionC m b -> HoistOptionC m a)
-> Applicative (HoistOptionC m)
HoistOptionC m a -> HoistOptionC m b -> HoistOptionC m b
HoistOptionC m a -> HoistOptionC m b -> HoistOptionC m a
HoistOptionC m (a -> b) -> HoistOptionC m a -> HoistOptionC m b
(a -> b -> c)
-> HoistOptionC m a -> HoistOptionC m b -> HoistOptionC m c
forall a. a -> HoistOptionC m a
forall a b.
HoistOptionC m a -> HoistOptionC m b -> HoistOptionC m a
forall a b.
HoistOptionC m a -> HoistOptionC m b -> HoistOptionC m b
forall a b.
HoistOptionC m (a -> b) -> HoistOptionC m a -> HoistOptionC m b
forall a b c.
(a -> b -> c)
-> HoistOptionC m a -> HoistOptionC m b -> HoistOptionC 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 (m :: * -> *). Applicative m => Functor (HoistOptionC m)
forall (m :: * -> *) a. Applicative m => a -> HoistOptionC m a
forall (m :: * -> *) a b.
Applicative m =>
HoistOptionC m a -> HoistOptionC m b -> HoistOptionC m a
forall (m :: * -> *) a b.
Applicative m =>
HoistOptionC m a -> HoistOptionC m b -> HoistOptionC m b
forall (m :: * -> *) a b.
Applicative m =>
HoistOptionC m (a -> b) -> HoistOptionC m a -> HoistOptionC m b
forall (m :: * -> *) a b c.
Applicative m =>
(a -> b -> c)
-> HoistOptionC m a -> HoistOptionC m b -> HoistOptionC m c
<* :: HoistOptionC m a -> HoistOptionC m b -> HoistOptionC m a
$c<* :: forall (m :: * -> *) a b.
Applicative m =>
HoistOptionC m a -> HoistOptionC m b -> HoistOptionC m a
*> :: HoistOptionC m a -> HoistOptionC m b -> HoistOptionC m b
$c*> :: forall (m :: * -> *) a b.
Applicative m =>
HoistOptionC m a -> HoistOptionC m b -> HoistOptionC m b
liftA2 :: (a -> b -> c)
-> HoistOptionC m a -> HoistOptionC m b -> HoistOptionC m c
$cliftA2 :: forall (m :: * -> *) a b c.
Applicative m =>
(a -> b -> c)
-> HoistOptionC m a -> HoistOptionC m b -> HoistOptionC m c
<*> :: HoistOptionC m (a -> b) -> HoistOptionC m a -> HoistOptionC m b
$c<*> :: forall (m :: * -> *) a b.
Applicative m =>
HoistOptionC m (a -> b) -> HoistOptionC m a -> HoistOptionC m b
pure :: a -> HoistOptionC m a
$cpure :: forall (m :: * -> *) a. Applicative m => a -> HoistOptionC m a
$cp1Applicative :: forall (m :: * -> *). Applicative m => Functor (HoistOptionC m)
Applicative, Applicative (HoistOptionC m)
a -> HoistOptionC m a
Applicative (HoistOptionC m)
-> (forall a b.
HoistOptionC m a -> (a -> HoistOptionC m b) -> HoistOptionC m b)
-> (forall a b.
HoistOptionC m a -> HoistOptionC m b -> HoistOptionC m b)
-> (forall a. a -> HoistOptionC m a)
-> Monad (HoistOptionC m)
HoistOptionC m a -> (a -> HoistOptionC m b) -> HoistOptionC m b
HoistOptionC m a -> HoistOptionC m b -> HoistOptionC m b
forall a. a -> HoistOptionC m a
forall a b.
HoistOptionC m a -> HoistOptionC m b -> HoistOptionC m b
forall a b.
HoistOptionC m a -> (a -> HoistOptionC m b) -> HoistOptionC m b
forall (m :: * -> *). Monad m => Applicative (HoistOptionC m)
forall (m :: * -> *) a. Monad m => a -> HoistOptionC m a
forall (m :: * -> *) a b.
Monad m =>
HoistOptionC m a -> HoistOptionC m b -> HoistOptionC m b
forall (m :: * -> *) a b.
Monad m =>
HoistOptionC m a -> (a -> HoistOptionC m b) -> HoistOptionC 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
return :: a -> HoistOptionC m a
$creturn :: forall (m :: * -> *) a. Monad m => a -> HoistOptionC m a
>> :: HoistOptionC m a -> HoistOptionC m b -> HoistOptionC m b
$c>> :: forall (m :: * -> *) a b.
Monad m =>
HoistOptionC m a -> HoistOptionC m b -> HoistOptionC m b
>>= :: HoistOptionC m a -> (a -> HoistOptionC m b) -> HoistOptionC m b
$c>>= :: forall (m :: * -> *) a b.
Monad m =>
HoistOptionC m a -> (a -> HoistOptionC m b) -> HoistOptionC m b
$cp1Monad :: forall (m :: * -> *). Monad m => Applicative (HoistOptionC m)
Monad
, Applicative (HoistOptionC m)
HoistOptionC m a
Applicative (HoistOptionC m)
-> (forall a. HoistOptionC m a)
-> (forall a.
HoistOptionC m a -> HoistOptionC m a -> HoistOptionC m a)
-> (forall a. HoistOptionC m a -> HoistOptionC m [a])
-> (forall a. HoistOptionC m a -> HoistOptionC m [a])
-> Alternative (HoistOptionC m)
HoistOptionC m a -> HoistOptionC m a -> HoistOptionC m a
HoistOptionC m a -> HoistOptionC m [a]
HoistOptionC m a -> HoistOptionC m [a]
forall a. HoistOptionC m a
forall a. HoistOptionC m a -> HoistOptionC m [a]
forall a. HoistOptionC m a -> HoistOptionC m a -> HoistOptionC 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 (m :: * -> *). Alternative m => Applicative (HoistOptionC m)
forall (m :: * -> *) a. Alternative m => HoistOptionC m a
forall (m :: * -> *) a.
Alternative m =>
HoistOptionC m a -> HoistOptionC m [a]
forall (m :: * -> *) a.
Alternative m =>
HoistOptionC m a -> HoistOptionC m a -> HoistOptionC m a
many :: HoistOptionC m a -> HoistOptionC m [a]
$cmany :: forall (m :: * -> *) a.
Alternative m =>
HoistOptionC m a -> HoistOptionC m [a]
some :: HoistOptionC m a -> HoistOptionC m [a]
$csome :: forall (m :: * -> *) a.
Alternative m =>
HoistOptionC m a -> HoistOptionC m [a]
<|> :: HoistOptionC m a -> HoistOptionC m a -> HoistOptionC m a
$c<|> :: forall (m :: * -> *) a.
Alternative m =>
HoistOptionC m a -> HoistOptionC m a -> HoistOptionC m a
empty :: HoistOptionC m a
$cempty :: forall (m :: * -> *) a. Alternative m => HoistOptionC m a
$cp1Alternative :: forall (m :: * -> *). Alternative m => Applicative (HoistOptionC m)
Alternative, Monad (HoistOptionC m)
Alternative (HoistOptionC m)
HoistOptionC m a
Alternative (HoistOptionC m)
-> Monad (HoistOptionC m)
-> (forall a. HoistOptionC m a)
-> (forall a.
HoistOptionC m a -> HoistOptionC m a -> HoistOptionC m a)
-> MonadPlus (HoistOptionC m)
HoistOptionC m a -> HoistOptionC m a -> HoistOptionC m a
forall a. HoistOptionC m a
forall a. HoistOptionC m a -> HoistOptionC m a -> HoistOptionC m a
forall (m :: * -> *).
Alternative m
-> Monad m
-> (forall a. m a)
-> (forall a. m a -> m a -> m a)
-> MonadPlus m
forall (m :: * -> *). MonadPlus m => Monad (HoistOptionC m)
forall (m :: * -> *). MonadPlus m => Alternative (HoistOptionC m)
forall (m :: * -> *) a. MonadPlus m => HoistOptionC m a
forall (m :: * -> *) a.
MonadPlus m =>
HoistOptionC m a -> HoistOptionC m a -> HoistOptionC m a
mplus :: HoistOptionC m a -> HoistOptionC m a -> HoistOptionC m a
$cmplus :: forall (m :: * -> *) a.
MonadPlus m =>
HoistOptionC m a -> HoistOptionC m a -> HoistOptionC m a
mzero :: HoistOptionC m a
$cmzero :: forall (m :: * -> *) a. MonadPlus m => HoistOptionC m a
$cp2MonadPlus :: forall (m :: * -> *). MonadPlus m => Monad (HoistOptionC m)
$cp1MonadPlus :: forall (m :: * -> *). MonadPlus m => Alternative (HoistOptionC m)
MonadPlus
, Monad (HoistOptionC m)
Monad (HoistOptionC m)
-> (forall a. (a -> HoistOptionC m a) -> HoistOptionC m a)
-> MonadFix (HoistOptionC m)
(a -> HoistOptionC m a) -> HoistOptionC m a
forall a. (a -> HoistOptionC m a) -> HoistOptionC m a
forall (m :: * -> *).
Monad m -> (forall a. (a -> m a) -> m a) -> MonadFix m
forall (m :: * -> *). MonadFix m => Monad (HoistOptionC m)
forall (m :: * -> *) a.
MonadFix m =>
(a -> HoistOptionC m a) -> HoistOptionC m a
mfix :: (a -> HoistOptionC m a) -> HoistOptionC m a
$cmfix :: forall (m :: * -> *) a.
MonadFix m =>
(a -> HoistOptionC m a) -> HoistOptionC m a
$cp1MonadFix :: forall (m :: * -> *). MonadFix m => Monad (HoistOptionC m)
MonadFix, Monad (HoistOptionC m)
Monad (HoistOptionC m)
-> (forall a. String -> HoistOptionC m a)
-> MonadFail (HoistOptionC m)
String -> HoistOptionC m a
forall a. String -> HoistOptionC m a
forall (m :: * -> *).
Monad m -> (forall a. String -> m a) -> MonadFail m
forall (m :: * -> *). MonadFail m => Monad (HoistOptionC m)
forall (m :: * -> *) a. MonadFail m => String -> HoistOptionC m a
fail :: String -> HoistOptionC m a
$cfail :: forall (m :: * -> *) a. MonadFail m => String -> HoistOptionC m a
$cp1MonadFail :: forall (m :: * -> *). MonadFail m => Monad (HoistOptionC m)
MonadFail, Monad (HoistOptionC m)
Monad (HoistOptionC m)
-> (forall a. IO a -> HoistOptionC m a) -> MonadIO (HoistOptionC m)
IO a -> HoistOptionC m a
forall a. IO a -> HoistOptionC m a
forall (m :: * -> *).
Monad m -> (forall a. IO a -> m a) -> MonadIO m
forall (m :: * -> *). MonadIO m => Monad (HoistOptionC m)
forall (m :: * -> *) a. MonadIO m => IO a -> HoistOptionC m a
liftIO :: IO a -> HoistOptionC m a
$cliftIO :: forall (m :: * -> *) a. MonadIO m => IO a -> HoistOptionC m a
$cp1MonadIO :: forall (m :: * -> *). MonadIO m => Monad (HoistOptionC m)
MonadIO
, Monad (HoistOptionC m)
e -> HoistOptionC m a
Monad (HoistOptionC m)
-> (forall e a. Exception e => e -> HoistOptionC m a)
-> MonadThrow (HoistOptionC m)
forall e a. Exception e => e -> HoistOptionC m a
forall (m :: * -> *).
Monad m -> (forall e a. Exception e => e -> m a) -> MonadThrow m
forall (m :: * -> *). MonadThrow m => Monad (HoistOptionC m)
forall (m :: * -> *) e a.
(MonadThrow m, Exception e) =>
e -> HoistOptionC m a
throwM :: e -> HoistOptionC m a
$cthrowM :: forall (m :: * -> *) e a.
(MonadThrow m, Exception e) =>
e -> HoistOptionC m a
$cp1MonadThrow :: forall (m :: * -> *). MonadThrow m => Monad (HoistOptionC m)
MonadThrow, MonadThrow (HoistOptionC m)
MonadThrow (HoistOptionC m)
-> (forall e a.
Exception e =>
HoistOptionC m a -> (e -> HoistOptionC m a) -> HoistOptionC m a)
-> MonadCatch (HoistOptionC m)
HoistOptionC m a -> (e -> HoistOptionC m a) -> HoistOptionC m a
forall e a.
Exception e =>
HoistOptionC m a -> (e -> HoistOptionC m a) -> HoistOptionC m a
forall (m :: * -> *).
MonadThrow m
-> (forall e a. Exception e => m a -> (e -> m a) -> m a)
-> MonadCatch m
forall (m :: * -> *). MonadCatch m => MonadThrow (HoistOptionC m)
forall (m :: * -> *) e a.
(MonadCatch m, Exception e) =>
HoistOptionC m a -> (e -> HoistOptionC m a) -> HoistOptionC m a
catch :: HoistOptionC m a -> (e -> HoistOptionC m a) -> HoistOptionC m a
$ccatch :: forall (m :: * -> *) e a.
(MonadCatch m, Exception e) =>
HoistOptionC m a -> (e -> HoistOptionC m a) -> HoistOptionC m a
$cp1MonadCatch :: forall (m :: * -> *). MonadCatch m => MonadThrow (HoistOptionC m)
MonadCatch, MonadCatch (HoistOptionC m)
MonadCatch (HoistOptionC m)
-> (forall b.
((forall a. HoistOptionC m a -> HoistOptionC m a)
-> HoistOptionC m b)
-> HoistOptionC m b)
-> (forall b.
((forall a. HoistOptionC m a -> HoistOptionC m a)
-> HoistOptionC m b)
-> HoistOptionC m b)
-> (forall a b c.
HoistOptionC m a
-> (a -> ExitCase b -> HoistOptionC m c)
-> (a -> HoistOptionC m b)
-> HoistOptionC m (b, c))
-> MonadMask (HoistOptionC m)
HoistOptionC m a
-> (a -> ExitCase b -> HoistOptionC m c)
-> (a -> HoistOptionC m b)
-> HoistOptionC m (b, c)
((forall a. HoistOptionC m a -> HoistOptionC m a)
-> HoistOptionC m b)
-> HoistOptionC m b
((forall a. HoistOptionC m a -> HoistOptionC m a)
-> HoistOptionC m b)
-> HoistOptionC m b
forall b.
((forall a. HoistOptionC m a -> HoistOptionC m a)
-> HoistOptionC m b)
-> HoistOptionC m b
forall a b c.
HoistOptionC m a
-> (a -> ExitCase b -> HoistOptionC m c)
-> (a -> HoistOptionC m b)
-> HoistOptionC 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 (m :: * -> *). MonadMask m => MonadCatch (HoistOptionC m)
forall (m :: * -> *) b.
MonadMask m =>
((forall a. HoistOptionC m a -> HoistOptionC m a)
-> HoistOptionC m b)
-> HoistOptionC m b
forall (m :: * -> *) a b c.
MonadMask m =>
HoistOptionC m a
-> (a -> ExitCase b -> HoistOptionC m c)
-> (a -> HoistOptionC m b)
-> HoistOptionC m (b, c)
generalBracket :: HoistOptionC m a
-> (a -> ExitCase b -> HoistOptionC m c)
-> (a -> HoistOptionC m b)
-> HoistOptionC m (b, c)
$cgeneralBracket :: forall (m :: * -> *) a b c.
MonadMask m =>
HoistOptionC m a
-> (a -> ExitCase b -> HoistOptionC m c)
-> (a -> HoistOptionC m b)
-> HoistOptionC m (b, c)
uninterruptibleMask :: ((forall a. HoistOptionC m a -> HoistOptionC m a)
-> HoistOptionC m b)
-> HoistOptionC m b
$cuninterruptibleMask :: forall (m :: * -> *) b.
MonadMask m =>
((forall a. HoistOptionC m a -> HoistOptionC m a)
-> HoistOptionC m b)
-> HoistOptionC m b
mask :: ((forall a. HoistOptionC m a -> HoistOptionC m a)
-> HoistOptionC m b)
-> HoistOptionC m b
$cmask :: forall (m :: * -> *) b.
MonadMask m =>
((forall a. HoistOptionC m a -> HoistOptionC m a)
-> HoistOptionC m b)
-> HoistOptionC m b
$cp1MonadMask :: forall (m :: * -> *). MonadMask m => MonadCatch (HoistOptionC m)
MonadMask
)
deriving (m a -> HoistOptionC m a
(forall (m :: * -> *) a. Monad m => m a -> HoistOptionC m a)
-> MonadTrans HoistOptionC
forall (m :: * -> *) a. Monad m => m a -> HoistOptionC m a
forall (t :: Effect).
(forall (m :: * -> *) a. Monad m => m a -> t m a) -> MonadTrans t
lift :: m a -> HoistOptionC m a
$clift :: forall (m :: * -> *) a. Monad m => m a -> HoistOptionC m a
MonadTrans, MonadTrans HoistOptionC
m (StT HoistOptionC a) -> HoistOptionC m a
MonadTrans HoistOptionC
-> (forall (m :: * -> *) a.
Monad m =>
(Run HoistOptionC -> m a) -> HoistOptionC m a)
-> (forall (m :: * -> *) a.
Monad m =>
m (StT HoistOptionC a) -> HoistOptionC m a)
-> MonadTransControl HoistOptionC
(Run HoistOptionC -> m a) -> HoistOptionC m a
forall (m :: * -> *) a.
Monad m =>
m (StT HoistOptionC a) -> HoistOptionC m a
forall (m :: * -> *) a.
Monad m =>
(Run HoistOptionC -> m a) -> HoistOptionC 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
restoreT :: m (StT HoistOptionC a) -> HoistOptionC m a
$crestoreT :: forall (m :: * -> *) a.
Monad m =>
m (StT HoistOptionC a) -> HoistOptionC m a
liftWith :: (Run HoistOptionC -> m a) -> HoistOptionC m a
$cliftWith :: forall (m :: * -> *) a.
Monad m =>
(Run HoistOptionC -> m a) -> HoistOptionC m a
$cp1MonadTransControl :: MonadTrans HoistOptionC
MonadTransControl) via IdentityT
deriving via InterpretPrimC HoistOptionH (HoistOption m) m
instance Carrier m => Carrier (HoistOptionC m)