polysemy- Higher-order, low-boilerplate, zero-cost free monads.

Safe HaskellNone





newtype Tagged k e m a where Source #

An effect for annotating effects and disambiguating identical effects.


Tagged :: forall k e m a. e m a -> Tagged k e m a 


tag :: forall k e r a. Member (Tagged k e) r => Sem (e ': r) a -> Sem r a Source #

Tag uses of an effect, effectively gaining access to the tagged effect locally.

This may be used to create tagged- variants of regular actions.

For example:

taggedLocal :: forall k i r a
             . Member (Tagged k (Reader i)) r
            => (i -> i)
            -> Sem r a
            -> Sem r a
taggedLocal f m =
  tag k (Reader i) $ local @i f (raise m)

tagged :: forall k e r a. Sem (e ': r) a -> Sem (Tagged k e ': r) a Source #

A reinterpreting version of tag.


untag :: forall k e r a. Sem (Tagged k e ': r) a -> Sem (e ': r) a Source #

Run a Tagged k e effect through reinterpreting it to e

retag :: forall k1 k2 e r a. Member (Tagged k2 e) r => Sem (Tagged k1 e ': r) a -> Sem r a Source #

Transform a Tagged k1 e effect into a Tagged k2 e effect