add raise

This commit is contained in:
Sandy Maguire 2017-05-05 20:08:14 -06:00 committed by Tomáš Janoušek
parent 84762417b7
commit 9f6ff9f67d
2 changed files with 15 additions and 0 deletions

View File

@ -22,6 +22,9 @@ module Control.Monad.Freer
-- ** Sending Arbitrary Effect
, send
-- ** Lifting Effect Stacks
, raise
-- * Handling Effects
, Arr
, run
@ -47,6 +50,7 @@ import Control.Monad.Freer.Internal
, Members
, handleRelay
, handleRelayS
, raise
, run
, runM
, send

View File

@ -53,6 +53,9 @@ module Control.Monad.Freer.Internal
-- ** Sending Arbitrary Effect
, send
-- ** Lifting Effect Stacks
, raise
-- * Handling Effects
, run
, runM
@ -268,6 +271,14 @@ interpose ret h = loop
where
k = qComp q loop
-- | Embeds a less-constrained 'Eff' into a more-constrained one. Analogous to
-- MTL's 'lift'.
raise :: Eff effs a -> Eff (e ': effs) a
raise = loop
where
loop (Val x) = pure x
loop (E u q) = E (weaken u) . tsingleton $ qComp q loop
--------------------------------------------------------------------------------
-- Nondeterministic Choice --
--------------------------------------------------------------------------------