{-# LANGUAGE RankNTypes #-}
module Control.Effect.Lift
(
Lift(..)
, sendM
, sendIO
, liftWith
, Algebra
, 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 :: forall (n :: * -> *) (sig :: (* -> *) -> * -> *) (m :: * -> *) a.
(Has (Lift n) sig m, Functor n) =>
n a -> m a
sendM n a
m = (forall (ctx :: * -> *).
Functor ctx =>
Handler ctx m n -> ctx () -> n (ctx a))
-> m a
forall (n :: * -> *) (sig :: (* -> *) -> * -> *) (m :: * -> *) a.
Has (Lift n) sig m =>
(forall (ctx :: * -> *).
Functor ctx =>
Handler ctx m n -> ctx () -> n (ctx a))
-> m a
liftWith (\ Handler ctx m n
_ 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)
{-# INLINE sendM #-}
sendIO :: Has (Lift IO) sig m => IO a -> m a
sendIO :: forall (sig :: (* -> *) -> * -> *) (m :: * -> *) a.
Has (Lift IO) sig m =>
IO a -> m a
sendIO = IO a -> m a
forall (n :: * -> *) (sig :: (* -> *) -> * -> *) (m :: * -> *) a.
(Has (Lift n) sig m, Functor n) =>
n a -> m a
sendM
{-# INLINE sendIO #-}
liftWith
:: Has (Lift n) sig m
=> (forall ctx . Functor ctx => Handler ctx m n -> ctx () -> n (ctx a))
-> m a
liftWith :: forall (n :: * -> *) (sig :: (* -> *) -> * -> *) (m :: * -> *) a.
Has (Lift n) sig m =>
(forall (ctx :: * -> *).
Functor ctx =>
Handler ctx m n -> ctx () -> n (ctx a))
-> m a
liftWith forall (ctx :: * -> *).
Functor ctx =>
Handler ctx m n -> ctx () -> 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 =>
Handler ctx m n -> ctx () -> n (ctx a))
-> Lift n m a
forall (m :: * -> *) (sig :: * -> *) a.
(forall (ctx :: * -> *).
Functor ctx =>
Handler ctx m sig -> ctx () -> sig (ctx a))
-> Lift sig m a
LiftWith forall (ctx :: * -> *).
Functor ctx =>
Handler ctx m n -> ctx () -> n (ctx a)
with)
{-# INLINE liftWith #-}