Skip to content
This repository was archived by the owner on Apr 1, 2025. It is now read-only.

Commit 29fc72f

Browse files
committed
Define a hoisting operation over Term.
1 parent 2388800 commit 29fc72f

File tree

1 file changed

+8
-1
lines changed

1 file changed

+8
-1
lines changed

semantic-core/src/Data/Term.hs

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
1-
{-# LANGUAGE DeriveTraversable, FlexibleInstances, MultiParamTypeClasses, QuantifiedConstraints, StandaloneDeriving, UndecidableInstances #-}
1+
{-# LANGUAGE DeriveTraversable, FlexibleInstances, MultiParamTypeClasses, QuantifiedConstraints, RankNTypes, StandaloneDeriving, UndecidableInstances #-}
22
module Data.Term
33
( Term(..)
4+
, hoistTerm
45
) where
56

67
import Control.Effect.Carrier
@@ -41,3 +42,9 @@ instance RightModule sig => Monad (Term sig) where
4142

4243
instance RightModule sig => Carrier sig (Term sig) where
4344
eff = Term
45+
46+
47+
hoistTerm :: (HFunctor sig, forall g . Functor g => Functor (sig g)) => (forall m x . sig m x -> sig' m x) -> Term sig a -> Term sig' a
48+
hoistTerm f = go
49+
where go (Var v) = Var v
50+
go (Term t) = Term (f (hmap (hoistTerm f) t))

0 commit comments

Comments
 (0)