Extra blank line in vcat in wl-pprint package

I use wl-pprint because the standard PrettyPrinter does not have functionality. Everything is fine, except for the empty document in the vcat function (the same with the <$> combinator).

The correct behavior:

 import Text.PrettyPrint > vcat[text "a", empty, text "b"] a b 

wl-pprint shows an extra blank line:

 import Text.PrettyPrint.Leijen > vcat[text "a", empty, text "b"] a b 

So what can I do? It is not possible to filter the vcat list because there is no Eq instance for the Doc .

+4
source share
2 answers

Since I had no better ideas, I made the following changes to the source code

 (<$$>) :: Doc -> Doc -> Doc x <$$> Empty = x -- <<< added Empty <$$> y = y -- <<< added x <$$> y = x <> linebreak <> y 
0
source

define vcatSoft = fold <//>

docs say: "The document (vcat xs) merges all xs documents vertically with ()." and, looking at <$$> , he says that he "combines documents x and y with a gap between them." But pay attention to the following <//> function, which uses softbreak . And looking at defn vcat, it's just vcat = fold <$$> , so define a function = fold <//> .

0
source

All Articles