Permalink
Browse files

bracket vs bracket_ comment

  • Loading branch information...
1 parent 3951e14 commit 8c7b44f3d211c8e4eff39e8886cab18b08f2cc51 @snoyberg committed Oct 24, 2010
Showing with 4 additions and 0 deletions.
  1. +4 −0 Control/Monad/Invert.hs
View
4 Control/Monad/Invert.hs
@@ -97,6 +97,9 @@ block action = revertIO $ \a -> E.block $ invertIO action a
unblock :: MonadInvertIO m => m a -> m a
unblock action = revertIO $ \a -> E.unblock $ invertIO action a
+-- | There is a very important distinction between this function and
+-- 'bracket_': in this version, the monadic side effects from the
+-- initialization function and kept, while in bracket_ they are discarded.
bracket :: MonadInvertIO m
=> m a
-> (a -> m b)
@@ -107,6 +110,7 @@ bracket acquire cleanup action = revertIO $ \a -> E.bracket
(\x -> invertIO (revertIO (const $ return x) >>= cleanup) a)
(\x -> invertIO (revertIO (const $ return x) >>= action) a)
+-- | See 'bracket'.
bracket_ :: MonadInvertIO m => m a -> m b -> m c -> m c
bracket_ acquire cleanup action = revertIO $ \a -> E.bracket_
(invertIO acquire a)

0 comments on commit 8c7b44f

Please sign in to comment.