From 70414495f56dad0de5f0410bca3aec1d77cc58f9 Mon Sep 17 00:00:00 2001 From: Rob Rix Date: Wed, 16 Oct 2019 17:35:17 -0400 Subject: [PATCH] :fire: exactMatch. --- src/Rendering/TOC.hs | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/src/Rendering/TOC.hs b/src/Rendering/TOC.hs index 05d4ad793..4db405a83 100644 --- a/src/Rendering/TOC.hs +++ b/src/Rendering/TOC.hs @@ -103,15 +103,14 @@ dedupe = let tuples = sortOn fst . Map.elems . snd . foldl' go (0, Map.empty) in go :: (Int, Map.Map DedupeKey (Int, (Entry, Declaration))) -> (Entry, Declaration) -> (Int, Map.Map DedupeKey (Int, (Entry, Declaration))) - go (index, m) x | Just (_, similar@(_, similarDecl)) <- Map.lookup (dedupeKey (snd x)) m - = if exactMatch similar x + go (index, m) x | Just (_, (_, similarDecl)) <- Map.lookup (dedupeKey (snd x)) m + = if similarDecl == snd x then (succ index, m) else (succ index, Map.insert (dedupeKey similarDecl) (index, (Replaced, similarDecl)) m) | otherwise = (succ index, Map.insert (dedupeKey (snd x)) (index, x) m) dedupeKey decl = DedupeKey (toCategoryName decl, T.toLower (declarationIdentifier decl)) - exactMatch = (==) `on` snd -- | Construct a description of an 'Entry'. entryChange :: Entry -> Text