<div dir="ltr">I don't think this package works as expected. Consider the following:<div><br></div><div><div>import           Control.Concurrent</div><div>import           Control.Exception.Async</div><div>import           System.Timeout</div>

<div><br></div><div>main :: IO ()</div><div>main = do</div><div>    timeout 1000000 $ do</div><div>        threadDelay 10000000 `catchSync` \e -> do</div><div>            print e</div><div>            threadDelay 10000000</div>

<div>    return ()</div></div><div><br></div><div>The expected behavior would be that the timeout- an async exception- would kill the thread delay, the catch would ignore the async exception, and the program would exit. In reality, catchSync treats the timeout as a synchronous exception, prints it, and delays once again. Compare this to classy-prelude's catchAny, which handles the situation correctly, via the technique I described in "Catching all exceptions."[1]</div>

<div><br></div><div>In this case, the issue is that the timeout exception type is not recognized as async, and a special case could be added to handle that exception type[2]. However, I think the overall approach of determining *how* an exception was thrown based on *what* was thrown is not tenable.</div>

<div><br></div><div>[1] <a href="https://www.fpcomplete.com/user/snoyberg/general-haskell/exceptions/catching-all-exceptions">https://www.fpcomplete.com/user/snoyberg/general-haskell/exceptions/catching-all-exceptions</a></div>

<div>[2] It's a bit difficult to do so, since IIRC the type is never exported. But a hack using the Typeable instance- while ugly- is likely possible.</div></div><div class="gmail_extra"><br><br><div class="gmail_quote">

On Wed, Feb 5, 2014 at 1:28 PM, Roman Cheplyaka <span dir="ltr"><<a href="mailto:roma@ro-che.info" target="_blank">roma@ro-che.info</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">

The links are:<br>
<br>
<a href="http://hackage.haskell.org/package/asynchronous-exceptions" target="_blank">http://hackage.haskell.org/package/asynchronous-exceptions</a><br>
<a href="https://github.com/feuerbach/asynchronous-exceptions" target="_blank">https://github.com/feuerbach/asynchronous-exceptions</a><br>
<br>
* Roman Cheplyaka <<a href="mailto:roma@ro-che.info">roma@ro-che.info</a>> [2014-02-05 13:23:38+0200]<br>
<div class="HOEnZb"><div class="h5">> It is often useful to distinguish between synchronous and asynchronous<br>
> exceptions. The common idiom is to run a user-supplied computation<br>
> catching any synchronous exceptions but allowing asynchronous exceptions<br>
> (such as user interrupt) pass through.<br>
><br>
> base 4.7 (shipped with GHC 7.8) will have SomeAsyncException type that<br>
> solves this problem.<br>
><br>
> asynchronous-exceptions is a new package that serves two purposes:<br>
> * provide compatibility with older `base` versions that lack the<br>
>   `SomeAsyncException` type<br>
> * define convenient functions for catching only synchronous exceptions<br>
><br>
> Roman<br>
</div></div><br>_______________________________________________<br>
Haskell-Cafe mailing list<br>
<a href="mailto:Haskell-Cafe@haskell.org">Haskell-Cafe@haskell.org</a><br>
<a href="http://www.haskell.org/mailman/listinfo/haskell-cafe" target="_blank">http://www.haskell.org/mailman/listinfo/haskell-cafe</a><br>
<br></blockquote></div><br></div>