1
1
mirror of https://github.com/github/semantic.git synced 2025-01-01 19:55:34 +03:00

Define a helper to interpret a Term in some other eff-Carrier.

This commit is contained in:
Rob Rix 2019-07-17 11:57:44 -04:00
parent 1c85529a33
commit a1ee196d76
No known key found for this signature in database
GPG Key ID: F188A01508EA1CF7

View File

@ -4,6 +4,7 @@ module Data.Term
, Syntax(..)
, iter
, cata
, interpret
) where
import Control.Effect.Carrier
@ -86,3 +87,7 @@ cata :: Syntax sig
-> Term sig x
-> b
cata var alg k h = getConst . iter (coerce var) (Const . alg) (coerce k) (Const . h)
interpret :: (Carrier sig m, Member eff sig, Syntax eff) => (forall a . Incr () (m a) -> m (Incr () (m a))) -> (a -> m b) -> Term eff a -> m b
interpret = iter id send