mirror of
https://github.com/lexi-lambda/freer-simple.git
synced 2024-09-11 08:05:51 +03:00
Add the subsume handler for deduplicating effects
This commit is contained in:
parent
9b3ca1df06
commit
3c09ca2c6d
@ -217,6 +217,7 @@ module Control.Monad.Freer
|
||||
-- *** Basic effect handlers
|
||||
, interpret
|
||||
, interpose
|
||||
, subsume
|
||||
-- *** Derived effect handlers
|
||||
, reinterpret
|
||||
, reinterpret2
|
||||
@ -265,6 +266,12 @@ interpose :: forall eff effs. Member eff effs => (eff ~> Eff effs) -> Eff effs ~
|
||||
interpose f = interposeWith (\e -> (f e >>=))
|
||||
{-# INLINE interpose #-}
|
||||
|
||||
-- | Interprets an effect in terms of another identical effect. This can be used
|
||||
-- to eliminate duplicate effects.
|
||||
subsume :: forall eff effs. Member eff effs => Eff (eff ': effs) ~> Eff effs
|
||||
subsume = interpret send
|
||||
{-# INLINE subsume #-}
|
||||
|
||||
-- | Like 'interpret', but instead of removing the interpreted effect @f@,
|
||||
-- reencodes it in some new effect @g@.
|
||||
reinterpret :: forall f g effs. (f ~> Eff (g ': effs)) -> Eff (f ': effs) ~> Eff (g ': effs)
|
||||
|
Loading…
Reference in New Issue
Block a user