;$9     (Ozgun Ataman <ozgun.ataman@soostone.com>BSD3 Ozgun Ataman provisional Safe-Inferred  36HM A  is a function that takes an iteration number and possibly returns a delay in microseconds. *Nothing* implies we have reached the retry limit.Please note that  is a 7. You can collapse multiple strategies into one using  or 4. The semantics of this combination are as follows: If either policy returns , the combined policy returns . This can be used to inhibit) after a number of retries, for example.If both policies return a delay, the larger delay will be used. This is quite natural when combining multiple policies to achieve a certain effect.Example:VOne can easily define an exponential backoff policy with a limited number of retries: :> limitedBackoff = exponentialBackoff 50 <> limitRetries 5 Naturally, d will retry immediately (delay 0) for an unlimited number of retries, forming the identity for the .The default under 1 implements a constant 50ms delay, up to 5 times: -> def = constantDelay 50000 <> limitRetries 50For anything more complex, just define your own : J> myPolicy = RetryPolicy $ \ n -> if n > 10 then Just 1000 else Just 10000"Retry immediately, but only up to n times.Add an upperbound to a policy such that once the given time-delay amount has been reached or exceeded, the policy will stop retrying and fail.2Implement a constant delay with unlimited retries.(Grow delay exponentially each iteration.Implement Fibonacci backoff. Set a time-upperbound for any delays that may be directed by the given policy. This function does not terminate the retrying. The policy `capDelay maxDelay (exponentialBackoff n)` will never stop retrying. It will reach a state where it retries forever with a delay of maxDelayD between each one. To get termination you need to use one of the  function variants. ~Retry combinator for actions that don't raise exceptions, but signal in their type the outcome has failed. Examples are the ,  and EitherT monads.zLet's write a function that always fails and watch this combinator retry it 5 additional times following the initial run:import Data.Maybe3let f = putStrLn "Running action" >> return Nothing+retrying def (const $ return . isNothing) fRunning actionRunning actionRunning actionRunning actionRunning actionRunning actionNothingVNote how the latest failing result is returned after all retries have been exhausted. aRetry ALL exceptions that may be raised. To be used with caution; this matches the exception on ._See how the action below is run once and retried 5 more times before finally failing for good:=let f = putStrLn "Running action" >> error "this is an error"recoverAll def fRunning actionRunning actionRunning actionRunning actionRunning actionRunning action*** Exception: this is an error hRun an action and recover from a raised exception by potentially retrying the action a number of times. LHelper function for constructing handler functions of the form required by  .Maximum number of retries."Time-delay limit in microseconds. Base delay in microsecondsBase delay in microsecondsBase delay in microseconds A maximum delay in microseconds dAn action to check whether the result should be retried. If True, we delay and retry the operation. Action to run  Just use  for default settingsRShould a given exception be retried? Action will be retried if this returns True.Action to perform (Test for whether action is to be retried,How to report the generated warning message. Retry number          retry-0.6 Control.Retrybase Data.Monoid<> RetryPolicygetRetryPolicy limitRetrieslimitRetriesByDelay constantDelayexponentialBackofffibonacciBackoffcapDelayretrying recoverAll recovering logRetriesMonoidmappend Data.MaybeNothingmemptydata-default-class-0.0.1Data.Default.ClassdefMaybe Data.EitherEither GHC.Exception SomeException$fMonoidRetryPolicy$fDefaultRetryPolicy