Skip to content

Commit

Permalink
Apply suggestions from code review
Browse files Browse the repository at this point in the history
Co-authored-by: Silvan Mosberger <[email protected]>
  • Loading branch information
piegamesde and infinisil authored Aug 8, 2024
1 parent 0447bde commit d678a32
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 18 deletions.
4 changes: 2 additions & 2 deletions main/Main.hs
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ data Nixfmt = Nixfmt
width :: Width,
check :: Bool,
quiet :: Bool,
pure_ :: Bool,
strict :: Bool,
verify :: Bool,
ast :: Bool
}
Expand All @@ -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
Expand Down
18 changes: 2 additions & 16 deletions src/Nixfmt/Types.hs
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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

Expand Down

0 comments on commit d678a32

Please sign in to comment.