PROPOSAL: Add displayException to Exception typeclass

Michael Snoyman michael at snoyman.com
Mon Nov 10 14:01:26 UTC 2014


I started a discussion a few weeks back on some theoretical changes to how
exceptions are displayed. That discussion covered a lot of different
ground. I'd now like to formally propose the original change I mentioned in
that thread:

1.  Add a new method to the Exception typeclass:

    -- | Render this exception value in a human-friendly manner. Default
implementation: @show at .
    displayException :: e -> String
    displayException = show

2. Modify GHC's default exception handler to use `displayException` instead
of `show`.

This change will, on its own, cause no breakage[1] and, without further
action, will have no change in program behavior. It does, however, allow
users to begin distinguishing between how their exceptions should be
`show`n versus how they should be displayed to an end user.

Note that I am *not* proposing at this time any other changes discussed in
the previous thread. If someone wants to propose removing Show
superclasses, adding a Read superclass, providing a typeRepStack method[2],
or something else, please propose it separately.

Discussion period: two weeks.

Michael

[1] Besides introducing a new, possibly clashing identifier name.
[2] That one actually seems like a very good idea to me.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.haskell.org/pipermail/libraries/attachments/20141110/743c7e03/attachment.html>


More information about the Libraries mailing list