<div dir="ltr"><div class="gmail_extra"><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"><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></blockquote></div><br>A version of `catch` used to be in Prelude, but it *only* worked with the IOException subtype; the one in Control.Exception works for all exception types. Rather than propagate the confusion between them, or risk breaking code in weird ways (the one in Prelude was restricted in part because the exception system was redesigned to be extensible, and the Prelude version didn't handle the way the new exception types work), it was simply removed. The Prelude one was something of an oddity even before extensible exceptions and mostly confused new Haskellers, so there didn't seem to be much reason to keep it around.<br></div><div class="gmail_extra"><br></div><div class="gmail_extra">MonadIO is going to be hard. It's not a type but a typeclass for things that can perform operations in IO; but this is not (and can't be, if you think about it) bidirectional. Consider the case of StateT s IO: your exception handler can get an `s` known when the `catch` is evaluated, but can never know the *current* value of the `s` when the exception is thrown --- exceptions do not know how to carry state around like that, and in the most general case can't know how. There are various frameworks that attempt to add this kind of functionality, such as MonadCatch and MonadBaseControl; but it's fairly tricky even at the best of times.</div><div class="gmail_extra"><div><br></div>-- <br><div class="gmail_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></div>