From 610fc3c780812ce8742e74a6408d10c182f45ada Mon Sep 17 00:00:00 2001 From: Luca Bruno Date: Mon, 7 Jul 2014 17:29:55 +0200 Subject: [PATCH] Use pretty util functions for filling paragraphs --- Nix/Pretty.hs | 14 ++++++-------- 1 file changed, 6 insertions(+), 8 deletions(-) diff --git a/Nix/Pretty.hs b/Nix/Pretty.hs index 4177a34..8c4c835 100644 --- a/Nix/Pretty.hs +++ b/Nix/Pretty.hs @@ -12,8 +12,6 @@ prettySetArg :: (Text, Maybe NExpr) -> Doc prettySetArg (n, Nothing) = text (unpack n) prettySetArg (n, Just v) = text (unpack n) <+> text "?" <+> prettyNix v -prettyFold = foldr ($$) empty - infixOper :: NExpr -> String -> NExpr -> Doc infixOper l op r = prettyNix l <+> text op <+> prettyNix r @@ -44,19 +42,19 @@ prettyNix :: NExpr -> Doc prettyNix (Fix expr) = go expr where go (NConstant atom) = text $ unpack $ atomText atom go (NOper oper) = prettyOper oper - go (NList list) = lbrack <+> (prettyFold $ map prettyNix list) <+> rbrack + go (NList list) = lbrack <+> (fsep $ map prettyNix list) <+> rbrack - go (NArgSet args) = lbrace <+> (prettyFold $ map prettySetArg $ toList args) <+> rbrace + go (NArgSet args) = lbrace <+> (vcat $ map prettySetArg $ toList args) <+> rbrace go (NSet rec list) = (case rec of Rec -> "rec"; NonRec -> empty) - <+> lbrace <+> (prettyFold $ map prettyBind list) <+> rbrace + <+> lbrace <+> (vcat $ map prettyBind list) <+> rbrace go (NLet binds body) = text "let" go (NIf cond trueBody falseBody) = - text "if" <+> prettyNix cond - <+> text "then" <+> prettyNix trueBody - <+> text "else" <+> prettyNix falseBody + (text "if" <+> prettyNix cond) + $$ (text "then" <+> prettyNix trueBody) + $$ (text "else" <+> prettyNix falseBody) go (NWith scope body) = text "with" <+> prettyNix scope <> semi <+> prettyNix body go (NAssert cond body) = text "assert" <+> prettyNix cond <> semi <+> prettyNix body