[Haskell-cafe] ANN: asynchronous-exceptions
michael at snoyman.com
Wed Feb 5 14:56:31 UTC 2014
I don't think this package works as expected. Consider the following:
main :: IO ()
main = do
timeout 1000000 $ do
threadDelay 10000000 `catchSync` \e -> do
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."
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. However, I think the overall approach of determining
*how* an exception was thrown based on *what* was thrown is not tenable.
 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.
On Wed, Feb 5, 2014 at 1:28 PM, Roman Cheplyaka <roma at ro-che.info> wrote:
> The links are:
> * Roman Cheplyaka <roma at ro-che.info> [2014-02-05 13:23:38+0200]
> > It is often useful to distinguish between synchronous and asynchronous
> > exceptions. The common idiom is to run a user-supplied computation
> > catching any synchronous exceptions but allowing asynchronous exceptions
> > (such as user interrupt) pass through.
> > base 4.7 (shipped with GHC 7.8) will have SomeAsyncException type that
> > solves this problem.
> > asynchronous-exceptions is a new package that serves two purposes:
> > * provide compatibility with older `base` versions that lack the
> > `SomeAsyncException` type
> > * define convenient functions for catching only synchronous exceptions
> > Roman
> Haskell-Cafe mailing list
> Haskell-Cafe at haskell.org
-------------- next part --------------
An HTML attachment was scrubbed...
More information about the Haskell-Cafe