On Wed, Oct 29, 2014 at 10:33 AM, Michael Snoyman <michael@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