p :: Either A B -> Doc'
p (Left a) = pretty' a
p (Right b) = pretty' (parens b)
Do we lose anything if we make parens and similar functions return Doc'?
Geoffrey
I did it that way because, more often than not, you shouldn't be using parens
directly, but rather (#>). For example, in your case if Right is really
always supposed to be parenthesized, you can say it has precedence -1:
p :: Either A B -> Doc'
p (Left a) = pretty' a
p (Right b) = -1 #> b
But if you really want to make parens PrecDoc and ignore its precedence,
that's fine too.
:-Dylan
Ah, that makes sense. I only ran it into the problem because I was
printing out Haskell code (yes, I started implementing (3)), so we can
leave it the way it is.
Geoffrey