[Haskell-cafe] Absolutely confused with error/exception handling

Saurabh Nanda saurabhnanda at gmail.com
Fri Dec 16 01:42:10 UTC 2016


Hi,

What started as a simple exercise of writing an Airbrake integration for
Spock, has turned into a day of reading about errors, Control.Exception,
MonadThrow, MonadCatch, sync, asynchronous, etc.

Even after all that reading I haven't been able to find answers to the
following --

* What exactly is done by the "error" function? How does one "trap" those
errors and react to it? Can "catch" trap those errors? What is "e" in the
case of errors raised by "error"?
* How is "error" different from "throw" and "throwIO" (in the
Control.Exception package, I believe)
* What does MonadThrow and MonadCatch bring to the table? My understanding
is that they are bringing a unified API to representing short-circuitable
computations based on the inherently short-circuitable value of the host
monad. Eg throwM in Maybe just results in a Nothing. throwM in List results
in [] Therefore, in most of the cases throwM is not really using the error
machinery built into the Haskell language (what said machinery is, is the
very first question that I still don't completely understand)

All of this might be obvious, and I might have just reached a mind-block
after hours of reading. Help would be really appreciated :)

-- Saurabh.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.haskell.org/pipermail/haskell-cafe/attachments/20161216/1997476d/attachment.html>


More information about the Haskell-Cafe mailing list