-
Notifications
You must be signed in to change notification settings - Fork 42
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Exceptions 0.10.0 #61
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -60,7 +60,20 @@ instance (MonadIO m, MonadMask m) => MonadMask (GhcT m) where | |
wrap g = GhcT $ GHC.GhcT $ \s -> MTLAdapter (g s) | ||
unwrap m = unMTLA . GHC.unGhcT (unGhcT m) | ||
|
||
uninterruptibleMask = mask | ||
uninterruptibleMask f = wrap $ \s -> | ||
uninterruptibleMask $ \io_restore -> | ||
unwrap (f $ \m -> (wrap $ \s' -> io_restore (unwrap m s'))) s | ||
where | ||
wrap g = GhcT $ GHC.GhcT $ \s -> MTLAdapter (g s) | ||
unwrap m = unMTLA . GHC.unGhcT (unGhcT m) | ||
|
||
generalBracket acquire release body | ||
= wrap $ \s -> generalBracket (unwrap acquire s) | ||
(\a exitCase -> unwrap (release a exitCase) s) | ||
(\a -> unwrap (body a) s) | ||
where | ||
wrap g = GhcT $ GHC.GhcT $ \s -> MTLAdapter (g s) | ||
unwrap m = unMTLA . GHC.unGhcT (unGhcT m) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This is the main fix: exceptions-0.9 introduced a new method named There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. What about depending on exceptions >= 0.8.0? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Do you mean >= 0.10.0, or did you change your mind and now want an There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I indeed meant >= 0.10.0 - thanks for spotting that. I would not bother supporting 0.8 and earlier, especially given how it's a v0, and how we're likely one of the last libraries to add support for the new exceptions versions. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. fixed, merging |
||
|
||
instance (MonadIO m, MonadCatch m, MonadMask m) => GHC.ExceptionMonad (GhcT m) where | ||
gcatch = catch | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I also took the opportunity to fix the implementation of
uninterruptibleMask
. It was previously defined asuninterruptibleMask = mask
, so callinguninterruptibleMask body
was misleadingly runningbody
in interruptible mode, not in uninterruptible mode. The difference is that some calls, likethreadDelay
, are intentionally marked as being interruptible even when running insidemask
. As a result,terminates after 1 second because the timeout successfully interrupts the threadDelay after 1 second, while
terminates after 3 seconds, because the timeout has to wait until the
uninterruptibleMask
computation terminates before aborting the computation.Without this fix,
and
both terminate after 1 second, whereas with this fix, the second terminates after 3 seconds, as desired.