Discussion: adding displayException to Exception class
Jeremy Shaw
jeremy at n-heptane.com
Wed Oct 29 02:55:06 UTC 2014
On Tue, Oct 28, 2014 at 6:43 PM, Michael Snoyman <michael at snoyman.com> wrote:
> As I recently commented on this list[1], the Show typeclass is overloaded
> with multiple meanings (serialization, debug info, and user-friendly data
> display). The general consensus seems to be that the official semantics for
> Show should be for serialization (as paired up with Read).
A bit off topic but, I think the semantics of Show/Read should
actually be even stronger. Serializing to a String is a bit pointless
-- things like Binary, Cereal, SafeCopy etc are much more suited for
'serialization'. It seems to me that Show and Read are really closer
to ShowExpr and ReadExpr in many cases. The idea being that you can
show a value, copy and paste that string into GHCi and get back your
original value. For many show instances this holds true. Though
clearly not all. I'd love to see:
1. Show/Read really be ShowExpr/ReadExpr
2. Binary
3. SafeCopy (like binary, but versioned with migration)
4. Pretty
Of course, that opens the can of worms -- why not HTML instances,
Markdown instances, etc. This is probably more a proposal for
something like Idris where changes like this are still viable ;)
- jeremy
More information about the Libraries
mailing list