exceptions 0.3.1 → 0.3.2
raw patch · 4 files changed
+34/−1 lines, 4 filesPVP ok
version bump matches the API change (PVP)
API changes (from Hackage documentation)
+ Control.Monad.Catch: handleAll :: MonadCatch m => (SomeException -> m a) -> m a -> m a
+ Control.Monad.Catch: handleIOError :: MonadCatch m => (IOError -> m a) -> m a -> m a
+ Control.Monad.Catch: handleIf :: (MonadCatch m, Exception e) => (e -> Bool) -> (e -> m a) -> m a -> m a
Files
- CHANGELOG.markdown +5/−0
- exceptions.cabal +1/−1
- src/Control/Monad/Catch.hs +15/−0
- src/Control/Monad/Catch/Pure.hs +13/−0
CHANGELOG.markdown view
@@ -1,3 +1,8 @@+0.3.2+-----+* Better documentation for `CatchT`.+* Added `handle`-like analogues for parity with `Control.Exception`.+ 0.3.1 ----- * Fixed test suite.
exceptions.cabal view
@@ -1,6 +1,6 @@ name: exceptions category: Control, Exceptions, Monad-version: 0.3.1+version: 0.3.2 cabal-version: >= 1.8 license: OtherLicense license-file: LICENSE
src/Control/Monad/Catch.hs view
@@ -70,7 +70,10 @@ , catchIf , Handler(..), catches , handle+ , handleAll+ , handleIOError , handleJust+ , handleIf , try , tryJust , onException@@ -253,6 +256,18 @@ handle :: (MonadCatch m, Exception e) => (e -> m a) -> m a -> m a handle = flip catch {-# INLINE handle #-}++-- | Flipped 'catchIOError'+handleIOError :: MonadCatch m => (IOError -> m a) -> m a -> m a+handleIOError = handle++-- | Flipped 'catchAll'+handleAll :: MonadCatch m => (SomeException -> m a) -> m a -> m a+handleAll = handle++-- | Flipped 'catchIf'+handleIf :: (MonadCatch m, Exception e) => (e -> Bool) -> (e -> m a) -> m a -> m a+handleIf f = flip (catchIf f) -- | Flipped 'catchJust'. See "Control.Exception"'s 'ControlException.handleJust'. handleJust :: (MonadCatch m, Exception e) => (e -> Maybe b) -> (b -> m a) -> m a -> m a
src/Control/Monad/Catch/Pure.hs view
@@ -90,6 +90,19 @@ -- This should /never/ be used in combination with 'IO'. Think of 'CatchT' -- as an alternative base monad for use with mocking code that solely throws -- exceptions via 'throwM'.+--+-- Note: that 'IO' monad has these abilities already, so stacking 'CatchT' on top+-- of it does not add any value and can possibly be confusing:+--+-- >>> (error "Hello!" :: IO ()) `catch` (\(e :: ErrorCall) -> liftIO $ print e)+-- Hello!+--+-- >>> runCatchT $ (error "Hello!" :: CatchT IO ()) `catch` (\(e :: ErrorCall) -> liftIO $ print e)+-- *** Exception: Hello!+--+-- >>> runCatchT $ (throwM (ErrorCall "Hello!") :: CatchT IO ()) `catch` (\(e :: ErrorCall) -> liftIO $ print e)+-- Hello!+ newtype CatchT m a = CatchT { runCatchT :: m (Either SomeException a) } type Catch = CatchT Identity