Skip to content

Commit

Permalink
Merge pull request #110 from juhp/patch-1
Browse files Browse the repository at this point in the history
further reduce newlines for compact output
  • Loading branch information
georgefst authored Jun 4, 2022
2 parents 380829e + 844be68 commit da22de6
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 2 deletions.
9 changes: 9 additions & 0 deletions src/Text/Pretty/Simple.hs
Original file line number Diff line number Diff line change
Expand Up @@ -680,6 +680,15 @@ layoutStringAnsi opts = fmap convertStyle . layoutString opts
-- , B
-- ( B ( B A ) ) ] )
--
-- >>> pPrintOpt CheckColorTty defaultOutputOptionsDarkBg {outputOptionsCompact = True} $ [("id", 123), ("state", 1), ("pass", 1), ("tested", 100), ("time", 12345)]
-- [
-- ( "id", 123 ),
-- ( "state", 1 ),
-- ( "pass", 1 ),
-- ( "tested", 100 ),
-- ( "time", 12345 )
-- ]
--
-- __Initial indent__
--
-- >>> pPrintOpt CheckColorTty defaultOutputOptionsDarkBg {outputOptionsInitialIndent = 3} $ B ( B ( B ( B A ) ) )
Expand Down
3 changes: 2 additions & 1 deletion src/Text/Pretty/Simple/Internal/Printer.hs
Original file line number Diff line number Diff line change
Expand Up @@ -255,7 +255,8 @@ 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 = x <> munless (outputOptionsCompact opts) line' <> annotate Comma "," <> y
munless b x = if b then mempty else x

-- | Determine whether this expression should be displayed on a single line.
isSimple :: Expr -> Bool
Expand Down
2 changes: 1 addition & 1 deletion stack.yaml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# For more information, see: http://docs.haskellstack.org/en/stable/yaml_configuration.html

# Specifies the GHC version and set of packages available (e.g., lts-3.5, nightly-2015-09-21, ghc-7.10.2)
resolver: lts-18.02
resolver: lts-18.28

# Local packages, usually specified by relative directory name
packages:
Expand Down

0 comments on commit da22de6

Please sign in to comment.