quickcheck-monoid-subclasses 0.3.0.6 → 0.3.0.7
raw patch · 17 files changed
+107/−125 lines, 17 filesdep +hspec-quickcheck-classesdep ~QuickCheckdep ~basedep ~containersPVP ok
version bump matches the API change (PVP)
Dependencies added: hspec-quickcheck-classes
Dependency ranges changed: QuickCheck, base, containers
API changes (from Hackage documentation)
Files
- CHANGELOG.md +5/−0
- LICENSE +1/−1
- README.md +6/−1
- quickcheck-monoid-subclasses.cabal +17/−15
- src/internal/Internal.hs +1/−1
- src/internal/Internal/Semigroup/Eq.hs +1/−1
- src/internal/Internal/Semigroup/Tuple.hs +1/−1
- src/prelude/Internal/Prelude.hs +1/−1
- src/public/Test/QuickCheck/Classes/Monoid/Factorial.hs +1/−1
- src/public/Test/QuickCheck/Classes/Monoid/GCD.hs +1/−1
- src/public/Test/QuickCheck/Classes/Monoid/LCM.hs +1/−1
- src/public/Test/QuickCheck/Classes/Monoid/Monus.hs +1/−1
- src/public/Test/QuickCheck/Classes/Monoid/Null.hs +1/−1
- src/public/Test/QuickCheck/Classes/Semigroup/Cancellative.hs +1/−1
- src/public/Test/QuickCheck/Classes/Semigroup/Factorial.hs +1/−1
- src/test/ClassSpec.hs +67/−36
- src/test/Test/Hspec/Laws.hs +0/−61
CHANGELOG.md view
@@ -1,3 +1,8 @@+# 0.3.0.7++- Added support for GHC `9.14`.+- Revised upper bounds for package dependencies.+ # 0.3.0.6 - Revised upper bounds for package dependencies.
LICENSE view
@@ -186,7 +186,7 @@ same "printed page" as the copyright notice for easier identification within third-party archives. - Copyright © 2022–2025 Jonathan Knowles+ Copyright © 2022–2026 Jonathan Knowles Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License.
README.md view
@@ -1,6 +1,11 @@ # `quickcheck-monoid-subclasses` -<a href="http://jonathanknowles.net/quickcheck-monoid-subclasses/"><img src="https://img.shields.io/badge/API-Documentation-green" /></a>+[](https://hackage.haskell.org/package/quickcheck-monoid-subclasses)+[](https://jonathanknowles.github.io/quickcheck-monoid-subclasses/) ## Overview
quickcheck-monoid-subclasses.cabal view
@@ -1,12 +1,12 @@ cabal-version: 3.0 name: quickcheck-monoid-subclasses-version: 0.3.0.6+version: 0.3.0.7 bug-reports: https://github.com/jonathanknowles/quickcheck-monoid-subclasses/issues license: Apache-2.0 license-file: LICENSE author: Jonathan Knowles maintainer: mail@jonathanknowles.net-copyright: 2022–2025 Jonathan Knowles+copyright: 2022–2026 Jonathan Knowles category: Testing synopsis: Testing monoid subclass instances with QuickCheck description:@@ -19,29 +19,31 @@ README.md common dependency-base- build-depends:base >= 4.14.3.0 && < 4.22+ build-depends:base >= 4.14.3.0 && < 4.23 common dependency-bytestring- build-depends:bytestring >= 0.10.12.0 && < 0.13+ build-depends:bytestring >= 0.10.12.0 && < 0.13 common dependency-commutative-semigroups- build-depends:commutative-semigroups >= 0.1.0.0 && < 0.3+ build-depends:commutative-semigroups >= 0.1.0.0 && < 0.3 common dependency-containers- build-depends:containers >= 0.6.5.1 && < 0.8+ build-depends:containers >= 0.6.5.1 && < 0.9 common dependency-hspec- build-depends:hspec >= 2.10.7 && < 2.12+ build-depends:hspec >= 2.10.7 && < 2.12+common dependency-hspec-quickcheck-classes+ build-depends:hspec-quickcheck-classes >= 0.0.0.0 && < 0.1 common dependency-monoid-subclasses- build-depends:monoid-subclasses >= 1.2.3 && < 1.3+ build-depends:monoid-subclasses >= 1.2.3 && < 1.3 common dependency-pretty-show- build-depends:pretty-show >= 1.10 && < 1.11+ build-depends:pretty-show >= 1.10 && < 1.11 common dependency-QuickCheck- build-depends:QuickCheck >= 2.14.2 && < 2.17+ build-depends:QuickCheck >= 2.14.2 && < 2.19 common dependency-quickcheck-classes- build-depends:quickcheck-classes >= 0.6.5.0 && < 0.7+ build-depends:quickcheck-classes >= 0.6.5.0 && < 0.7 common dependency-semigroupoids- build-depends:semigroupoids >= 5.3.7 && < 6.1+ build-depends:semigroupoids >= 5.3.7 && < 6.1 common dependency-text- build-depends:text >= 1.2.4.1 && < 2.2+ build-depends:text >= 1.2.4.1 && < 2.2 common dependency-vector- build-depends:vector >= 0.12.3.1 && < 0.14+ build-depends:vector >= 0.12.3.1 && < 0.14 common extensions default-extensions:@@ -125,6 +127,7 @@ , dependency-commutative-semigroups , dependency-containers , dependency-hspec+ , dependency-hspec-quickcheck-classes , dependency-monoid-subclasses , dependency-QuickCheck , dependency-quickcheck-classes@@ -144,7 +147,6 @@ other-modules: ClassSpec SpecHook- Test.Hspec.Laws type: exitcode-stdio-1.0 build-tool-depends:
src/internal/Internal.hs view
@@ -1,5 +1,5 @@ -- |--- Copyright: © 2022–2025 Jonathan Knowles+-- Copyright: © 2022–2026 Jonathan Knowles -- License: Apache-2.0 -- module Internal
src/internal/Internal/Semigroup/Eq.hs view
@@ -1,5 +1,5 @@ -- |--- Copyright: © 2022–2025 Jonathan Knowles+-- Copyright: © 2022–2026 Jonathan Knowles -- License: Apache-2.0 -- module Internal.Semigroup.Eq
src/internal/Internal/Semigroup/Tuple.hs view
@@ -3,7 +3,7 @@ {- HLINT ignore "Redundant bracket" -} -- |--- Copyright: © 2022–2025 Jonathan Knowles+-- Copyright: © 2022–2026 Jonathan Knowles -- License: Apache-2.0 -- module Internal.Semigroup.Tuple
src/prelude/Internal/Prelude.hs view
@@ -1,5 +1,5 @@ -- |--- Copyright: © 2022–2025 Jonathan Knowles+-- Copyright: © 2022–2026 Jonathan Knowles -- License: Apache-2.0 -- module Internal.Prelude
src/public/Test/QuickCheck/Classes/Monoid/Factorial.hs view
@@ -5,7 +5,7 @@ {- HLINT ignore "Use const" -} -- |--- Copyright: © 2022–2025 Jonathan Knowles+-- Copyright: © 2022–2026 Jonathan Knowles -- License: Apache-2.0 -- -- This module provides 'Laws' definitions for classes exported by
src/public/Test/QuickCheck/Classes/Monoid/GCD.hs view
@@ -3,7 +3,7 @@ {- HLINT ignore "Redundant ==" -} -- |--- Copyright: © 2022–2025 Jonathan Knowles+-- Copyright: © 2022–2026 Jonathan Knowles -- License: Apache-2.0 -- -- This module provides 'Laws' definitions for classes exported by
src/public/Test/QuickCheck/Classes/Monoid/LCM.hs view
@@ -3,7 +3,7 @@ {- HLINT ignore "Use &&" -} -- |--- Copyright: © 2022–2025 Jonathan Knowles+-- Copyright: © 2022–2026 Jonathan Knowles -- License: Apache-2.0 -- -- This module provides 'Laws' definitions for classes exported by
src/public/Test/QuickCheck/Classes/Monoid/Monus.hs view
@@ -2,7 +2,7 @@ {- HLINT ignore "Redundant bracket" -} -- |--- Copyright: © 2022–2025 Jonathan Knowles+-- Copyright: © 2022–2026 Jonathan Knowles -- License: Apache-2.0 -- -- This module provides 'Laws' definitions for classes exported by
src/public/Test/QuickCheck/Classes/Monoid/Null.hs view
@@ -2,7 +2,7 @@ {- HLINT ignore "Redundant bracket" -} -- |--- Copyright: © 2022–2025 Jonathan Knowles+-- Copyright: © 2022–2026 Jonathan Knowles -- License: Apache-2.0 -- -- This module provides 'Laws' definitions for classes exported by
src/public/Test/QuickCheck/Classes/Semigroup/Cancellative.hs view
@@ -3,7 +3,7 @@ {- HLINT ignore "Redundant bracket" -} -- |--- Copyright: © 2022–2025 Jonathan Knowles+-- Copyright: © 2022–2026 Jonathan Knowles -- License: Apache-2.0 -- -- This module provides 'Laws' definitions for classes exported by
src/public/Test/QuickCheck/Classes/Semigroup/Factorial.hs view
@@ -5,7 +5,7 @@ {- HLINT ignore "Use null" -} -- |--- Copyright: © 2022–2025 Jonathan Knowles+-- Copyright: © 2022–2026 Jonathan Knowles -- License: Apache-2.0 -- -- This module provides 'Laws' definitions for classes exported by
src/test/ClassSpec.hs view
@@ -1,7 +1,9 @@+{-# LANGUAGE DeriveFunctor #-}+{-# LANGUAGE UndecidableInstances #-} {-# OPTIONS_GHC -fno-warn-orphans #-} -- |--- Copyright: © 2022–2025 Jonathan Knowles+-- Copyright: © 2022–2026 Jonathan Knowles -- License: Apache-2.0 -- module ClassSpec where@@ -16,8 +18,19 @@ ( Map ) import Data.Monoid ( Dual (..), Product (..), Sum (..) )+import Data.Monoid.Factorial+ ( FactorialMonoid ) import Data.Monoid.GCD- ( GCDMonoid, LeftGCDMonoid, OverlappingGCDMonoid, RightGCDMonoid )+ ( DistributiveGCDMonoid+ , GCDMonoid+ , LeftDistributiveGCDMonoid+ , LeftGCDMonoid+ , OverlappingGCDMonoid+ , RightDistributiveGCDMonoid+ , RightGCDMonoid+ )+import Data.Monoid.LCM+ ( DistributiveLCMMonoid, LCMMonoid ) import Data.Monoid.Monus ( Monus ) import Data.Monoid.Null@@ -32,6 +45,8 @@ , RightReductive , SumCancellative )+import Data.Semigroup.Factorial+ ( Factorial, StableFactorial ) import Data.Sequence ( Seq ) import Data.Set@@ -46,8 +61,8 @@ ( CommutativeProduct ) import Test.Hspec ( Spec )-import Test.Hspec.Laws- ( testLawsMany )+import Test.Hspec.QuickCheck.Classes+ ( testLaws ) import Test.QuickCheck ( Arbitrary (..) , Confidence@@ -58,6 +73,7 @@ , scale , shrinkIntegral , shrinkMap+ , shrinkMapBy ) import Test.QuickCheck.Classes ( Laws (..) )@@ -98,7 +114,7 @@ spec :: Spec spec = do- testLawsMany @() $ fmap disableCoverageCheck <$>+ testLaws @() $ fmap disableCoverageCheck <$> [ cancellativeLaws , commutativeLaws , distributiveGCDMonoidLaws@@ -122,7 +138,7 @@ , rightReductiveLaws , stableFactorialLaws ]- testLawsMany @ByteString+ testLaws @ByteString [ factorialLaws , factorialMonoidLaws , leftCancellativeLaws@@ -138,7 +154,7 @@ , rightReductiveLaws , stableFactorialLaws ]- testLawsMany @(Dual ByteString)+ testLaws @(Dual ByteString) [ factorialLaws , factorialMonoidLaws , leftCancellativeLaws@@ -154,7 +170,7 @@ , rightReductiveLaws , stableFactorialLaws ]- testLawsMany @Text+ testLaws @Text [ factorialLaws , factorialMonoidLaws , leftCancellativeLaws@@ -170,7 +186,7 @@ , rightReductiveLaws , stableFactorialLaws ]- testLawsMany @(Dual Text)+ testLaws @(Dual Text) [ factorialLaws , factorialMonoidLaws , leftCancellativeLaws@@ -186,7 +202,7 @@ , rightReductiveLaws , stableFactorialLaws ]- testLawsMany @[SmallInt]+ testLaws @[Small Int] [ factorialLaws , factorialMonoidLaws , leftCancellativeLaws@@ -202,7 +218,7 @@ , rightReductiveLaws , stableFactorialLaws ]- testLawsMany @(Dual [SmallInt])+ testLaws @(Dual [Small Int]) [ factorialLaws , factorialMonoidLaws , leftCancellativeLaws@@ -218,7 +234,7 @@ , rightReductiveLaws , stableFactorialLaws ]- testLawsMany @(Seq SmallInt)+ testLaws @(Seq (Small Int)) [ factorialLaws , factorialMonoidLaws , leftCancellativeLaws@@ -234,7 +250,7 @@ , rightReductiveLaws , stableFactorialLaws ]- testLawsMany @(Dual (Seq SmallInt))+ testLaws @(Dual (Seq (Small Int))) [ factorialLaws , factorialMonoidLaws , leftCancellativeLaws@@ -250,7 +266,7 @@ , rightReductiveLaws , stableFactorialLaws ]- testLawsMany @(Vector SmallInt)+ testLaws @(Vector (Small Int)) [ factorialLaws , factorialMonoidLaws , leftCancellativeLaws@@ -266,7 +282,7 @@ , rightReductiveLaws , stableFactorialLaws ]- testLawsMany @(Dual (Vector SmallInt))+ testLaws @(Dual (Vector (Small Int))) [ factorialLaws , factorialMonoidLaws , leftCancellativeLaws@@ -282,7 +298,7 @@ , rightReductiveLaws , stableFactorialLaws ]- testLawsMany @(Set SmallInt)+ testLaws @(Set (Small Int)) [ commutativeLaws , distributiveGCDMonoidLaws , distributiveLCMMonoidLaws@@ -302,7 +318,7 @@ , rightGCDMonoidLaws , rightReductiveLaws ]- testLawsMany @(Set Natural)+ testLaws @(Set (Small Natural)) [ commutativeLaws , distributiveGCDMonoidLaws , distributiveLCMMonoidLaws@@ -322,7 +338,7 @@ , rightGCDMonoidLaws , rightReductiveLaws ]- testLawsMany @(Product SmallInt)+ testLaws @(Product (Small Int)) [ commutativeLaws , factorialLaws , factorialMonoidLaws@@ -331,7 +347,7 @@ , reductiveLaws , rightReductiveLaws ]- testLawsMany @(Product Natural)+ testLaws @(Small (Product Natural)) [ commutativeLaws , distributiveGCDMonoidLaws , distributiveLCMMonoidLaws@@ -351,7 +367,7 @@ , rightGCDMonoidLaws , rightReductiveLaws ]- testLawsMany @(Sum SmallInt)+ testLaws @(Sum (Small Int)) [ cancellativeLaws , commutativeLaws , factorialLaws@@ -363,7 +379,7 @@ , rightCancellativeLaws , rightReductiveLaws ]- testLawsMany @(Sum Natural)+ testLaws @(Small (Sum Natural)) [ cancellativeLaws , commutativeLaws , distributiveGCDMonoidLaws@@ -387,7 +403,7 @@ , rightReductiveLaws , stableFactorialLaws ]- testLawsMany @(IntMap SmallInt)+ testLaws @(IntMap (Small Int)) [ factorialLaws , factorialMonoidLaws , leftGCDMonoidLaws@@ -397,7 +413,7 @@ , positiveMonoidLaws , rightReductiveLaws ]- testLawsMany @(IntMap Natural)+ testLaws @(IntMap (Small Natural)) [ factorialLaws , factorialMonoidLaws , leftGCDMonoidLaws@@ -407,7 +423,7 @@ , positiveMonoidLaws , rightReductiveLaws ]- testLawsMany @(Map Int SmallInt)+ testLaws @(Map Int (Small Int)) [ factorialLaws , factorialMonoidLaws , leftGCDMonoidLaws@@ -417,7 +433,7 @@ , positiveMonoidLaws , rightReductiveLaws ]- testLawsMany @(Map Int Natural)+ testLaws @(Map Int (Small Natural)) [ factorialLaws , factorialMonoidLaws , leftGCDMonoidLaws@@ -427,7 +443,7 @@ , positiveMonoidLaws , rightReductiveLaws ]- testLawsMany @(Maybe ()) $ fmap disableCoverageCheck <$>+ testLaws @(Maybe ()) $ fmap disableCoverageCheck <$> [ commutativeLaws , factorialLaws , factorialMonoidLaws@@ -441,7 +457,7 @@ , rightGCDMonoidLaws , rightReductiveLaws ]- testLawsMany @(Maybe (Product SmallInt))+ testLaws @(Maybe (Product (Small Int))) [ commutativeLaws , factorialLaws , factorialMonoidLaws@@ -451,7 +467,7 @@ , reductiveLaws , rightReductiveLaws ]- testLawsMany @(Maybe (Product Natural))+ testLaws @(Maybe (Small (Product Natural))) [ commutativeLaws , factorialLaws , factorialMonoidLaws@@ -465,7 +481,7 @@ , rightGCDMonoidLaws , rightReductiveLaws ]- testLawsMany @(Maybe (Sum SmallInt))+ testLaws @(Maybe (Sum (Small Int))) [ commutativeLaws , factorialLaws , factorialMonoidLaws@@ -475,7 +491,7 @@ , reductiveLaws , rightReductiveLaws ]- testLawsMany @(Maybe (Sum Natural))+ testLaws @(Maybe (Small (Sum Natural))) [ commutativeLaws , factorialLaws , factorialMonoidLaws@@ -525,18 +541,23 @@ -- Utility types -------------------------------------------------------------------------------- -type SmallInt = Small Int- newtype Small a = Small {getSmall :: a}+ deriving stock Functor deriving newtype ( Cancellative , Commutative , CommutativeProduct+ , DistributiveGCDMonoid+ , DistributiveLCMMonoid , Enum , Eq+ , Factorial+ , FactorialMonoid , GCDMonoid , Integral+ , LCMMonoid , LeftCancellative+ , LeftDistributiveGCDMonoid , LeftGCDMonoid , LeftReductive , Monoid@@ -549,10 +570,12 @@ , Real , Reductive , RightCancellative+ , RightDistributiveGCDMonoid , RightGCDMonoid , RightReductive , Semigroup , Show+ , StableFactorial , SumCancellative ) @@ -560,7 +583,7 @@ -- Arbitrary instances -------------------------------------------------------------------------------- -instance Arbitrary a => Arbitrary (Small a) where+instance Arbitrary (Small Int) where arbitrary = Small <$> scale (`div` 2) arbitrary shrink = shrinkMap Small getSmall @@ -586,9 +609,17 @@ ] shrink = shrinkMap Text.pack Text.unpack -instance Arbitrary Natural where- arbitrary = elements [0 .. 3]- shrink = shrinkIntegral+instance Arbitrary (Small Natural) where+ arbitrary = Small <$> elements [0 .. 3]+ shrink = shrinkMapBy Small getSmall shrinkIntegral++instance Arbitrary (Small (Product Natural)) where+ arbitrary = fmap Product <$> arbitrary+ shrink = shrinkMap (fmap Product) (fmap getProduct)++instance Arbitrary (Small (Sum Natural)) where+ arbitrary = fmap Sum <$> arbitrary+ shrink = shrinkMap (fmap Sum) (fmap getSum) instance Arbitrary a => Arbitrary (Vector a) where arbitrary = Vector.fromList <$> arbitrary
− src/test/Test/Hspec/Laws.hs
@@ -1,61 +0,0 @@--- |--- Copyright: © 2022–2025 Jonathan Knowles--- License: Apache-2.0------ Provides testing functions to check that type class instances obey laws.----module Test.Hspec.Laws- ( testLaws- , testLawsMany- ) where--import Prelude--import Control.Monad- ( forM_ )-import Data.Proxy- ( Proxy (..) )-import Data.Typeable- ( Typeable, typeRep )-import Test.Hspec- ( Spec, describe, it, parallel )-import Test.QuickCheck.Classes- ( Laws (..) )---- | Constructs a test to check that the given type class instance obeys the--- given set of laws.------ Example usage:------ >>> testLaws @Natural ordLaws--- >>> testLaws @(Map Int) functorLaws----testLaws- :: forall a. Typeable a- => (Proxy a -> Laws)- -> Spec-testLaws getLaws =- parallel $ describe description $- forM_ (lawsProperties laws) $ uncurry it- where- description = mconcat- [ "Testing "- , lawsTypeclass laws- , " laws for type "- , show (typeRep $ Proxy @a)- ]- laws = getLaws $ Proxy @a---- | Calls `testLaws` with multiple sets of laws.------ Example usage:------ >>> testLawsMany @Natural [eqLaws, ordLaws]--- >>> testLawsMany @(Map Int) [foldableLaws, functorLaws]----testLawsMany- :: forall a. Typeable a- => [Proxy a -> Laws]- -> Spec-testLawsMany getLawsMany =- testLaws @a `mapM_` getLawsMany