A detailed technical overview of Haskell exception annotations as of GHC 9.12/9.14, covering backtraces (HasCallStack and cost-centre based), the pivotal changes to SomeException, the Exception typeclass modifications (toException, fromException, backtraceDesired), and the WhileHandling proposal implemented in catch. Key gotchas include: throwing SomeException clears the exception context, rethrowing exceptions should use catchNoPropagate and rethrowIO, and displayException does not show annotations. The post also documents the significant limitations in GHC 9.10 (lost annotations, duplicated annotations via ExceptionWithContext), and previews GHC 10.0 improvements including STM exception handling and a fixed onException that properly adds WhileHandling when the release callback itself throws.

18m read timeFrom well-typed.com
Post cover image
Table of contents
BacktracesBasic definitionsException type classThrowCatch⚠️ Caution: Displaying exceptionsGHC 9.10GHC 10.0Conclusions

Sort: