cdepillabout / cdepillabout/pretty-simple

"Compact" option sometimes produces ugly/inconsistent output

Open
#84 15 comments 0 reactions 0 assignees View on GitHub
high priority
Dominant language
Haskell
Stars
260
Forks
30
PR merge metrics
No merged PRs in 30d

Description

I'm using a custom pPrintOpt config which looks like this:
```
pPrint :: (Show a) => a -> IO ()
pPrint = pPrintOpt CheckColorTty (defaultOutputOptionsDarkBg {outputOptionsCompact=True,outputOptionsPageWidth=60})
```
I'm getting some weird behaviour when printing long lists of tuples with this compact option. If I print a list of 10 integer values, the printing works as expected:
```
Prelude> replicate 10 12345
[ 12345
, 12345
, 12345
, 12345
, 12345
, 12345
, 12345
, 12345
, 12345
, 12345
]
```
If I define a simple ADT, it also works fine:
```
Prelude> data Foo = Foo Int Int deriving (Show)
Prelude> replicate 10 (Foo 1 2)
[ Foo 1 2
, Foo 1 2
, Foo 1 2
, Foo 1 2
, Foo 1 2
, Foo 1 2
, Foo 1 2
, Foo 1 2
, Foo 1 2
, Foo 1 2
]
```
However, if I try and print a list of tuples, the output seems to insert extra newlines after the commas:
```
Prelude> replicate 10 (1, 2)
[
( 1, 2 )
,
( 1, 2 )
,
( 1, 2 )
,
( 1, 2 )
,
( 1, 2 )
,
( 1, 2 )
,
( 1, 2 )
,
( 1, 2 )
,
( 1, 2 )
,
( 1, 2 )
]
```
I would not expect these newlines to be here. Instead, the expected output would be similar to the previous examples, where the comma is on the same line as the value.

Contributor guide

No contributing guide indexed for this repository

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.