Discussion: adding displayException to Exception class
John Lato
jwlato at gmail.com
Wed Oct 29 02:57:46 UTC 2014
On Wed, Oct 29, 2014 at 10:33 AM, Michael Snoyman <michael at snoyman.com>
wrote:
>
> A completely different approach that might be better for your use case
> *and* might be useful in other cases would be to keep a stack of the
> `TypeRep`s we converted through when creating the SomeException. However,
> that would require a breaking change to SomeException, which I really
> *don't* want to propose.
>
We already keep all the TypeReps, they just aren't generically accessible.
If we added a function to the Exception class like
typeRepStack :: a -> [TypeRep]
it should work. A more-or-less sensible default is typeRepStack a =
[typeOf a], which would work for all terminal exception types. A mid-level
type in a hierarchy would need a different value though, something like
typeRepStack se@(SomeException e) = typeOf se : typeRepStack e
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.haskell.org/pipermail/libraries/attachments/20141029/c7f77a17/attachment-0001.html>
More information about the Libraries
mailing list