Pretty class as alternative for Show class

Johannes Waldmann waldmann at
Wed Feb 13 02:42:48 EST 2008

Henning Thielemann wrote:

>  The Show class converts to String, the Pretty class could convert to a
> pretty printer data type like Doc. [...]

Ah yes, I use this since a long time

class ToDoc a where
    toDoc :: a -> Doc
    toDoc = toDocPrec 0 -- useful?
    toDocPrec :: Int -> a -> Doc

I generally make even this output re-readable,
and I'm reading is via Parsec:

class Reader a where
      readerPrec :: Int -> Parser a

and I also have the obvious DrIFT rules
that can generate standard instances for most types.

I will happily contribute this code to whatever Pretty class emerges.
(Well, it's free, so I'd have no way to not contribute it ...)

best regards, Johannes.

More information about the Libraries mailing list