mirror of
https://github.com/polysemy-research/polysemy.git
synced 2024-09-17 13:37:21 +03:00
commit
175ccc840b
@ -2,6 +2,7 @@
|
||||
|
||||
|
||||
## Unreleased changes
|
||||
* Added `InterpretersFor` as a shorthand for interpreters consuming multiple effects
|
||||
|
||||
## 1.4.0.0 (2020-10-31)
|
||||
|
||||
|
@ -34,7 +34,9 @@ module Polysemy.Internal
|
||||
, usingSem
|
||||
, liftSem
|
||||
, hoistSem
|
||||
, Append
|
||||
, InterpreterFor
|
||||
, InterpretersFor
|
||||
, (.@)
|
||||
, (.@@)
|
||||
) where
|
||||
@ -579,6 +581,11 @@ runM (Sem m) = m $ \z ->
|
||||
{-# INLINE runM #-}
|
||||
|
||||
|
||||
type family Append l r where
|
||||
Append (a ': l) r = a ': (Append l r)
|
||||
Append '[] r = r
|
||||
|
||||
|
||||
------------------------------------------------------------------------------
|
||||
-- | Type synonym for interpreters that consume an effect without changing the
|
||||
-- return value. Offered for user convenience.
|
||||
@ -592,6 +599,12 @@ runM (Sem m) = m $ \z ->
|
||||
type InterpreterFor e r = ∀ a. Sem (e ': r) a -> Sem r a
|
||||
|
||||
|
||||
------------------------------------------------------------------------------
|
||||
-- | Variant of 'InterpreterFor' that takes a list of effects.
|
||||
-- @since (TODO)
|
||||
type InterpretersFor es r = ∀ a. Sem (Append es r) a -> Sem r a
|
||||
|
||||
|
||||
------------------------------------------------------------------------------
|
||||
-- | Some interpreters need to be able to lower down to the base monad (often
|
||||
-- 'IO') in order to function properly --- some good examples of this are
|
||||
|
@ -2,16 +2,16 @@
|
||||
|
||||
{-# OPTIONS_HADDOCK not-home #-}
|
||||
|
||||
module Polysemy.Internal.Bundle where
|
||||
module Polysemy.Internal.Bundle (
|
||||
module Polysemy.Internal.Bundle,
|
||||
Append,
|
||||
) where
|
||||
|
||||
import Data.Proxy
|
||||
import Polysemy
|
||||
import Polysemy.Internal (Append)
|
||||
import Polysemy.Internal.Union
|
||||
|
||||
type family Append l r where
|
||||
Append (a ': l) r = a ': (Append l r)
|
||||
Append '[] r = r
|
||||
|
||||
extendMembership :: forall r r' e. ElemOf e r -> ElemOf e (Append r r')
|
||||
extendMembership Here = Here
|
||||
extendMembership (There e) = There (extendMembership @_ @r' e)
|
||||
|
Loading…
Reference in New Issue
Block a user