Handling exceptions

The libraries in this subsection are as follows:

  • exceptions: Generalizing extensible extensions to any monad via type-classes (MonadThrow, MonadCatch, and MonadMask)
  • safe-exceptions: At the time of writing, safe-exceptions is a recent attempt at pumping more sense into exception handling in the Haskell ecosystem

When working with custom monads and exceptions, it's advisable to use generalized functions from the exceptions library to conveniently throw, catch, and mask exceptions. The functions work pretty much the same as their originals from Control.Exception, unless somehow restricted by the base monad.

There are a few nuisances in the way exceptions are handled in Haskell and GHC. In particular, differentiating between synchronous ...

Get Haskell High Performance Programming now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.