Currently we define
|
instance (Arbitrary1 f, Arbitrary1 g, Arbitrary a) => Arbitrary (Compose f g a) where |
|
arbitrary = arbitrary1 |
|
shrink = shrink1 |
That's more restrictive than it can be, it would be nice to relax the constraint to Arbitrary (f (g a)) as in
instance Arbitrary (f (g a)) => Arbitrary (Compose f g a) where
arbitrary = Compose <$> arbitrary
shrink (Compose x) = map Compose (shrink x)
This would bring the approach in line with how base defines all other instances for Compose:
instance Num (f (g a)) => Num (Compose f g a)
instance Read (f (g a)) => Read (Compose f g a)
instance Fractional (f (g a)) => Fractional (Compose f g a)
instance Integral (f (g a)) => Integral (Compose f g a)
instance Real (f (g a)) => Real (Compose f g a)
instance RealFrac (f (g a)) => RealFrac (Compose f g a)
instance Show (f (g a)) => Show (Compose f g a)
Currently we define
quickcheck/src/Test/QuickCheck/Arbitrary.hs
Lines 1016 to 1018 in 3c2d0d8
That's more restrictive than it can be, it would be nice to relax the constraint to
Arbitrary (f (g a))as inThis would bring the approach in line with how
basedefines all other instances forCompose: