From dd4c6ed8a53e4f4f3d44de6870d3ba5e07cbb9cd Mon Sep 17 00:00:00 2001
From: Rob Rix <robrix@github.com>
Date: Wed, 16 Oct 2019 22:23:04 -0400
Subject: [PATCH] Rename Entry to ChangeType.

---
 src/Rendering/TOC.hs | 16 ++++++++--------
 1 file changed, 8 insertions(+), 8 deletions(-)

diff --git a/src/Rendering/TOC.hs b/src/Rendering/TOC.hs
index 0cf09cab3..8015d6e7c 100644
--- a/src/Rendering/TOC.hs
+++ b/src/Rendering/TOC.hs
@@ -5,7 +5,7 @@ module Rendering.TOC
 , TOCSummary(..)
 , isValidSummary
 , declaration
-, Entry(..)
+, ChangeType(..)
 , tableOfContentsBy
 , dedupe
 ) where
@@ -50,7 +50,7 @@ instance ToJSON TOCSummary where
   toJSON ErrorSummary{..} = object [ "error" .= message, "span" .= span, "language" .= language ]
 
 -- | An entry in a table of contents.
-data Entry
+data ChangeType
   = Changed  -- ^ An entry for a node containing changes.
   | Inserted -- ^ An entry for a change occurring inside an 'Insert' 'Patch'.
   | Deleted  -- ^ An entry for a change occurring inside a 'Delete' 'Patch'.
@@ -70,7 +70,7 @@ declaration (In annotation _) = annotation
 tableOfContentsBy :: (Foldable f, Functor f)
                   => (forall b. TermF f ann b -> Maybe a) -- ^ A function mapping relevant nodes onto values in Maybe.
                   -> Diff f ann ann                       -- ^ The diff to compute the table of contents for.
-                  -> [(Entry, a)]                         -- ^ A list of entries for relevant changed nodes in the diff.
+                  -> [(ChangeType, a)]                         -- ^ A list of entries for relevant changed nodes in the diff.
 tableOfContentsBy selector = fromMaybe [] . cata (\ r -> case r of
   Patch patch -> (pure . patchEntry <$> bicrosswalk selector selector patch) <> bifoldMap fold fold patch <> Just []
   Merge (In (_, ann2) r) -> case (selector (In ann2 r), fold r) of
@@ -84,7 +84,7 @@ data DedupeKey = DedupeKey {-# UNPACK #-} !T.Text {-# UNPACK #-} !T.Text
 
 data Dedupe = Dedupe
   { index :: {-# UNPACK #-} !Int
-  , entry :: {-# UNPACK #-} !Entry
+  , entry :: {-# UNPACK #-} !ChangeType
   , decl  :: {-# UNPACK #-} !Declaration
   }
 
@@ -95,7 +95,7 @@ data Dedupe = Dedupe
 -- 2. Two similar entries (defined by a case insensitive comparison of their
 --    identifiers) are in the list.
 --    Action: Combine them into a single Replaced entry.
-dedupe :: [(Entry, Declaration)] -> [(Entry, Declaration)]
+dedupe :: [(ChangeType, Declaration)] -> [(ChangeType, Declaration)]
 dedupe = map (entry &&& 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)
@@ -105,8 +105,8 @@ dedupe = map (entry &&& decl) . sortOn index . Map.elems . foldl' go Map.empty .
 
   dedupeKey (Declaration kind ident _ _ _) = DedupeKey (formatKind kind) (T.toLower ident)
 
--- | Construct a description of an 'Entry'.
-formatEntry :: Entry -> Text
+-- | Construct a description of an 'ChangeType'.
+formatEntry :: ChangeType -> Text
 formatEntry entry = case entry of
   Changed  -> "modified"
   Deleted  -> "removed"
@@ -114,7 +114,7 @@ formatEntry entry = case entry of
   Replaced -> "modified"
 
 -- | Construct a 'TOCSummary' from a node annotation and a change type label.
-recordSummary :: Entry -> Declaration -> TOCSummary
+recordSummary :: ChangeType -> Declaration -> TOCSummary
 recordSummary entry decl@(Declaration kind text _ srcSpan language)
   | ErrorDeclaration <- kind = ErrorSummary text srcSpan language
   | otherwise                = TOCSummary (formatKind kind) (formatIdentifier decl) srcSpan (formatEntry entry)