
On 27 October 2010 08:57, Ivan Lazar Miljenovic
What do you mean by "prettyExpr"?
Without a type class I generally name pretty printers by the pretty 'pretty' then the type they print Expr (expression), Decl (declaration) etc.
My main objection to having a Pretty type class is that when having a "reasonably sized syntax tree", aren't you likely to want to have your own custom printing variants rather than the ones in the pre-defined class? As such, does having a default class make sense if it isn't used?
That said, 9 packages [1] do use prettyclass [2]... out of the 168 packages [3] that use pretty itself [4] (some of which implement their own Pretty class).
For a syntax tree I'd want a class, then I can use pretty at any level. This is helpful in defining the instances as most of the work is delegated to pretty rather than prettyExp, prettyDecl etc. so it keeps the code neat. It is also useful in GHCi where I can just call pretty on something. I can't think that I've ever wanted two different flavours of output for a syntax tree. If I was wanted 'round trip printing' (from parsing to pretty to parsing) I'd have to take a lot of care over white space and layout so I would be needing something more powerful than a pretty printer. As for the prettyclass in HughesPJ, if people found they wanted this I don't know why people didn't switch to wl-pprint. Wl-pprint is nicer in enough ways to make the change sensible.