Data.Display - Textual representation of Haskell values (was Re: PROPOSAL: Add displayException to Exception typeclass)
Greg Weber
greg at gregweber.info
Mon Nov 10 18:25:45 UTC 2014
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]] ?
[["abc", "def"], ["ghi"], ["jkl"]]
Or
[ ["abc", "def"]
, ["ghi"]
, ["jkl"]
]
On Mon, Nov 10, 2014 at 9:16 AM, Simon Hengel <sol at typeful.net> wrote:
> > > So I would love to have tho following type class:
> > >
> > > class Display a where
> > > display :: a -> String
> > > default display :: Show a => a -> String
> > > display = show
> > >
> > > Note that for many Prelude types `show == display`, with the notable
> > > exception of String, where `display = id`. One use case where this
> > > matters is string interpolation [1][2][3].
> >
> > I would also like a class like that to exist.
> >
> > But I think it should be based on Text and Text builder rather than
> > String (and hence be outside of base).
>
> I created an initial draft:
>
> https://github.com/sol/display/blob/master/src/Data/Display.hs
>
> I named the builder version `displayBuilder` as I could not come up with
> any better name (suggestions much appreciated!).
>
> In addition, I think the `display` method has to be outside of the
> class. Otherwise, if somebody defines `display` he end up with the
> default implementation of `displayBuilder` (which is based on show and
> may not be what is intended). Any input on that?
>
> Pleas bikeshed hard!
>
> Cheers,
> Simon
> _______________________________________________
> Libraries mailing list
> Libraries at haskell.org
> http://www.haskell.org/mailman/listinfo/libraries
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.haskell.org/pipermail/libraries/attachments/20141110/75616aed/attachment-0001.html>
More information about the Libraries
mailing list