1
1
mirror of https://github.com/github/semantic.git synced 2024-11-28 18:23:44 +03:00

Reformat dedupe.

This commit is contained in:
Rob Rix 2019-10-17 22:03:02 -04:00
parent fbfcdd8985
commit 8a3c49f3df
No known key found for this signature in database
GPG Key ID: F188A01508EA1CF7

View File

@ -101,7 +101,12 @@ data Dedupe = Dedupe
-- identifiers) are in the list. -- identifiers) are in the list.
-- Action: Combine them into a single Replaced entry. -- Action: Combine them into a single Replaced entry.
dedupe :: [(Change, Declaration)] -> [(Change, Declaration)] dedupe :: [(Change, Declaration)] -> [(Change, Declaration)]
dedupe = map ((change :: Dedupe -> Change) &&& decl) . sortOn index . Map.elems . foldl' go Map.empty . zipWith (uncurry . Dedupe) [0..] where dedupe
= map ((change :: Dedupe -> Change) &&& decl) -- extract the changes and decls
. sortOn index -- after sorting
. Map.elems -- the elements of the map
. foldl' go Map.empty -- produced by deduping
. zipWith (uncurry . Dedupe) [0..] where -- the indexed inputs
go m d@(Dedupe _ _ decl) = let key = dedupeKey decl in case Map.lookup key m of go m d@(Dedupe _ _ decl) = let key = dedupeKey decl in case Map.lookup key m of
Just (Dedupe _ _ similar) Just (Dedupe _ _ similar)
| similar == decl -> m | similar == decl -> m