From 04769c6c5377083eec92e616fa5b79d723884726 Mon Sep 17 00:00:00 2001 From: Maximilian Algehed Date: Thu, 21 Mar 2024 11:38:26 +0100 Subject: [PATCH] instances of CoArbitrary --- src/Test/QuickCheck/Arbitrary.hs | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/src/Test/QuickCheck/Arbitrary.hs b/src/Test/QuickCheck/Arbitrary.hs index 1975986b..9f4cee23 100644 --- a/src/Test/QuickCheck/Arbitrary.hs +++ b/src/Test/QuickCheck/Arbitrary.hs @@ -1073,6 +1073,7 @@ instance Arbitrary NewlineMode where instance Arbitrary1 Down where liftArbitrary = fmap Down liftShrink shr (Down a) = Down <$> shr a + instance Arbitrary a => Arbitrary (Down a) where arbitrary = arbitrary1 shrink = shrink1 @@ -1424,6 +1425,21 @@ instance CoArbitrary a => CoArbitrary [a] where instance (Integral a, CoArbitrary a) => CoArbitrary (Ratio a) where coarbitrary r = coarbitrary (numerator r,denominator r) +#if defined(MIN_VERSION_base) +#if MIN_VERSION_base(4,6,0) +instance CoArbitrary a => CoArbitrary (Down a) where + coarbitrary (Down x) = coarbitrary x +#endif +#endif + +#if defined(MIN_VERSION_base) +#if MIN_VERSION_base(4,9,0) +instance CoArbitrary a => CoArbitrary (NonEmpty a) where + coarbitrary (a :| as) = coarbitrary (a, as) +#endif +#endif + + #ifndef NO_FIXED instance HasResolution a => CoArbitrary (Fixed a) where coarbitrary = coarbitraryReal