Skip to content

Commit

Permalink
instances of CoArbitrary
Browse files Browse the repository at this point in the history
  • Loading branch information
MaximilianAlgehed committed Mar 21, 2024
1 parent cbe44c4 commit 04769c6
Showing 1 changed file with 16 additions and 0 deletions.
16 changes: 16 additions & 0 deletions src/Test/QuickCheck/Arbitrary.hs
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down

0 comments on commit 04769c6

Please sign in to comment.