-- | Like 'finally', but only performs the final action if there was an
-- exception raised by the computation.
onException :: IO a -> IO b -> IO a
-onException io what = io `catch` \e -> do what
+onException io what = io `catch` \e -> do _ <- what
throw (e :: SomeException)
-----------------------------------------------------------------------------
block (do
a <- before
r <- unblock (thing a) `onException` after a
- after a
+ _ <- after a
return r
)
#endif
a `finally` sequel =
block (do
r <- unblock a `onException` sequel
- sequel
+ _ <- sequel
return r
)