quickcheck-instances 0.3.26.1 → 0.3.27
raw patch · 3 files changed
+39/−2 lines, 3 filesdep ~textdep ~vector
Dependency ranges changed: text, vector
Files
CHANGES view
@@ -1,3 +1,7 @@+0.3.27++* Add instances for `Backwards`, `Reverse` and `Lift` from `transformers`+ 0.3.26.1 * Support `hashable-1.4`
quickcheck-instances.cabal view
@@ -1,5 +1,5 @@ name: quickcheck-instances-version: 0.3.26.1+version: 0.3.27 synopsis: Common quickcheck instances description: QuickCheck instances.@@ -111,7 +111,7 @@ build-depends: time if !impl(ghc >=8.0)- build-depends: semigroups >=0.18.5 && <0.20+ build-depends: semigroups >=0.18.5 && <0.21 if !impl(ghc >=7.10) build-depends:
src/Test/QuickCheck/Instances/Transformer.hs view
@@ -6,6 +6,10 @@ import Prelude () import Test.QuickCheck.Instances.CustomPrelude +import Control.Applicative.Backwards (Backwards (..))+import Control.Applicative.Lift (Lift (..))+import Data.Functor.Reverse (Reverse (..))+ import Control.Monad.Trans.Maybe (MaybeT (..)) import Data.Functor.Sum (Sum (..)) @@ -31,5 +35,34 @@ liftShrink shr (InR g) = map InR (liftShrink shr g) instance (Arbitrary1 f, Arbitrary1 g, Arbitrary a) => Arbitrary (Sum f g a) where+ arbitrary = arbitrary1+ shrink = shrink1++instance Arbitrary1 f => Arbitrary1 (Backwards f) where+ liftArbitrary arb = fmap Backwards (liftArbitrary arb)+ liftShrink shr (Backwards xs) = map Backwards (liftShrink shr xs)++instance (Arbitrary1 f, Arbitrary a) => Arbitrary (Backwards f a) where+ arbitrary = arbitrary1+ shrink = shrink1++instance Arbitrary1 f => Arbitrary1 (Reverse f) where+ liftArbitrary arb = fmap Reverse (liftArbitrary arb)+ liftShrink shr (Reverse xs) = map Reverse (liftShrink shr xs)++instance (Arbitrary1 f, Arbitrary a) => Arbitrary (Reverse f a) where+ arbitrary = arbitrary1+ shrink = shrink1++instance Arbitrary1 f => Arbitrary1 (Lift f) where+ liftArbitrary arb = oneof+ [ fmap Pure arb+ , fmap Other (liftArbitrary arb)+ ]++ liftShrink shr (Pure x) = map Pure (shr x)+ liftShrink shr (Other xs) = map Other (liftShrink shr xs)++instance (Arbitrary1 f, Arbitrary a) => Arbitrary (Lift f a) where arbitrary = arbitrary1 shrink = shrink1