{-# LANGUAGE TemplateHaskell #-}
module Polysemy.Embed
(
Embed (..)
, embed
, runEmbedded
) where
import Polysemy
runEmbedded
:: forall m1 m2 r a
. Member (Embed m2) r
=> (forall x. m1 x -> m2 x)
-> Sem (Embed m1 ': r) a
-> Sem r a
runEmbedded :: forall (m1 :: * -> *) (m2 :: * -> *) (r :: EffectRow) a.
Member (Embed m2) r =>
(forall x. m1 x -> m2 x) -> Sem (Embed m1 : r) a -> Sem r a
runEmbedded forall x. m1 x -> m2 x
f = forall (e :: (* -> *) -> * -> *) (r :: EffectRow) a.
FirstOrder e "interpret" =>
(forall (rInitial :: EffectRow) x. e (Sem rInitial) x -> Sem r x)
-> Sem (e : r) a -> Sem r a
interpret forall a b. (a -> b) -> a -> b
$ forall (m :: * -> *) (r :: EffectRow) a.
Member (Embed m) r =>
m a -> Sem r a
embed forall b c a. (b -> c) -> (a -> b) -> a -> c
. forall x. m1 x -> m2 x
f forall b c a. (b -> c) -> (a -> b) -> a -> c
. forall (m :: * -> *) a (z :: * -> *). Embed m z a -> m a
unEmbed
{-# INLINE runEmbedded #-}