mirror of
https://github.com/github/semantic.git
synced 2024-12-22 22:31:36 +03:00
Combine the gram at each node in.
This commit is contained in:
parent
192366d5ad
commit
1b02940e26
@ -129,9 +129,12 @@ termCostDecorator :: (Prologue.Foldable f, Functor f) => TermDecorator f a Cost
|
||||
termCostDecorator c = 1 + sum (cost <$> tailF c)
|
||||
|
||||
pqGramDecorator :: (Prologue.Foldable f, Functor f) => (forall b. CofreeF f (Record a) b -> label) -> Int -> Int -> TermDecorator f a (Gram label, DList.DList (Gram label))
|
||||
pqGramDecorator getLabel p q c@(a :< s) = (Gram [] [ Just (getLabel c) ], foldMap (Prologue.snd . childGrams) s)
|
||||
where childGrams :: HasField fields (Gram label, DList.DList (Gram label)) => Record fields -> (Gram label, DList.DList (Gram label))
|
||||
childGrams = getField
|
||||
pqGramDecorator getLabel p q c@(a :< s) = (Gram [] [ Just label ], foldMap (childGrams label) s)
|
||||
where childGrams :: HasField fields (Gram label, DList.DList (Gram label)) => label -> Record fields -> DList.DList (Gram label)
|
||||
childGrams label record = let (child, grandchildren) = getField record in
|
||||
DList.singleton (prependParent label child) <> grandchildren
|
||||
prependParent label gram = gram { stem = Just label : stem gram }
|
||||
label = getLabel c
|
||||
|
||||
-- | The sum of the node count of the diff’s patches.
|
||||
diffCostWithCachedTermCosts :: HasField fields Cost => Diff leaf (Record fields) -> Integer
|
||||
|
Loading…
Reference in New Issue
Block a user