mirror of
https://github.com/github/semantic.git
synced 2024-12-22 14:21:31 +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
|
||||
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)] }
|
||||
deriving (Eq, Foldable, Functor, Monoid, Ord, Show, Traversable)
|
||||
|
Loading…
Reference in New Issue
Block a user