Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

An extra blank line in a vcat in the wl-pprint package

I use wl-pprint package, because the standard PrettyPrinter lacks functionality. All is good, except an empty doc in a vcat function (the same thing with <$> combinator).

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 imposible to filter vcat list, because there is no Eq instance for Doc.

like image 633
user1374768 Avatar asked Nov 13 '22 03:11

user1374768


1 Answers

Because I hadn't have any better ideas, I made the following changes in the source

(<$$>) :: Doc -> Doc -> Doc
x <$$> Empty    = x                   -- <<< added
Empty <$$> y    = y                   -- <<< added
x <$$> y        = x <> linebreak <> y
like image 130
user1374768 Avatar answered Dec 30 '22 23:12

user1374768