retry 0.7.4.3 → 0.7.5.0
raw patch · 3 files changed
+24/−1 lines, 3 filesdep ~basePVP ok
version bump matches the API change (PVP)
Dependency ranges changed: base
API changes (from Hackage documentation)
+ Control.Retry: instance GHC.Base.Monad m => Data.Semigroup.Semigroup (Control.Retry.RetryPolicyM m)
Files
- changelog.md +3/−0
- retry.cabal +1/−1
- src/Control/Retry.hs +20/−0
changelog.md view
@@ -1,3 +1,6 @@+0.7.5.0+* Add Semigroup instance when the Semigroup class is available through base.+ 0.7.4.3 * Loosen dependency upper bounds.
retry.cabal view
@@ -14,7 +14,7 @@ case we should hang back for a bit and retry the query instead of simply raising an exception. -version: 0.7.4.3+version: 0.7.5.0 synopsis: Retry combinators for monadic actions that may fail license: BSD3 license-file: LICENSE
src/Control/Retry.hs view
@@ -94,7 +94,11 @@ import GHC.Prim import GHC.Types (Int(I#)) import System.Random+# if MIN_VERSION_base(4, 9, 0)+import Data.Semigroup+# else import Data.Monoid+# endif import Prelude hiding (catch) ------------------------------------------------------------------------------- @@ -149,12 +153,28 @@ def = constantDelay 50000 <> limitRetries 5 +-- Base 4.9.0 adds a Data.Semigroup module. This has fewer+-- dependencies than the semigroups package, so we're using base's+-- only if its available.+# if MIN_VERSION_base(4, 9, 0)+instance Monad m => Semigroup (RetryPolicyM m) where+ (RetryPolicyM a) <> (RetryPolicyM b) = RetryPolicyM $ \ n -> runMaybeT $ do+ a' <- MaybeT $ a n+ b' <- MaybeT $ b n+ return $! max a' b'++ instance Monad m => Monoid (RetryPolicyM m) where mempty = retryPolicy $ const (Just 0)+ mappend = (<>)+# else+instance Monad m => Monoid (RetryPolicyM m) where+ mempty = retryPolicy $ const (Just 0) (RetryPolicyM a) `mappend` (RetryPolicyM b) = RetryPolicyM $ \ n -> runMaybeT $ do a' <- MaybeT $ a n b' <- MaybeT $ b n return $! max a' b'+#endif -------------------------------------------------------------------------------