[Haskell-beginners] pretty-printing data
magnus at therning.org
Sat Aug 29 18:09:15 EDT 2009
On Sat, Aug 29, 2009 at 3:22 PM, Michael Mossey<mpm at alumni.caltech.edu> wrote:
> For debugging purposes I'm interested in pretty-printing data; to start
> with, lists of algebraic data types. Basically I'd like 'show' with the
> ability to put each entry of a list on a separate line, and indented. Note
> that the algebraic data might have an inner list as one of its elements, so
> this is a non-obvious formatting problem.
> I believe I can make instances of Show, can I not? Is there something called
> showList which I can use to code my own method of showing lists of a
> particular type? My understanding is that I can't make [a] an instance of
> Show; hence they provided showList.
> So basically, I'm wondering if a pretty-printing (for data!) library already
> exists, or whether I should try to make instances of Show.
Take a look at the pretty-printing libraries available on Hackage.
I've personally used two of them, pretty and wl-pprint. I'm fairly
sure both of them define pretty-printing for lists, but I don't know
whether it's done the way you want.
Magnus Therning (OpenPGP: 0xAB4DFBA4)
magnus＠therning．org Jabber: magnus＠therning．org
http://therning.org/magnus identi.ca|twitter: magthe
More information about the Beginners