
On Mon, Nov 10, 2014 at 10:49:44AM -0500, Roman Cheplyaka wrote:
On 10/11/14 09:56, Simon Hengel wrote:
1. Add a new method to the Exception typeclass:
-- | Render this exception value in a human-friendly manner. Default implementation: @show@. displayException :: e -> String displayException = show
I'm +0.5 on this one, even though I think we should solve this in the general case. I think there is a difference between converting something to a string (display) vs. showing something in a programmer friendly way (show). This distinction is not novel, both Python and Ruby make that distinction (str()/repr() in Python, #to_s/#inspect in Ruby).
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).
Yes, this is a valid point. The Text vs. String issue is one of the things that made me reluctant to tackle this so far (the other being that outside of base people may not want to depend on it, orphan instances, ...). My given Display class would probably not be that useful without some `displays :: ShowS`. I think by now I'm sold on the separate package based on text. Cheers, Simon