diff --git a/semantic-core/src/Analysis/Typecheck.hs b/semantic-core/src/Analysis/Typecheck.hs index acd16813e..7fbaf9d36 100644 --- a/semantic-core/src/Analysis/Typecheck.hs +++ b/semantic-core/src/Analysis/Typecheck.hs @@ -29,7 +29,7 @@ import qualified Data.IntSet as IntSet import Data.List.NonEmpty (nonEmpty) import Data.Loc import qualified Data.Map as Map -import Data.Name +import Data.Name hiding (subst) import qualified Data.Set as Set import Prelude hiding (fail) diff --git a/semantic-core/src/Data/Name.hs b/semantic-core/src/Data/Name.hs index 092d3357d..66c1fb867 100644 --- a/semantic-core/src/Data/Name.hs +++ b/semantic-core/src/Data/Name.hs @@ -14,6 +14,9 @@ module Data.Name , runNaming , NamingC(..) , Incr(..) +, match +, subst +, incr ) where import Control.Applicative @@ -130,3 +133,13 @@ data Incr a = Z | S a deriving (Eq, Foldable, Functor, Ord, Show, Traversable) + +match :: Eq a => a -> a -> Incr a +match x y | x == y = Z + | otherwise = S y + +subst :: a -> Incr a -> a +subst a = incr a id + +incr :: b -> (a -> b) -> Incr a -> b +incr z s = \case { Z -> z ; S a -> s a }