quickcheck-instances 0.3.15 → 0.3.16
raw patch · 3 files changed
+96/−1 lines, 3 filesdep ~hashable
Dependency ranges changed: hashable
Files
- CHANGES +4/−0
- quickcheck-instances.cabal +1/−1
- src/Test/QuickCheck/Instances.hs +91/−0
CHANGES view
@@ -1,3 +1,7 @@+0.3.16++* Instances for `Semigroup` newtypes: `Min`, `Max`, `First`, `Last`, `Option` and `WrappedMonoid`.+ 0.3.15 * `QuickCheck-2.10` support.
quickcheck-instances.cabal view
@@ -1,5 +1,5 @@ Name: quickcheck-instances-Version: 0.3.15+Version: 0.3.16 Synopsis: Common quickcheck instances Description: QuickCheck instances. .
src/Test/QuickCheck/Instances.hs view
@@ -55,6 +55,7 @@ import qualified Data.HashMap.Lazy as HML import qualified Data.HashSet as HS import qualified Data.Scientific as Scientific+import qualified Data.Semigroup as Semi import qualified Data.Tagged as Tagged (Tagged (..)) import qualified Data.Text as TS import qualified Data.Text.Lazy as TL@@ -575,6 +576,96 @@ where g (x :| xs) = (x, xs) h (x, xs) = x :| xs+++instance Arbitrary1 Semi.Min where+ liftArbitrary arb = Semi.Min <$> arb+ liftShrink shr = map Semi.Min . shr . Semi.getMin++instance Arbitrary a => Arbitrary (Semi.Min a) where+ arbitrary = arbitrary1+ shrink = shrink1++instance CoArbitrary a => CoArbitrary (Semi.Min a) where+ coarbitrary = coarbitrary . Semi.getMin++instance Function a => Function (Semi.Min a) where+ function = functionMap Semi.getMin Semi.Min+++instance Arbitrary1 Semi.Max where+ liftArbitrary arb = Semi.Max <$> arb+ liftShrink shr = map Semi.Max . shr . Semi.getMax++instance Arbitrary a => Arbitrary (Semi.Max a) where+ arbitrary = arbitrary1+ shrink = shrink1++instance CoArbitrary a => CoArbitrary (Semi.Max a) where+ coarbitrary = coarbitrary . Semi.getMax++instance Function a => Function (Semi.Max a) where+ function = functionMap Semi.getMax Semi.Max+++instance Arbitrary1 Semi.First where+ liftArbitrary arb = Semi.First <$> arb+ liftShrink shr = map Semi.First . shr . Semi.getFirst++instance Arbitrary a => Arbitrary (Semi.First a) where+ arbitrary = arbitrary1+ shrink = shrink1++instance CoArbitrary a => CoArbitrary (Semi.First a) where+ coarbitrary = coarbitrary . Semi.getFirst++instance Function a => Function (Semi.First a) where+ function = functionMap Semi.getFirst Semi.First+++instance Arbitrary1 Semi.Last where+ liftArbitrary arb = Semi.Last <$> arb+ liftShrink shr = map Semi.Last . shr . Semi.getLast++instance Arbitrary a => Arbitrary (Semi.Last a) where+ arbitrary = arbitrary1+ shrink = shrink1++instance CoArbitrary a => CoArbitrary (Semi.Last a) where+ coarbitrary = coarbitrary . Semi.getLast++instance Function a => Function (Semi.Last a) where+ function = functionMap Semi.getLast Semi.Last+++instance Arbitrary1 Semi.WrappedMonoid where+ liftArbitrary arb = Semi.WrapMonoid <$> arb+ liftShrink shr = map Semi.WrapMonoid . shr . Semi.unwrapMonoid++instance Arbitrary a => Arbitrary (Semi.WrappedMonoid a) where+ arbitrary = arbitrary1+ shrink = shrink1++instance CoArbitrary a => CoArbitrary (Semi.WrappedMonoid a) where+ coarbitrary = coarbitrary . Semi.unwrapMonoid++instance Function a => Function (Semi.WrappedMonoid a) where+ function = functionMap Semi.unwrapMonoid Semi.WrapMonoid+++instance Arbitrary1 Semi.Option where+ liftArbitrary arb = Semi.Option <$> liftArbitrary arb+ liftShrink shr = map Semi.Option . liftShrink shr . Semi.getOption++instance Arbitrary a => Arbitrary (Semi.Option a) where+ arbitrary = arbitrary1+ shrink = shrink1++instance CoArbitrary a => CoArbitrary (Semi.Option a) where+ coarbitrary = coarbitrary . Semi.getOption++instance Function a => Function (Semi.Option a) where+ function = functionMap Semi.getOption Semi.Option ------------------------------------------------------------------------------- -- transformers