From 86c4745cea434a033cdb25f03af19d0d472a65b3 Mon Sep 17 00:00:00 2001 From: Jens Petersen Date: Tue, 31 May 2022 13:24:36 +0800 Subject: [PATCH] further reduce newlines for compact output (#84) --- src/Text/Pretty/Simple/Internal/Printer.hs | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/Text/Pretty/Simple/Internal/Printer.hs b/src/Text/Pretty/Simple/Internal/Printer.hs index 14c64ae..8ae1bd6 100644 --- a/src/Text/Pretty/Simple/Internal/Printer.hs +++ b/src/Text/Pretty/Simple/Internal/Printer.hs @@ -255,7 +255,10 @@ prettyExpr opts = (if outputOptionsCompact opts then group else id) . \case spaceIfNeeded = \case Other (' ' : _) : _ -> mempty _ -> space - lineAndCommaSep x y = x <> line' <> annotate Comma "," <> y + lineAndCommaSep x y = + if outputOptionsCompact + then x <> annotate Comma "," <> y + else x <> line' <> annotate Comma "," <> y -- | Determine whether this expression should be displayed on a single line. isSimple :: Expr -> Bool