polysemy-1.7.1.0: Higher-order, low-boilerplate free monads.
Safe HaskellNone
LanguageHaskell2010

Polysemy.Embed

Synopsis

Effect

newtype Embed m (z :: Type -> Type) a where Source #

An effect which allows a regular Monad m into the Sem ecosystem. Monadic actions in m can be lifted into Sem via embed.

For example, you can use this effect to lift IO actions directly into Sem:

embed (putStrLn "hello") :: Member (Embed IO) r => Sem r ()

That being said, you lose out on a significant amount of the benefits of Sem by using embed directly in application code; doing so will tie your application code directly to the underlying monad, and prevent you from interpreting it differently. For best results, only use Embed in your effect interpreters.

Consider using trace and traceToIO as a substitute for using putStrLn directly.

Since: 1.0.0.0

Constructors

Embed 

Fields

Instances

Instances details
MakeLaw e '[Embed IO] Source # 
Instance details

Defined in Polysemy.Law

Methods

mkLaw :: (Eq a, Show a, Citizen res (Sem (e ': '[Embed IO]) a)) => String -> res -> String -> res -> Law e '[Embed IO] Source #

Actions

embed :: Member (Embed m) r => m a -> Sem r a Source #

Embed a monadic action m in Sem.

Since: 1.0.0.0

Interpretations

runEmbedded :: forall m1 m2 r a. Member (Embed m2) r => (forall x. m1 x -> m2 x) -> Sem (Embed m1 ': r) a -> Sem r a Source #

Given a natural transform from m1 to m2 run a Embed m1 effect by transforming it into a Embed m2 effect.

Since: 1.0.0.0