mirror of
https://github.com/github/semantic.git
synced 2025-01-06 23:46:21 +03:00
Define a function computing the table of contents for a term.
This commit is contained in:
parent
8941b23246
commit
8fdd1bdf0d
@ -150,6 +150,14 @@ tableOfContentsBy selector = fromMaybe [] . iter diffAlgebra . fmap (Just . fmap
|
|||||||
| otherwise = fold r
|
| otherwise = fold r
|
||||||
patchEntry = these Deleted Inserted (const Replaced) . unPatch
|
patchEntry = these Deleted Inserted (const Replaced) . unPatch
|
||||||
|
|
||||||
|
termTableOfContentsBy :: Traversable f
|
||||||
|
=> (forall b. TermF f annotation b -> Maybe a)
|
||||||
|
-> Term f annotation
|
||||||
|
-> [Entry a]
|
||||||
|
termTableOfContentsBy selector = cata termAlgebra
|
||||||
|
where termAlgebra r | Just a <- selector r = [Unchanged a]
|
||||||
|
| otherwise = fold r
|
||||||
|
|
||||||
dedupe :: HasField fields (Maybe Declaration) => [Entry (Record fields)] -> [Entry (Record fields)]
|
dedupe :: HasField fields (Maybe Declaration) => [Entry (Record fields)] -> [Entry (Record fields)]
|
||||||
dedupe = foldl' go []
|
dedupe = foldl' go []
|
||||||
where go xs x | (_, _:_) <- find (exactMatch `on` entryPayload) x xs = xs
|
where go xs x | (_, _:_) <- find (exactMatch `on` entryPayload) x xs = xs
|
||||||
|
Loading…
Reference in New Issue
Block a user