#4810: Versions of bracket without masking acquire action
---------------------------------+------------------------------------------
Reporter: mitar | Owner:
Type: proposal | Status: new
Priority: normal | Milestone:
Component: libraries/base | Version: 7.0.1
Keywords: | Testcase:
Blockedby: | Difficulty:
Os: Unknown/Multiple | Blocking:
Architecture: Unknown/Multiple | Failure: None/Unknown
---------------------------------+------------------------------------------
Comment(by mitar):
Replying to [comment:9 simonmar]:
> But it wouldn't make a difference if it was unmasked, it would still not
be interruptible.
Yes.
> I like it!
;-)
> Then I misunderstood what you wanted `blockWithUnmask` to do. Could you
show me the code?
`bracketWithUnmask`, not `blockWithUnmask` (just to be sure).
{{{
bracketWithUnmask before after thing =
mask $ \restore -> do
a <- before restore
r <- restore (thing a) `onException` after a
_ <- after a
return r
}}}
This. ;-) Before just gets additional argument: restore.
To be clear, this was not my initial proposal, for that you showed it
would not work correctly. My initial proposal would have `restore before`
there.
Of course the same argument could be applied also that `after` should also
have `restore` as an argument, but I cannot really imagine a real-world
use for this. And it is probably then easier to write everything by hand
with `mask` than using some variant of `bracket`.
And if user does not want to allow unmasking, then it is possible to just
do:
{{{
bracket (before id) after ...
}}}
Of course this is still doable very similar to my initial approach:
{{{
mask $ \restore -> bracket (open restore) (close) (restore . work)
}}}
--
Ticket URL: <http://hackage.haskell.org/trac/ghc/ticket/4810#comment:10>
GHC <http://www.haskell.org/ghc/>
The Glasgow Haskell Compiler
_______________________________________________
Glasgow-haskell-bugs mailing list
[email protected]
http://www.haskell.org/mailman/listinfo/glasgow-haskell-bugs