Skip to content

Commit 5508025

Browse files
committed
Render.Frame: renderExpr: refactor
1 parent 8a1111c commit 5508025

File tree

1 file changed

+13
-7
lines changed

1 file changed

+13
-7
lines changed

src/Nix/Render/Frame.hs

Lines changed: 13 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -154,19 +154,25 @@ renderExpr
154154
renderExpr _level longLabel shortLabel e@(Ann _ x) = do
155155
opts :: Options <- asks (view hasLens)
156156
let
157+
lvl :: Verbosity
158+
lvl = verbose opts
159+
157160
expr :: NExpr
158161
expr = stripAnnotation e
159162

160-
rendered
161-
| verbose opts >= DebugInfo = pretty $ PS.ppShow expr
162-
| verbose opts >= Chatty = prettyNix expr
163-
| otherwise = prettyNix (Fix (Fix (NSym "<?>") <$ x))
163+
concise = prettyNix $ Fix $ Fix (NSym "<?>") <$ x
164+
165+
chatty =
166+
bool
167+
(pretty $ PS.ppShow expr)
168+
(prettyNix expr)
169+
(lvl == Chatty)
164170

165171
pure $
166172
bool
167-
(pretty shortLabel <> fillSep [": ", rendered])
168-
(vsep [pretty (longLabel <> ":\n>>>>>>>>"), indent 2 rendered, "<<<<<<<<"])
169-
(verbose opts >= Chatty)
173+
(pretty shortLabel <> fillSep [": ", concise])
174+
(vsep [pretty (longLabel <> ":\n>>>>>>>>"), indent 2 chatty, "<<<<<<<<"])
175+
(lvl >= Chatty)
170176

171177
renderValueFrame
172178
:: forall e t f m ann

0 commit comments

Comments
 (0)