cdepillabout/pretty-simple

[rfe] option for compact (complex) lists: avoid rendering lines with only a comma

juhp opened this issue · 2 comments

juhp commented

I really like the simplicity of this library, though I do wish it defaulted to more compact output. 8-)

Simple lists render nicely:

> pPrint ["one","two"]
[ "one"
, "two"
]

But for complicated lists using available compact options:

> import Network.XmlRpc.Internals
> pPrintOpt CheckColorTty (defaultOutputOptionsDarkBg {outputOptionsCompact = True, 
                                                       outputOptionsCompactParens = True})
    [("resultCode",ValueInt 10),("resultText",ValueString "build completed in 5m 12s")]

[
    ( "resultCode", ValueInt 10 )
,
    ( "resultText", ValueString "build completed in 5m 12s" ) ]

This is a small example, but for rendering large Map's etc, having the comma on a separate line takes up a lot of vertical space. Maybe outputOptionsCompactParens should induce putting the comma on the same line?

I would love to just have a pPrintCompact function to provide such compact output (the above usage is already rather long).

further edit: perhaps the initial newline could be dropped too, to something like this?:

[   ( "resultCode", ValueInt 10 )
,   ( "resultText", ValueString "build completed in 5m 12s" ) ]

I think this is covered by #84, except for pPrintCompact, which is possibly a good idea. Could you open that part as a separate issue? Then I'll close this and you can subscribe to #84.

juhp commented

Okay, thanks