{-# LANGUAGE RankNTypes #-}
module Control.Effect.Lift
(
Lift(..)
, sendM
, liftWith
, Algebra
, Effect
, Has
, run
) where
import Control.Algebra
import Control.Effect.Lift.Internal (Lift(..))
sendM :: (Has (Lift n) sig m, Functor n) => n a -> m a
sendM :: n a -> m a
sendM m :: n a
m = Lift n m a -> m a
forall (eff :: (* -> *) -> * -> *) (sig :: (* -> *) -> * -> *)
(m :: * -> *) a.
(Member eff sig, Algebra sig m) =>
eff m a -> m a
send ((forall (ctx :: * -> *).
Functor ctx =>
ctx () -> (forall a. ctx (m a) -> n (ctx a)) -> n (ctx a))
-> (a -> m a) -> Lift n m a
forall (sig :: * -> *) (m :: * -> *) k a.
(forall (ctx :: * -> *).
Functor ctx =>
ctx () -> (forall a. ctx (m a) -> sig (ctx a)) -> sig (ctx a))
-> (a -> m k) -> Lift sig m k
LiftWith (\ ctx :: ctx ()
ctx _ -> (a -> ctx () -> ctx a
forall (f :: * -> *) a b. Functor f => a -> f b -> f a
<$ ctx ()
ctx) (a -> ctx a) -> n a -> n (ctx a)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> n a
m) a -> m a
forall (f :: * -> *) a. Applicative f => a -> f a
pure)
liftWith
:: Has (Lift n) sig m
=> (forall ctx . Functor ctx => ctx () -> (forall a . ctx (m a) -> n (ctx a)) -> n (ctx a))
-> m a
liftWith :: (forall (ctx :: * -> *).
Functor ctx =>
ctx () -> (forall a. ctx (m a) -> n (ctx a)) -> n (ctx a))
-> m a
liftWith with :: forall (ctx :: * -> *).
Functor ctx =>
ctx () -> (forall a. ctx (m a) -> n (ctx a)) -> n (ctx a)
with = Lift n m a -> m a
forall (eff :: (* -> *) -> * -> *) (sig :: (* -> *) -> * -> *)
(m :: * -> *) a.
(Member eff sig, Algebra sig m) =>
eff m a -> m a
send ((forall (ctx :: * -> *).
Functor ctx =>
ctx () -> (forall a. ctx (m a) -> n (ctx a)) -> n (ctx a))
-> (a -> m a) -> Lift n m a
forall (sig :: * -> *) (m :: * -> *) k a.
(forall (ctx :: * -> *).
Functor ctx =>
ctx () -> (forall a. ctx (m a) -> sig (ctx a)) -> sig (ctx a))
-> (a -> m k) -> Lift sig m k
LiftWith forall (ctx :: * -> *).
Functor ctx =>
ctx () -> (forall a. ctx (m a) -> n (ctx a)) -> n (ctx a)
with a -> m a
forall (f :: * -> *) a. Applicative f => a -> f a
pure)