`shrinkBoundedEnum`?!
I have a small sum type that currently uses genericShrink:
data SmallSum = A | B | C | D
deriving (Eq, Ord, Read, Show, Generic, Enum, Bounded)
instance Arbitrary SmallSum where
arbitrary = QC.arbitraryBoundedEnum
shrink = QC.genericShrink
genericShrink is useless in this case though, since there are no subterms that it could shrink to. From the haddocks:
Shrink a term to any of its immediate subterms, and also recursively shrink all subterms.
What I'd like to have is a function that shrinks a constructor to the "smaller" constructors, either
f1 A = []
f1 B = [A]
f1 C = [A,B]
f1 D = [A,B,C]
or
f2 A = []
f2 B = [A]
f2 C = [B]
f2 D = [C]
Could one of these functions (or a variation) be added as shrinkBoundedEnum in analogy to arbitraryBoundedEnum?!
Maybe an implementation in terms of shrinkIntegral would make sense. For a large type you possibly wouldn't want to shrink to all the smaller constructors, but shrinking to an "interesting" selection of them would be useful.
@sjakobi
I've created a PR that may resolve this issue here: https://github.com/nick8325/quickcheck/pull/350
Fixed by #350.
@sjakobi just in case you're still interested, the latest Hackage release has shrinkBoundedEnum: 🎉
https://hackage.haskell.org/package/QuickCheck-2.14.3/docs/Test-QuickCheck.html#v:shrinkBoundedEnum