From 5b452bf4715f072788d435c3fe0f493466c4256f Mon Sep 17 00:00:00 2001 From: Rob Rix Date: Wed, 16 Oct 2019 22:29:17 -0400 Subject: [PATCH] Rename the entry field of Dedupe to change. --- src/Rendering/TOC.hs | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/src/Rendering/TOC.hs b/src/Rendering/TOC.hs index bff021c9f..2a2686394 100644 --- a/src/Rendering/TOC.hs +++ b/src/Rendering/TOC.hs @@ -1,4 +1,4 @@ -{-# LANGUAGE DerivingVia, RankNTypes, ScopedTypeVariables, TupleSections #-} +{-# LANGUAGE DerivingVia, DuplicateRecordFields, RankNTypes, ScopedTypeVariables, TupleSections #-} module Rendering.TOC ( diffTOC , Summaries(..) @@ -83,9 +83,9 @@ data DedupeKey = DedupeKey {-# UNPACK #-} !T.Text {-# UNPACK #-} !T.Text deriving (Eq, Ord) data Dedupe = Dedupe - { index :: {-# UNPACK #-} !Int - , entry :: {-# UNPACK #-} !Change - , decl :: {-# UNPACK #-} !Declaration + { index :: {-# UNPACK #-} !Int + , change :: {-# UNPACK #-} !Change + , decl :: {-# UNPACK #-} !Declaration } -- Dedupe entries in a final pass. This catches two specific scenarios with @@ -96,11 +96,11 @@ data Dedupe = Dedupe -- identifiers) are in the list. -- Action: Combine them into a single Replaced entry. dedupe :: [(Change, Declaration)] -> [(Change, Declaration)] -dedupe = map (entry &&& decl) . sortOn index . Map.elems . foldl' go Map.empty . zipWith (uncurry . Dedupe) [0..] where +dedupe = map ((change :: Dedupe -> Change) &&& decl) . sortOn index . Map.elems . foldl' go Map.empty . zipWith (uncurry . Dedupe) [0..] where go m d@(Dedupe _ _ decl) = let key = dedupeKey decl in case Map.lookup key m of Just (Dedupe _ _ similar) | similar == decl -> m - | otherwise -> Map.insert key d { entry = Replaced, decl = similar } m + | otherwise -> Map.insert key d { change = Replaced, decl = similar } m _ -> Map.insert key d m dedupeKey (Declaration kind ident _ _ _) = DedupeKey (formatKind kind) (T.toLower ident)