[Haskell-cafe] Pretty-printer for Text

Ivan Lazar Miljenovic ivan.miljenovic at gmail.com
Wed Oct 27 03:57:57 EDT 2010

On 27 October 2010 18:39, Stephen Tetley <stephen.tetley at gmail.com> wrote:
> Having a Pretty class plus primitive printers int, bool is an
> advantage. For ints, bools, ... code tends to look neater if you use
> int or bool rather than pretty. Plus for ints and others you tend to
> need things like hex printers anyway, so one size via a type class
> doesn't fit all.

Definitely agreed.

> As for the class - if I have a reasonably sized
> syntax tree I'd rather just do
>> pretty a
> ... than formulate a naming scheme like:
>> prettyExpr a

What do you mean by "prettyExpr"?

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

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).

[1]: http://bifunctor.homelinux.net/~roel/cgi-bin/hackage-scripts/revdeps/prettyclass-
[2]: http://hackage.haskell.org/package/prettyclass
[3]: http://bifunctor.homelinux.net/~roel/cgi-bin/hackage-scripts/revdeps/pretty-
[4]: http://hackage.haskell.org/package/pretty

Ivan Lazar Miljenovic
Ivan.Miljenovic at gmail.com

More information about the Haskell-Cafe mailing list