mirror of
https://github.com/github/semantic.git
synced 2024-12-31 19:20:19 +03:00
Define a function computing the maximum metavariable bound in a diff.
This commit is contained in:
parent
7ada1dea20
commit
3e2c883b3a
@ -52,6 +52,12 @@ freeMetavariables = cata $ \ diff -> case diff of
|
|||||||
Var v -> Set.singleton v
|
Var v -> Set.singleton v
|
||||||
Patch patch -> foldMap fold patch
|
Patch patch -> foldMap fold patch
|
||||||
|
|
||||||
|
maxBoundMetavariable :: (Foldable syntax, Functor syntax) => Diff syntax ann -> Maybe Metavar
|
||||||
|
maxBoundMetavariable = cata $ \ diff -> case diff of
|
||||||
|
Copy bindings _ -> foldr (max . Just . fst) Nothing bindings
|
||||||
|
Var _ -> Nothing
|
||||||
|
Patch patch -> foldr (max . foldr max Nothing) Nothing patch
|
||||||
|
|
||||||
|
|
||||||
newtype Env a = Env { unEnv :: [(Metavar, a)] }
|
newtype Env a = Env { unEnv :: [(Metavar, a)] }
|
||||||
deriving (Eq, Foldable, Functor, Monoid, Ord, Show, Traversable)
|
deriving (Eq, Foldable, Functor, Monoid, Ord, Show, Traversable)
|
||||||
|
Loading…
Reference in New Issue
Block a user