Data.Display - Textual representation of Haskell values (was Re: PROPOSAL: Add displayException to Exception typeclass)

Evan Laforge qdunkan at gmail.com
Mon Nov 10 18:51:55 UTC 2014


On Mon, Nov 10, 2014 at 10:25 AM, Greg Weber <greg at gregweber.info> wrote:
> What is the goal of this project? To pretty-print output? Or to be a
> slightly friendlier version of Show?
> To put it another way, what happens with more complicated structures?
> As an example, what should the output be for this type [[String]] ?

I've long used a Pretty class, which outputs a Doc from a pretty
printing library.  That way it can be flattened into one line or
wrapped, depending on context.  Most of the readability comes from the
layout, and the rest comes from how I can omit "less important" data
or use non-haskell syntax (e.g. {k: v} for maps).  So for me a Display
class that doesn't include layout wouldn't be very useful.

I include all data in Show (and usually derive it), which means that
it's valid syntax and I automatically parse and then format it with
Language.Haskell.Pretty.

I don't know if this is applicable to a general purpose Display class,
because then it would have to pick a pretty printing library, which
means it's making choices about layout and formatting, which means
it's not really universal.  E.g. I currently use HughesPJ but modified
to avoid piling up on the right margin, but having been meaning for a
long time to switch to an indentation based formatter that uses Text.

Also, I use the showList hack.  It works.


More information about the Libraries mailing list