Bad output from Text.PrettyPrint.HughesPJ
This program:
import Text.PrettyPrint.HughesPJ
ncat x y = nest 4 $ cat [ x, y ]
d1 = foldl1 ncat $ take 50 $ repeat $ char 'a'
d2 = parens $ sep [ d1, text "+" , d1 ]
main = print d2
generates the output below. I haven't worked out what is expected, but this certainly doesn't look right to me (in particular, the space before the a
on the third line of the output).
% runghc pp1.hs | tr ' ' _
(aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
+___________________________________________________________________________________________________________________________________________________________________________________________________a
_a
a
a
a
a
a
a
a
a
a
a
a
a
a
a
a
a
a
a
a
a
a
a
a
a
a
a
a
a
a
a
a
a
a
a
a
a
a
a
a
a
a
a
a
a
a
a
a
a)
The pp1 test goes on to say:
This code used to print an infinite string, by calling 'spaces'
with a negative argument. There's a patch in the library now,
which makes 'spaces' do somehthing sensible when called with a negative
argument, but it really should not happen at all.
This output is not what is expected, becuase the
test "works" now, by virtue of a hack in HughesPJ.spaces.
I'm leaving this strange output here to remind us to look
at the root cause of the problem. Sometime.