<div dir="auto">> <span style="font-family:sans-serif;font-size:13.696px">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.</span><div dir="auto"><font face="sans-serif"><span style="font-size:13.696px"><br></span></font></div><div dir="auto"><font face="sans-serif"><span style="font-size:13.696px">Apologies, but I couldn't understand the example. In an exception where it's not even possible to know the stack trace easily, I don't expect to know the state of the computation. It's an exception -- it is alright if it doesn't have the state. But at least allow me to catch the exception in MonadIO. </span></font></div><div dir="auto"><font face="sans-serif"><span style="font-size:13.696px"><br></span></font></div><div dir="auto"><font face="sans-serif"><span style="font-size:13.696px">And this brings me to my original question. What do I need to do to catch an exception in spock's ActionT? I thought I didn't understand something earlier. But now it seems that I have hit a hairy part of Haskell. </span></font></div><div dir="auto"><font face="sans-serif"><span style="font-size:13.696px"><br></span></font></div><div dir="auto"><font face="sans-serif"><span style="font-size:13.696px">--Saurabh. <br></span></font><div dir="auto"><span style="font-family:sans-serif;font-size:13.696px"><br></span></div></div></div><div class="gmail_extra"><br><div class="gmail_quote">On 16 Dec 2016 9:14 am, "Brandon Allbery" <<a href="mailto:allbery.b@gmail.com">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"><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="m_1407148790622520218gmail_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>
</blockquote></div></div>