checkers 0.5.7 → 0.6.0
raw patch · 4 files changed
+55/−19 lines, 4 filesdep ~semigroupoidsPVP ok
version bump matches the API change (PVP)
Dependency ranges changed: semigroupoids
API changes (from Hackage documentation)
- Test.QuickCheck.Instances.Array: instance (GHC.Ix.Ix a, Test.QuickCheck.Arbitrary.CoArbitrary b) => Test.QuickCheck.Arbitrary.CoArbitrary (GHC.Arr.Array a b)
+ Test.QuickCheck.Instances.Array: instance Test.QuickCheck.Arbitrary.CoArbitrary b => Test.QuickCheck.Arbitrary.CoArbitrary (GHC.Arr.Array a b)
- Test.QuickCheck.Classes: traversable :: forall f a b m. (Traversable f, Monoid m, Show (f a), Arbitrary (f a), Arbitrary b, Arbitrary m, CoArbitrary a, EqProp (f b), EqProp m) => f (a, b, m) -> TestBatch
+ Test.QuickCheck.Classes: traversable :: forall t a b c m f g. (Traversable t, Applicative f, Applicative g, Monoid m, Arbitrary (t a), Arbitrary (t b), Arbitrary (f b), Arbitrary (g c), Arbitrary (t (f (g a))), Arbitrary m, Arbitrary b, CoArbitrary a, CoArbitrary b, Show (t a), Show (t b), Show (t (f (g a))), EqProp (t b), EqProp m, EqProp (f (g (t a))), EqProp (f (g (t c)))) => t (f a, g b, c, m) -> TestBatch
Files
- CHANGELOG.md +8/−0
- checkers.cabal +1/−1
- src/Test/QuickCheck/Classes.hs +45/−12
- src/Test/QuickCheck/Instances/Array.hs +1/−6
CHANGELOG.md view
@@ -1,3 +1,11 @@+## [0.6.0]++* [Enhance `traversable` checks](https://github.com/haskell-checkers/checkers/pull/61)++* [Remove redundant constraint from instance CoArbitrary Array](https://github.com/haskell-checkers/checkers/pull/65)++[0.6.0]: https://github.com/haskell-checkers/checkers/compare/v0.5.7...v0.6.0+ ## [0.5.7] * [Add `bifoldable` and `bifoldableBifunctor` tests](https://github.com/haskell-checkers/checkers/pull/62)
checkers.cabal view
@@ -1,5 +1,5 @@ Name: checkers-Version: 0.5.7+Version: 0.6.0 Cabal-Version: >= 1.10 Synopsis: Check properties on standard classes and data structures. Category: Testing
src/Test/QuickCheck/Classes.hs view
@@ -1,5 +1,5 @@ {-# LANGUAGE ScopedTypeVariables, FlexibleContexts, KindSignatures- , Rank2Types, TypeOperators, CPP+ , Rank2Types, TypeApplications, TypeOperators, CPP #-} ----------------------------------------------------------------------@@ -35,6 +35,8 @@ import Data.Functor.Alt (Alt ((<!>))) import Data.Functor.Bind (Bind ((>>-)), apDefault) import qualified Data.Functor.Bind as B (Bind (join))+import Data.Functor.Compose (Compose (..))+import Data.Functor.Identity (Identity (..)) import Data.List.NonEmpty (NonEmpty(..)) import Data.Semigroup (Semigroup (..)) import Data.Monoid (Endo(..), Dual(..), Sum(..), Product(..))@@ -719,24 +721,53 @@ rightMovesP f g = (left f >>> right (arr g)) =-= ((right (arr g)) >>> left f) -traversable :: forall f a b m.- ( Traversable f, Monoid m, Show (f a)- , Arbitrary (f a), Arbitrary b, Arbitrary m- , CoArbitrary a- , EqProp (f b), EqProp m) =>- f (a, b, m) -> TestBatch-traversable = const ( "traversable"- , [ ("fmap", property fmapP)+traversable :: forall t a b c m f g.+ ( Traversable t, Applicative f, Applicative g, Monoid m+ , Arbitrary (t a), Arbitrary (t b), Arbitrary (f b), Arbitrary (g c)+ , Arbitrary (t (f (g a)))+ , Arbitrary m, Arbitrary b+ , CoArbitrary a, CoArbitrary b+ , Show (t a), Show (t b), Show (t (f (g a)))+ , EqProp (t b), EqProp m, EqProp (f (g (t a))), EqProp (f (g (t c)))) => t (f a, g b, c, m)+ -> TestBatch+traversable = const ( "Traversable"+ , [ ("identity", property identityP)+ , ("composition", property compositionP)+ -- , ("naturality", property $ \(f :: f Int -> g Int) -> naturalityP f)+ , ("fmap", property fmapP) , ("foldMap", property foldMapP)+ , ("sequenceA identity", property sequenceIdentityP)+ , ("sequenceA composition", property sequenceCompositionP)+ -- , ("sequenceA naturality", property $ \(f :: f a -> g a) -> sequenceNaturalityP f) ] ) where- fmapP :: (a -> b) -> f a -> Property- foldMapP :: (a -> m) -> f a -> Property+ identityP :: Property+ identityP = traverse @t @_ @b Identity =-= Identity + compositionP :: (a -> f b) -> (b -> g c) -> Property+ compositionP f g = traverse @t (Compose . fmap g . f) =-= Compose . fmap (traverse g) . traverse f++ --FIXME: Does not compile due to rank2 type.+ --naturalityP :: (forall x. (f x -> g x)) -> (a -> f b) -> Property+ --naturalityP t f = t . traverse @t f =-= traverse (t . f)++ fmapP :: (a -> b) -> t a -> Property fmapP f x = f `fmap` x =-= f `fmapDefault` x- foldMapP f x = f `foldMap` x =-= f `foldMapDefault` x + foldMapP :: (a -> m) -> t a -> Property+ foldMapP f x = f `foldMap` x =-= (f `foldMapDefault` x :: m)++ sequenceIdentityP :: Property+ sequenceIdentityP = sequenceA @t @_ @b . fmap Identity =-= Identity++ sequenceCompositionP :: Property+ sequenceCompositionP = sequenceA @t @(Compose f g) @a . fmap Compose =-= Compose . fmap sequenceA . sequenceA++ --FIXME: Does not compile due to rank2 type.+ --sequenceNaturalityP :: (forall x. (f x -> g x)) -> Property+ --sequenceNaturalityP t = t . sequenceA @t @_ @a =-= sequenceA . fmap t+ -- | Note that 'foldable' doesn't check the strictness of 'foldl'', `foldr'' and `foldMap''. -- -- @since 0.4.13@@ -829,6 +860,7 @@ foldMapP :: (a -> m) -> t a -> Property foldMapP f t = foldMap f t =-= fold (fmap f t) +-- | @since 0.5.7 bifoldable :: forall p a b c m. ( Bifoldable p, Monoid m , Show (p a b), Show (p m m)@@ -852,6 +884,7 @@ bifoldrBifoldMapP :: (a -> c -> c) -> (b -> c -> c) -> c -> p a b -> Property bifoldrBifoldMapP f g z t = bifoldr f g z t =-= appEndo (bifoldMap (Endo . f) (Endo . g) t) z +-- | @since 0.5.7 bifoldableBifunctor :: forall p a b m. ( Bifoldable p, Bifunctor p, Monoid m , Show (p a b)
src/Test/QuickCheck/Instances/Array.hs view
@@ -1,19 +1,14 @@ {-# LANGUAGE CPP #-} {-# OPTIONS_GHC -Wall -fno-warn-orphans #-}-#if MIN_VERSION_base(4,9,0)--- https://github.com/conal/checkers/pull/38-{-# OPTIONS_GHC -Wno-redundant-constraints #-}-#endif module Test.QuickCheck.Instances.Array where import Test.QuickCheck import Data.Array --- The redundant (Ix a) constraint is required with GHC-7.10. instance (Ix a, Integral a, Arbitrary b) => Arbitrary (Array a b) where arbitrary = (\x -> listArray (0,fromIntegral (length x - 1)) x) <$> arbitrary -instance (Ix a, CoArbitrary b) => CoArbitrary (Array a b) where+instance (CoArbitrary b) => CoArbitrary (Array a b) where coarbitrary = coarbitrary . elems