Skip to content

Commit 24683c3

Browse files
committed
Pretty: refactor
1 parent 1a3c8e2 commit 24683c3

File tree

1 file changed

+7
-6
lines changed

1 file changed

+7
-6
lines changed

src/Nix/Pretty.hs

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -287,13 +287,9 @@ exprFNixDoc = \case
287287
, align ("else " <> withoutParens falseBody)
288288
]
289289
NWith scope body ->
290-
leastPrecedence $
291-
vsep
292-
["with " <> withoutParens scope <> ";", align $ withoutParens body]
290+
prettyAddScope "with " scope body
293291
NAssert cond body ->
294-
leastPrecedence $
295-
vsep
296-
["assert " <> withoutParens cond <> ";", align $ withoutParens body]
292+
prettyAddScope "assert " cond body
297293
NSynHole name -> simpleExpr $ pretty ("^" <> name)
298294
where
299295
prettyContainer h f t c =
@@ -302,6 +298,11 @@ exprFNixDoc = \case
302298
(const $ simpleExpr $ group $ nest 2 $ vsep $ [h] <> (f <$> c) <> [t])
303299
c
304300

301+
prettyAddScope h c b =
302+
leastPrecedence $
303+
vsep
304+
[h <> withoutParens c <> ";", align $ withoutParens b]
305+
305306

306307
valueToExpr :: forall t f m . MonadDataContext f m => NValue t f m -> NExpr
307308
valueToExpr = iterNValue (\_ _ -> thk) phi

0 commit comments

Comments
 (0)