quchen / prettyprinter

A modern, extensible and well-documented prettyprinter.
BSD 2-Clause "Simplified" License
294 stars 36 forks source link

Squashing consecutive newlines #201

Closed newhoggy closed 3 years ago

newhoggy commented 3 years ago

Is it possible to add a special kind of newline whereby if there were more than one consecutive such newline they will be squashed into one?

newhoggy commented 3 years ago

Similarly for spaces.

quchen commented 3 years ago

This has been requested multiple times via various channels, and I’m not a fan of it.

Rationale

Code

On a code level, it would be quite complicated, and thus only pitfall-heavy, probably changing the Doc type.

Usage

My recommendation

Produce your documents with concatWith, and insert the desired amount of lines between manually. Don’t use the layouter to clean up your Doc, but rather create it in a way it doesn’t have to.

newhoggy commented 3 years ago

Thanks for you advice and suggestions!