Closed jonathanknowles closed 1 year ago
Hi @nick8325
Just wondering if you think this function would be useful? If you like the idea, but you'd like me to make revisions to it -- let me know, would be happy to do so.
All the best! Jonathan
It looks good! Thanks for the patch!
It looks good! Thanks for the patch!
You're welcome!
This PR adds a new function
shrinkBoundedEnum
, which should resolve issue https://github.com/nick8325/quickcheck/issues/343.The
shrinkBoundedEnum
function provides a counterpart to the pre-existingarbitraryBoundedEnum
function. Together, they can be used to define a completeArbitrary
instance for a bounded enumeration data type.For example, let's say we have the following (admittedly contrived) type:
We can then define the following
Arbitrary
instance:Since
shrinkBoundedEnum
reusesshrinkIntegral
internally, we get similar shrinking behaviour: values earlier in the shrink list are shrunk more aggressively, followed by the usual exponential back-off: