Proposal: add Control.Exception.SomeAsyncException
Merijn Verstraaten
merijn at inconsistent.nl
Wed Feb 5 18:46:02 UTC 2014
On Feb 5, 2014, at 19:41 , Evan Laforge wrote:
> But I think even with AsyncException as its own class you can't say
> "everything except", so it still requires an explicit rethrow, yes?
> E.g.:
>
> case Exception.fromException exc of
> Just (exc :: Exception.AsyncException) -> Exception.throwIO exc
> Nothing -> return ()
Well, you can do:
newtype AllBut e = AllBut SomeException deriving (Show, Typeable)
instance forall e . Exception e => Exception (AllBut e) where
fromException x = case fromException x :: Maybe e of
Nothing -> Just (AllBut x)
Just _ -> Nothing
This lets you write "foo `catch` \(AllBut _ :: AllBut AsyncException) -> doStuff", which will catch everything *except* async exceptions.
Cheers,
Merijn
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 801 bytes
Desc: Message signed with OpenPGP using GPGMail
URL: <http://www.haskell.org/pipermail/libraries/attachments/20140205/ee5e6b75/attachment.sig>
More information about the Libraries
mailing list