https://github.com/mbg/retry-types
Type-level representations of retry policies in Haskell.
https://github.com/mbg/retry-types
haskell haskell-library retry-strategies types
Last synced: 2 months ago
JSON representation
Type-level representations of retry policies in Haskell.
- Host: GitHub
- URL: https://github.com/mbg/retry-types
- Owner: mbg
- License: mit
- Created: 2022-03-01T22:50:41.000Z (over 3 years ago)
- Default Branch: main
- Last Pushed: 2022-03-01T22:51:00.000Z (over 3 years ago)
- Last Synced: 2025-02-06T09:13:55.336Z (4 months ago)
- Topics: haskell, haskell-library, retry-strategies, types
- Language: Haskell
- Homepage:
- Size: 7.81 KB
- Stars: 0
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- Changelog: ChangeLog.md
- License: LICENSE
Awesome Lists containing this project
README
# retry-types
This small Haskell library contains type-level representations of the retry policies from the [`retry`](https://hackage.haskell.org/package/retry) package along with a type class to reify them to their value-level equivalents. This allows other packages which wish to incorporate retry policies into type-level specifications to do so.
## Example
Each retry policy and retry policy transformer from [`Control.Retry`](https://hackage.haskell.org/package/retry/docs/Control-Retry.html) has an equivalent type in `Control.Retry.Types` with the same name (except starting with an upper-case character). For example, the `ConstantDelay 5` type represents a retry policy with a constant delay of 5 microseconds -- the equivalent of `constantDelay 5` at the value-level. We can reify `ConstantDelay 5` into `constantDelay 5` by using the `retryPolicyVal` function that is part of the `HasRetryPolicy` type class: `retryPolicyVal @(ConstantDelay 5)`.
Type-level retry policies can also be combined with the `(<+>)` type operator. For example, `ConstantDelay 5 <+> LimitRetries 10` is the equivalent of `constantDelay 5 <> limitRetries 10`.