From d678a32fcaf7ab67c7760df1beb8f212b7a72e16 Mon Sep 17 00:00:00 2001 From: piegames Date: Thu, 8 Aug 2024 10:27:53 +0200 Subject: [PATCH] Apply suggestions from code review Co-authored-by: Silvan Mosberger --- main/Main.hs | 4 ++-- src/Nixfmt/Types.hs | 18 ++---------------- 2 files changed, 4 insertions(+), 18 deletions(-) diff --git a/main/Main.hs b/main/Main.hs index da448598..4f7094c7 100644 --- a/main/Main.hs +++ b/main/Main.hs @@ -42,7 +42,7 @@ data Nixfmt = Nixfmt width :: Width, check :: Bool, quiet :: Bool, - pure_ :: Bool, + strict :: Bool, verify :: Bool, ast :: Bool } @@ -60,7 +60,7 @@ options = &= help (addDefaultHint defaultWidth "Maximum width in characters"), check = False &= help "Check whether files are formatted without modifying them", quiet = False &= help "Do not report errors", - pure_ = False &= help "Ignore all line breaks in the input formatting except for empty lines", + strict = False &= help "Enable a stricter formatting mode that isn't influenced as much by how the input is formatted", verify = False &= help diff --git a/src/Nixfmt/Types.hs b/src/Nixfmt/Types.hs index 588a263a..812670d0 100644 --- a/src/Nixfmt/Types.hs +++ b/src/Nixfmt/Types.hs @@ -85,13 +85,7 @@ data Ann a = Ann deriving (Show) removeLineInfo :: Ann a -> Ann a -removeLineInfo (Ann{preTrivia, value, trailComment}) = - Ann - { preTrivia, - sourceLine = MP.pos1, - value, - trailComment - } +removeLineInfo ann = ann { sourceLine = MP.pos1 } -- | An annotated value without any trivia or trailing comment pattern LoneAnn :: a -> Ann a @@ -127,15 +121,7 @@ data Item a Comments Trivia deriving (Foldable, Show) -newtype Items a = Items {unItems :: [Item a]} - -mapItems :: (a -> a) -> Items a -> Items a -mapItems f = Items . Prelude.map f' . unItems - where - f' = \case - (Item a) -> Item $ f a - (Comments t) -> Comments t - +newtype Items a = Items {unItems :: [Item a]} derive Functor instance (Eq a) => Eq (Items a) where (==) = (==) `on` concatMap Data.Foldable.toList . unItems