packages feed

exceptions 0.10.10 → 0.10.11

raw patch · 5 files changed

+86/−10 lines, 5 filesPVP ok

version bump matches the API change (PVP)

API changes (from Hackage documentation)

Files

.gitignore view
@@ -36,3 +36,6 @@ dist-install GNUmakefile ghc.mk++# MHS+dist-mcabal
CHANGELOG.markdown view
@@ -1,3 +1,13 @@+0.10.11 [2025.10.13]+--------------------+* Add a `rethrowM` method to the `MonadThrow` class and a `catchNoPropagate`+  method to the `MonadCatch` class, which are available when building with+  `base-4.21` (GHC 9.12) or later. These are like `throwM` and `catch`,+  respectively (and use them as their default implementations), but these+  methods do not add new backtraces (for `rethrowM`) or annotate the handler+  with the exception that was caught (for `catchNoPropagate`).+* Support building with MicroHs.+ 0.10.10 [2025.06.17] -------------------- * Replace `test-framework` with `tasty` in the test suite.
exceptions.cabal view
@@ -1,6 +1,6 @@ name:          exceptions category:      Control, Exceptions, Monad-version:       0.10.10+version:       0.10.11 cabal-version: >= 1.10 license:       BSD3 license-file:  LICENSE@@ -45,8 +45,10 @@     base                       >= 4.9      && < 5,     mtl                        >= 2.2      && < 2.4,     stm                        >= 2.2      && < 3,-    template-haskell           >= 2.11     && < 2.25,     transformers               >= 0.5.2.0  && < 0.7+  if impl(ghc)+    build-depends:+      template-haskell         >= 2.11     && < 2.25    exposed-modules:     Control.Monad.Catch@@ -73,4 +75,4 @@     tasty            >= 1.4     && < 1.6,     tasty-hunit      >= 0.10    && < 0.11,     tasty-quickcheck >= 0.10    && < 0.12,-    QuickCheck       >= 2.5     && < 2.17+    QuickCheck       >= 2.5     && < 2.18
src/Control/Monad/Catch.hs view
@@ -1,15 +1,17 @@ {-# LANGUAGE CPP #-} {-# LANGUAGE ExistentialQuantification #-}-{-# LANGUAGE GeneralizedNewtypeDeriving #-}-{-# LANGUAGE RankNTypes #-} {-# LANGUAGE FlexibleInstances #-}+{-# LANGUAGE GeneralizedNewtypeDeriving #-} {-# LANGUAGE MultiParamTypeClasses #-}-{-# LANGUAGE UndecidableInstances #-}+{-# LANGUAGE RankNTypes #-}+{-# LANGUAGE ScopedTypeVariables #-}+{-# LANGUAGE Trustworthy #-}+{-# LANGUAGE TypeApplications #-} {-# LANGUAGE TypeFamilies #-} {-# LANGUAGE TypeOperators #-}-{-# LANGUAGE Trustworthy #-}+{-# LANGUAGE UndecidableInstances #-} -#if !(MIN_VERSION_transformers(0,6,0))+#if !MIN_VERSION_transformers(0,6,0) {-# OPTIONS_GHC -Wno-deprecations #-} #endif --------------------------------------------------------------------@@ -91,9 +93,14 @@  import GHC.Stack (HasCallStack, withFrozenCallStack) +#if defined(__MHS__)+import Prelude hiding(foldr)+import Data.Foldable+#else import Language.Haskell.TH.Syntax (Q)+#endif -#if !(MIN_VERSION_transformers(0,6,0))+#if !MIN_VERSION_transformers(0,6,0) import Control.Monad.Trans.Error (ErrorT(..), Error, runErrorT) import Control.Monad.Trans.List (ListT(..), runListT) #endif@@ -121,6 +128,18 @@   -- > throwM e >> f = throwM e   throwM :: (HasCallStack, Exception e) => e -> m a +#if MIN_VERSION_base(4,21,0)+  -- | A utility to use when rethrowing exceptions, no new backtrace will be+  -- attached when rethrowing an exception but you must supply the existing+  -- context.+  --+  -- It is a generalization of "Control.Exception"'s+  -- 'ControlException.rethrowIO' and is only defined using @base-4.21@ (GHC+  -- 9.12) or later.+  rethrowM :: Exception e => ControlException.ExceptionWithContext e -> m a+  rethrowM = throwM+#endif+ -- | A class for monads which allow exceptions to be caught, in particular -- exceptions which were thrown by 'throwM'. --@@ -140,6 +159,20 @@   -- constrain which exceptions are caught. See "Control.Exception"'s   -- 'ControlException.catch'.   catch :: (HasCallStack, Exception e) => m a -> (e -> m a) -> m a+#if MIN_VERSION_base(4,21,0)+  -- | A variant of 'catch' which doesn't annotate the handler with the exception+  -- which was caught. This function should be used when you are implementing+  -- your own error handling functions which may rethrow the exceptions.+  --+  -- In the case where you rethrow an exception without modifying it, you+  -- should rethrow the exception with the old exception context.+  --+  -- It is a generalization of "Control.Exception"'s+  -- 'ControlException.catchNoPropagate' and is only defined using @base-4.21@+  -- (GHC 9.12) or later.+  catchNoPropagate :: Exception e => m a -> (ControlException.ExceptionWithContext e -> m a) -> m a+  catchNoPropagate = catch+#endif  -- | A class for monads which provide for the ability to account for -- all possible exit points from a computation, and to mask@@ -301,26 +334,51 @@   throwM _ = [] instance MonadThrow Maybe where   throwM _ = Nothing+#if !defined(__MHS__) instance MonadThrow Q where   throwM = fail . show+#endif  instance MonadThrow IO where   throwM = ControlException.throwIO+#if MIN_VERSION_base(4,21,0)+  rethrowM = ControlException.rethrowIO+#endif instance MonadCatch IO where   catch = ControlException.catch+#if MIN_VERSION_base(4,21,0)+  catchNoPropagate = ControlException.catchNoPropagate+#endif instance MonadMask IO where   mask = ControlException.mask   uninterruptibleMask = ControlException.uninterruptibleMask+++#if MIN_VERSION_base(4,21,0)   generalBracket acquire release use = mask $ \unmasked -> do     resource <- acquire++    b <- unmasked (use resource) `catchNoPropagate` \e -> do+      _ <- release resource (ExitCaseException $ ControlException.toException e)+      rethrowM @IO @SomeException e+    c <- release resource (ExitCaseSuccess b)+    return (b, c)+#else+  generalBracket acquire release use = mask $ \unmasked -> do+    resource <- acquire+     b <- unmasked (use resource) `catch` \e -> do       _ <- release resource (ExitCaseException e)       throwM e     c <- release resource (ExitCaseSuccess b)     return (b, c)+#endif  instance MonadThrow (ST s) where   throwM = unsafeIOToST . ControlException.throwIO+#if MIN_VERSION_base(4,21,0)+  rethrowM = unsafeIOToST . ControlException.rethrowIO+#endif  instance MonadThrow STM where   throwM = STM.throwSTM@@ -654,7 +712,7 @@ -- I don't believe any valid of MonadCatch exists for ContT. -- instance MonadCatch m => MonadCatch (ContT r m) where -#if !(MIN_VERSION_transformers(0,6,0))+#if !MIN_VERSION_transformers(0,6,0) -- | Throws exceptions into the base monad. instance (Error e, MonadThrow m) => MonadThrow (ErrorT e m) where   throwM = lift . throwM
src/Control/Monad/Catch/Pure.hs view
@@ -50,6 +50,9 @@ import Control.Monad.Writer (MonadWriter(..)) import Data.Functor.Identity import Data.Traversable as Traversable+#if defined(__MHS__)+import Data.Foldable+#endif  ------------------------------------------------------------------------------ -- $mtl