External Publication
Visit Post

Exception Annotations: Lay of the Land

Haskell Community [Unofficial] May 10, 2026
Source

At the risk of confusing myself and others (this is full of subtle issues!)

Suppose we made the toException of both SomeException and ExceptionWithContext actually respect the “produce a SomeException with no attached ExceptionContext” invariant. No exceptions (pun accidental) for it!

Suppose as well that we add a separate toExceptionPreservingContext :: ExceptionWithContext e -> SomeException function, and also redefine rethrowIO as

rethrowIO :: Exception e => ExceptionWithContext e -> IO a
rethrowIO e = throwIO (NoBacktrace (toExceptionPreservingContext e))

Would that work / bet better? Instance definitions would be more uniform, at least.

Discussion in the ATmosphere

Loading comments...