Pretty.lhs: bug found, feature missed
Fri, 9 Nov 2001 10:18:05 -0800
(don't know if others are/have attended to this)
thanks, I've committed the obvious fix for this one.
As for you other question, GHC's Outputable is one example
of a Pretty use which lets you prune documents at a certain
depth. The sources can be found in ghc/compiler/utils/Outputable.lhs -
maybe something in there that's of use to you..
----- Original Message -----
From: "Johannes Waldmann" <email@example.com>
Sent: Tuesday, November 06, 2001 13:40
Subject: Pretty.lhs: bug found, feature missed
> We were recently bitten by what seems to be
> a bug in hslibs/text/Pretty.lhs.
> The following code prints an infinite string:
> import Pretty
> 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
> I think this is due to the function indent/spaces
> called with a negative argument. The following is in Pretty.lhs:
> indent n | n >= 8 = '\t' : indent (n - 8)
> | otherwise = spaces n
> spaces 0 = ""
> spaces n = ' ' : spaces (n - 1)
> This looks Really Dangerous.
> Another point: we would want to use a version of `render (d :: Doc)'
> that always produces only a bounded amount of output,
> by cutting off sub-documents that are too deeply nested.
> (Some LISP pretty printers do have this feature -
> they cut long lists, and deeply nested lists).
> Before sitting down and trying to implement this, we would like to
> check whether someone already did it. If so, please tell us.
> Best regards,
> -- Johannes Waldmann ---- http://www.informatik.uni-leipzig.de/~joe/ --
> -- firstname.lastname@example.org -- phone/fax (+49) 341 9732 204/252 --
> Glasgow-haskell-users mailing list