diff --git a/src/Test/QuickCheck/Arbitrary.hs b/src/Test/QuickCheck/Arbitrary.hs index 2ddfb7f7..3f649f56 100644 --- a/src/Test/QuickCheck/Arbitrary.hs +++ b/src/Test/QuickCheck/Arbitrary.hs @@ -150,6 +150,7 @@ import System.IO #if defined(MIN_VERSION_base) #if MIN_VERSION_base(4,9,0) import Data.List.NonEmpty (NonEmpty(..)) +import qualified Data.Semigroup as Semigroup #endif #endif @@ -1014,6 +1015,18 @@ instance Arbitrary a => Arbitrary (Monoid.Last a) where shrink = map Monoid.Last . shrink . Monoid.getLast #endif +#if defined(MIN_VERSION_base) +#if MIN_VERSION_base(4,9,0) +instance Arbitrary a => Arbitrary (Semigroup.Min a) where + arbitrary = fmap Semigroup.Min arbitrary + shrink = map Semigroup.Min . shrink . Semigroup.getMin + +instance Arbitrary a => Arbitrary (Semigroup.Max a) where + arbitrary = fmap Semigroup.Max arbitrary + shrink = map Semigroup.Max . shrink . Semigroup.getMax +#endif +#endif + #if MIN_VERSION_base(4,8,0) instance Arbitrary (f a) => Arbitrary (Monoid.Alt f a) where arbitrary = fmap Monoid.Alt arbitrary @@ -1584,6 +1597,15 @@ instance CoArbitrary a => CoArbitrary (Monoid.Last a) where coarbitrary = coarbitrary . Monoid.getLast #endif +#if MIN_VERSION_base(4,9,0) +instance CoArbitrary a => CoArbitrary (Semigroup.Min a) where + coarbitrary = coarbitrary . Semigroup.getMin + +instance CoArbitrary a => CoArbitrary (Semigroup.Max a) where + coarbitrary = coarbitrary . Semigroup.getMax +#endif + + #if MIN_VERSION_base(4,8,0) instance CoArbitrary (f a) => CoArbitrary (Monoid.Alt f a) where coarbitrary = coarbitrary . Monoid.getAlt diff --git a/src/Test/QuickCheck/Function.hs b/src/Test/QuickCheck/Function.hs index f2ef5f89..6fa2cc61 100644 --- a/src/Test/QuickCheck/Function.hs +++ b/src/Test/QuickCheck/Function.hs @@ -105,6 +105,7 @@ import GHC.Generics hiding (C) #if defined(MIN_VERSION_base) #if MIN_VERSION_base(4,9,0) import Data.List.NonEmpty (NonEmpty(..)) +import qualified Data.Semigroup as Semigroup #endif #endif @@ -442,13 +443,21 @@ instance Function a => Function (Monoid.Last a) where instance Function a => Function (Down a) where function = functionMap (\(Down a) -> a) Down #endif -#endif #if MIN_VERSION_base(4,8,0) instance Function (f a) => Function (Monoid.Alt f a) where function = functionMap Monoid.getAlt Monoid.Alt #endif +#if MIN_VERSION_base(4,9,0) +instance Function a => Function (Semigroup.Min a) where + function = functionMap Semigroup.getMin Semigroup.Min + +instance Function a => Function (Semigroup.Max a) where + function = functionMap Semigroup.getMax Semigroup.Max +#endif +#endif + -- poly instances instance Function A where