<div dir="ltr">Hi Saurabh,<div><br>I've found that the `safe-exceptions` package [1] and related articles [2] to be some of the best reading around exceptions in Haskell.</div><div><br>To answer your third question, the `IO` instance for `MonadThrow`/`MonadCatch`/etc. do use Haskell's extensible exception machinery. The monad-ste [3] package uses Haskell's exception hierarchy in a controlled manner where evaluating `Either` ends up being expensive.</div><div><br></div><div>I've also found exceptions to be one of the hardest parts about Haskell. Interestingly, they're one of the few dynamically typed bits with nearly OO-style inheritance. </div><div><br>[1]: <a href="https://hackage.haskell.org/package/safe-exceptions">https://hackage.haskell.org/package/safe-exceptions</a><br>[2]: <a href="https://haskell-lang.org/tutorial/exception-safety">https://haskell-lang.org/tutorial/exception-safety</a><br>[3]: <a href="https://hackage.haskell.org/package/monad-ste">https://hackage.haskell.org/package/monad-ste</a></div></div><div class="gmail_extra"><br clear="all"><div><div class="gmail_signature" data-smartmail="gmail_signature"><div dir="ltr"><div>Matt Parsons</div></div></div></div>
<br><div class="gmail_quote">On Thu, Dec 15, 2016 at 10:30 PM, Saurabh Nanda <span dir="ltr"><<a href="mailto:saurabhnanda@gmail.com" target="_blank">saurabhnanda@gmail.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir="auto">Thanks. The air is clearing up a bit. <div dir="auto"><br></div><div dir="auto">Any reason for "error" and "catch" to be in different packages? Or, why isn't "catch" in prelude?</div><div dir="auto"><br></div><div dir="auto">"catch" needs a action in IO. What if I have an action in MonadIO?</div><span class="HOEnZb"><font color="#888888"><div dir="auto"><br></div><div dir="auto">-- Saurabh. </div></font></span></div><div class="HOEnZb"><div class="h5"><div class="gmail_extra"><br><div class="gmail_quote">On 16 Dec 2016 8:00 am, "Brandon Allbery" <<a href="mailto:allbery.b@gmail.com" target="_blank">allbery.b@gmail.com</a>> wrote:<br type="attribution"><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir="ltr">whoops, pressed wrong key...<div><br></div><div>No guarantees are made as to when the exception thrown by `throw` occurs; this allows it to be thrown from pure code. `throwIO` is sequenced as any other I/O operation, so you have some guarantee as to I/O operations before the `throwIO` being performed.</div></div><div class="gmail_extra"><br><div class="gmail_quote">On Thu, Dec 15, 2016 at 9:28 PM, Brandon Allbery <span dir="ltr"><<a href="mailto:allbery.b@gmail.com" target="_blank">allbery.b@gmail.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir="ltr"><div class="gmail_extra"><br><div class="gmail_quote"><span>On Thu, Dec 15, 2016 at 8:42 PM, Saurabh Nanda <span dir="ltr"><<a href="mailto:saurabhnanda@gmail.com" target="_blank">saurabhnanda@gmail.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir="auto">* 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"?</div><div dir="auto"></div></blockquote><div><br></div></span><div>`error` specifically raises a UserError exception, with a user-specified payload (message). `catch` can catch them as such.</div><span><div> </div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir="auto">* How is "error" different from "throw" and "throwIO" (in the Control.Exception package, I believe)</div><div dir="auto"></div></blockquote></span></div><br>`throw` (for pure code / asynchronous) and `throwIO` (for code in IO) can throw any exception. No guarantees are made as to when the exception thrown by `throw`<span class="m_-5071497730454727724m_-7190253823080072306HOEnZb"><font color="#888888"><br><br clear="all"><div><br></div>-- <br><div class="m_-5071497730454727724m_-7190253823080072306m_7680743855748538699gmail_signature" data-smartmail="gmail_signature"><div dir="ltr"><div>brandon s allbery kf8nh sine nomine associates</div><div><a href="mailto:allbery.b@gmail.com" target="_blank">allbery.b@gmail.com</a> <a href="mailto:ballbery@sinenomine.net" target="_blank">ballbery@sinenomine.net</a></div><div>unix, openafs, kerberos, infrastructure, xmonad <a href="http://sinenomine.net" target="_blank">http://sinenomine.net</a></div></div></div>
</font></span></div></div>
</blockquote></div><br><br clear="all"><div><br></div>-- <br><div class="m_-5071497730454727724m_-7190253823080072306gmail_signature" data-smartmail="gmail_signature"><div dir="ltr"><div>brandon s allbery kf8nh sine nomine associates</div><div><a href="mailto:allbery.b@gmail.com" target="_blank">allbery.b@gmail.com</a> <a href="mailto:ballbery@sinenomine.net" target="_blank">ballbery@sinenomine.net</a></div><div>unix, openafs, kerberos, infrastructure, xmonad <a href="http://sinenomine.net" target="_blank">http://sinenomine.net</a></div></div></div>
</div>
</blockquote></div></div>
</div></div><br>______________________________<wbr>_________________<br>
Haskell-Cafe mailing list<br>
To (un)subscribe, modify options or view archives go to:<br>
<a href="http://mail.haskell.org/cgi-bin/mailman/listinfo/haskell-cafe" rel="noreferrer" target="_blank">http://mail.haskell.org/cgi-<wbr>bin/mailman/listinfo/haskell-<wbr>cafe</a><br>
Only members subscribed via the mailman list are allowed to post.<br></blockquote></div><br></div>