MonadCatchIO-mtl 0.2.0.0 → 0.3.0.0
raw patch · 2 files changed
+46/−5 lines, 2 filesPVP ok
version bump matches the API change (PVP)
API changes (from Hackage documentation)
+ Control.Monad.CatchIO: bracketOnError :: (MonadCatchIO m) => m a -> (a -> m b) -> (a -> m c) -> m c
+ Control.Monad.CatchIO: bracket_ :: (MonadCatchIO m) => m a -> m b -> m c -> m c
+ Control.Monad.CatchIO: finally :: (MonadCatchIO m) => m a -> m b -> m a
- Control.Monad.CatchIO: throw :: (MonadCatchIO m, Exception e) => e -> m a
+ Control.Monad.CatchIO: throw :: (MonadIO m, Exception e) => e -> m a
Files
- Control/Monad/CatchIO.hs +44/−3
- MonadCatchIO-mtl.cabal +2/−2
Control/Monad/CatchIO.hs view
@@ -2,7 +2,8 @@ E.Exception(..), throw, try, tryJust,- onException, bracket,+ onException, bracket, bracket_,+ finally, bracketOnError, Handler(..), catches ) where@@ -28,7 +29,7 @@ unblock :: m a -> m a -- | Generalized version of 'E.throwIO'-throw :: (MonadCatchIO m, E.Exception e) => e -> m a+throw :: (MonadIO m, E.Exception e) => e -> m a -- | Generalized version of 'E.try' try :: (MonadCatchIO m, E.Exception e) => m a -> m (Either e a)@@ -100,9 +101,49 @@ bracket before after thing = block (do a <- before r <- unblock (thing a) `onException` after a- after a+ _void $ after a return r) +-- | A variant of 'bracket' where the return value from the first computation+-- is not required.+bracket_ :: MonadCatchIO m+ => m a -- ^ computation to run first (\"acquire resource\")+ -> m b -- ^ computation to run last (\"release resource\")+ -> m c -- ^ computation to run in-between+ -> m c -- returns the value from the in-between computation+bracket_ before after thing =+ block $ do _void before+ r <- unblock thing `onException` after+ _void after+ return r++-- | A specialised variant of 'bracket' with just a computation to run+-- afterward.+finally :: MonadCatchIO m+ => m a -- ^ computation to run first+ -> m b -- ^ computation to run afterward (even if an exception was+ -- raised)+ -> m a -- returns the value from the first computation+thing `finally` after =+ block $ do r <- unblock thing `onException` after+ _void after+ return r++-- | Like 'bracket', but only performs the final action if there was an+-- exception raised by the in-between computation.+bracketOnError :: MonadCatchIO m+ => m a -- ^ computation to run first (\"acquire resource\")+ -> (a -> m b)-- ^ computation to run last (\"release resource\")+ -> (a -> m c)-- ^ computation to run in-between+ -> m c -- returns the value from the in-between+ -- computation+bracketOnError before after thing =+ block $ do a <- before+ unblock (thing a) `onException` after a+ -- | Generalized version of 'E.onException' onException :: MonadCatchIO m => m a -> m b -> m a onException a onEx = a `catch` (\(e::E.SomeException) -> onEx >> throw e)++_void :: Monad m => m a -> m ()+_void a = a >> return ()
MonadCatchIO-mtl.cabal view
@@ -1,5 +1,5 @@ name: MonadCatchIO-mtl-version: 0.2.0.0+version: 0.3.0.0 description: Provides a monad-transformer version of the @Control.Exception.catch@ function. For this, it defines the @MonadCatchIO@ class, a subset of@@ -17,7 +17,7 @@ tested-with: GHC==6.10 Library- build-depends: base, mtl, extensible-exceptions+ build-depends: base < 5, mtl, extensible-exceptions ghc-options: -Wall extensions: ExistentialQuantification, ScopedTypeVariables