#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:3 simonmar]:
 > but can't you just transform that to

 I do not see a way. This is an example from a library where user can use
 bracket to wrap my library calls but then I am "unable" to use bracket
 inside my library (and I want to use bracket because I want that my
 function to be interruptible). What I want to do is to tell the user that
 best practice is to use unmasked version of a bracket when using my
 library because I do take care of cleaning myself. But of course user
 should use bracket because it should cleanup things. This is somewhat a
 motivation behind all this. How to give an user a simple suggestion what
 to use when calling my library. It should be an acquire-use-release
 approach, but I would like to have acquire interruptible for the user (at
 least in my best practice suggestion, user could still of course mask
 everything if this is the best for him/her, but currently user does not
 have this option to choose, it is always masked with bracket). And I also
 want this acquire and release parts to be available separately to the
 user.

 Maybe I have to do one step back and rethink everything. I started from
 bracket and now I am trying to modify a bracket to suit my needs by maybe
 it should be simply something else to begin with.

 > That wouldn't be safe either, because there would be a window at the end
 of the acquire action with exceptions unblocked.

 True. It seems the correct approach is not that whole acquire action is
 unmasked, but that somewhere internally it can be unmasked (where acquire
 action can make sure everything is correctly handled).

 > Right, so here you can receive an exception after the `forkIO`, and
 `doSomethingWithThread` will not be executed.

 This is not the problem. The problem is that `killThread` is not executed.

 > Wouldn't that solve your problem?

 Yes. In my particular instance it would. Please add also a version for
 `forkOnIO`.

 But I still argue that we need also:

 {{{
 bracketWithUnmask :: ((forall a. IO a -> IO a) -> IO a) -> (a -> IO b) ->
 (a -> IO c) -> IO c
 }}}

 Although it seems it will not be useful in my case as I would have to
 change type signature for acquire function.

-- 
Ticket URL: <http://hackage.haskell.org/trac/ghc/ticket/4810#comment:4>
GHC <http://www.haskell.org/ghc/>
The Glasgow Haskell Compiler

_______________________________________________
Glasgow-haskell-bugs mailing list
Glasgow-haskell-bugs@haskell.org
http://www.haskell.org/mailman/listinfo/glasgow-haskell-bugs

Reply via email to