@@ -212,48 +212,49 @@ exprFNixDoc :: NExprF (NixDoc ann) -> NixDoc ann
212212exprFNixDoc = \ case
213213 NConstant atom -> prettyAtom atom
214214 NStr str -> simpleExpr $ prettyString str
215- NList [] -> simpleExpr $ lbracket <> rbracket
215+ NList [] -> simpleExpr " [] "
216216 NList xs ->
217217 simpleExpr $
218218 group $
219219 nest 2 $
220220 vsep $
221221 concat
222- [ [lbracket ]
222+ [ [" [ " ]
223223 , wrapParens appOpNonAssoc <$>
224224 xs
225- , [rbracket]]
226- NSet NNonRecursive [] -> simpleExpr $ lbrace <> rbrace
225+ , [" ]" ]
226+ ]
227+ NSet NNonRecursive [] -> simpleExpr " {}"
227228 NSet NNonRecursive xs ->
228229 simpleExpr $
229230 group $
230231 nest 2 $
231232 vsep $
232233 concat
233- [ [lbrace ]
234+ [ [" { " ]
234235 , prettyBind <$> xs
235- , [rbrace ]
236+ , [" } " ]
236237 ]
237- NSet NRecursive [] -> simpleExpr $ recPrefix <> lbrace <> rbrace
238+ NSet NRecursive [] -> simpleExpr " rec {} "
238239 NSet NRecursive xs ->
239240 simpleExpr $
240241 group $
241242 nest 2 $
242243 vsep $
243244 concat
244- [ [recPrefix <> lbrace ]
245+ [ [" rec { " ]
245246 , prettyBind <$> xs
246- , [rbrace ]
247+ , [" } " ]
247248 ]
248249 NAbs args body ->
249250 leastPrecedence $
250251 nest 2 $
251252 vsep
252- [ prettyParams args <> colon
253+ [ prettyParams args <> " : "
253254 , withoutParens body
254255 ]
255256 NBinary NApp fun arg ->
256- mkNixDoc appOp (wrapParens appOp fun <> space <> wrapParens appOpNonAssoc arg)
257+ mkNixDoc appOp (wrapParens appOp fun <> " " <> wrapParens appOpNonAssoc arg)
257258 NBinary op r1 r2 ->
258259 mkNixDoc opInfo $
259260 hsep
@@ -321,8 +322,6 @@ exprFNixDoc = \case
321322 vsep
322323 [" assert " <> withoutParens cond <> semi, align $ withoutParens body]
323324 NSynHole name -> simpleExpr $ pretty (" ^" <> unpack name)
324- where
325- recPrefix = " rec" <> space
326325
327326valueToExpr :: forall t f m . MonadDataContext f m => NValue t f m -> NExpr
328327valueToExpr = iterNValue (\ _ _ -> thk) phi
@@ -381,16 +380,17 @@ prettyNThunk
381380 )
382381 => t
383382 -> m (Doc ann )
384- prettyNThunk t = do
385- let ps = citations @ m @ (NValue t f m ) @ t t
386- v' <- prettyNValue <$> dethunk t
387- pure
388- $ fillSep
389- [ v'
390- , indent 2 $
391- parens $
392- mconcat $ " thunk from: " : fmap (prettyOriginExpr . _originExpr) ps
393- ]
383+ prettyNThunk t =
384+ do
385+ let ps = citations @ m @ (NValue t f m ) @ t t
386+ v' <- prettyNValue <$> dethunk t
387+ pure
388+ $ fillSep
389+ [ v'
390+ , indent 2 $
391+ parens $
392+ mconcat $ " thunk from: " : fmap (prettyOriginExpr . _originExpr) ps
393+ ]
394394
395395-- | This function is used only by the testing code.
396396printNix :: forall t f m . MonadDataContext f m => NValue t f m -> String
@@ -403,18 +403,18 @@ printNix = iterNValue (\_ _ -> thk) phi
403403 phi (NVStr' ns) = show $ stringIgnoreContext ns
404404 phi (NVList' l ) = " [ " <> unwords l <> " ]"
405405 phi (NVSet' s _) =
406- " { "
407- <> concat
408- [ check (unpack k) <> " = " <> v <> " ; "
409- | (k, v) <- sort $ toList s
410- ]
411- <> " }"
406+ " { " <>
407+ concat
408+ [ check (unpack k) <> " = " <> v <> " ; "
409+ | (k, v) <- sort $ toList s
410+ ] <> " }"
412411 where
413- check v = fromMaybe
414- v
415- ( fmap (surround . show ) (readMaybe v :: Maybe Int )
416- <|> fmap (surround . show ) (readMaybe v :: Maybe Float )
417- )
412+ check v =
413+ fromMaybe
414+ v
415+ (fmap (surround . show ) (readMaybe v :: Maybe Int )
416+ <|> fmap (surround . show ) (readMaybe v :: Maybe Float )
417+ )
418418 where surround s = " \" " <> s <> " \" "
419419 phi NVClosure' {} = " <<lambda>>"
420420 phi (NVPath' fp ) = fp
0 commit comments