There is a common idiom used in Control.Concurrent libraries,  as
embodied in the implementation of bracket:

http://www.haskell.org/ghc/docs/7.0-latest/html/libraries/base-4.3.0.0/src/Control-Exception-Base.html#bracket

bracket before after thing =
  mask $ \restore -> do
    a <- before
    r <- restore (thing a) `onException` after a
    _ <- after a
    return r


Is there any particular reason why bracket is not implemented as:

bracket before after thing =
  mask $ \restore -> do
    a <- before
    r <- restore (thing a) `finally` after a
    return r

Is there some subtle semantic difference?   Is there a performance
difference?   It seems like a trivial thing,  but I am genuinely
curious.

Best,
Leon

_______________________________________________
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe

Reply via email to