packages feed

quickcheck-monoid-subclasses 0.0.0.1 → 0.1.0.0

raw patch · 14 files changed

+733/−69 lines, 14 filesdep ~monoid-subclassesPVP ok

version bump matches the API change (PVP)

Dependency ranges changed: monoid-subclasses

API changes (from Hackage documentation)

Files

CHANGELOG.md view
@@ -1,3 +1,8 @@+# 0.1.0.0++- Added laws for the `LCMMonoid` type class.+- Added laws for the `GCDMonoid` type class to match those of `LCMMonoid`.+ # 0.0.0.1  - Revised lower dependency bound for the `vector` package.
LICENSE view
@@ -186,7 +186,7 @@       same "printed page" as the copyright notice for easier       identification within third-party archives. -   Copyright © 2022 Jonathan Knowles+   Copyright © 2022–2023 Jonathan Knowles     Licensed under the Apache License, Version 2.0 (the "License");    you may not use this file except in compliance with the License.
quickcheck-monoid-subclasses.cabal view
@@ -1,12 +1,12 @@ cabal-version:  3.0 name:           quickcheck-monoid-subclasses-version:        0.0.0.1+version:        0.1.0.0 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 Jonathan Knowles+copyright:      2022–2023 Jonathan Knowles category:       Testing synopsis:       Testing monoid subclass instances with QuickCheck description:@@ -29,7 +29,7 @@ common dependency-hspec     build-depends:hspec                     >= 2.10.7       && < 2.11 common dependency-monoid-subclasses-    build-depends:monoid-subclasses         >= 1.2.1        && < 1.3+    build-depends:monoid-subclasses         >= 1.2.2        && < 1.3 common dependency-pretty-show     build-depends:pretty-show               >= 1.10         && < 1.11 common dependency-QuickCheck@@ -78,6 +78,7 @@         src/public     exposed-modules:         Test.QuickCheck.Classes.Monoid.GCD+        Test.QuickCheck.Classes.Monoid.LCM         Test.QuickCheck.Classes.Monoid.Monus         Test.QuickCheck.Classes.Monoid.Null         Test.QuickCheck.Classes.Semigroup.Cancellative
src/internal/Internal.hs view
@@ -1,5 +1,5 @@ -- |--- Copyright: © 2022 Jonathan Knowles+-- Copyright: © 2022–2023 Jonathan Knowles -- License: Apache-2.0 -- module Internal
src/internal/Internal/Semigroup/Eq.hs view
@@ -1,5 +1,5 @@ -- |--- Copyright: © 2022 Jonathan Knowles+-- Copyright: © 2022–2023 Jonathan Knowles -- License: Apache-2.0 -- module Internal.Semigroup.Eq
src/internal/Internal/Semigroup/Tuple.hs view
@@ -1,7 +1,7 @@ {- HLINT ignore "Redundant bracket" -}  -- |--- Copyright: © 2022 Jonathan Knowles+-- Copyright: © 2022–2023 Jonathan Knowles -- License: Apache-2.0 -- module Internal.Semigroup.Tuple
src/prelude/Internal/Prelude.hs view
@@ -1,5 +1,5 @@ -- |--- Copyright: © 2022 Jonathan Knowles+-- Copyright: © 2022–2023 Jonathan Knowles -- License: Apache-2.0 -- module Internal.Prelude
src/public/Test/QuickCheck/Classes/Monoid/GCD.hs view
@@ -2,7 +2,7 @@ {- HLINT ignore "Redundant bracket" -}  -- |--- Copyright: © 2022 Jonathan Knowles+-- Copyright: © 2022–2023 Jonathan Knowles -- License: Apache-2.0 -- -- This module provides 'Laws' definitions for classes exported by@@ -35,7 +35,7 @@ import Data.Semigroup.Cancellative     ( Cancellative, LeftReductive (..), Reductive (..), RightReductive (..) ) import Internal-    ( cover, makeLaw2, makeLaw3, makeProperty, report )+    ( cover, makeLaw1, makeLaw2, makeLaw3, makeProperty, report, (==>) ) import Test.QuickCheck     ( Arbitrary (..), Property ) import Test.QuickCheck.Classes@@ -47,7 +47,7 @@  -- | 'Laws' for instances of 'Cancellative' and 'GCDMonoid'. ----- Tests the following laws:+-- Includes the following laws: -- -- @ -- 'gcd' (a '<>' b) (a '<>' c) '==' a '<>' 'gcd' b c@@ -131,24 +131,74 @@  -- | 'Laws' for instances of 'GCDMonoid'. ----- Tests the following laws:+-- Includes the following laws: --+-- __/Reductivity/__+-- -- @--- 'gcd' a b '==' 'commonPrefix' a b+-- 'isJust' (a '</>' 'gcd' a b) -- @+-- @+-- 'isJust' (b '</>' 'gcd' a b)+-- @ --+-- __/Uniqueness/__+-- -- @--- 'gcd' a b '==' 'commonSuffix' a b+-- 'all' 'isJust'+--     [ a '</>' c+--     , b '</>' c+--     , c '</>' 'gcd' a b+--     ]+-- ==>+--     (c '==' 'gcd' a b) -- @ --+-- __/Idempotence/__+-- -- @--- 'isJust' (a '</>' 'gcd' a b)+-- 'gcd' a a '==' a -- @ --+-- __/Identity/__+-- -- @--- 'isJust' (b '</>' 'gcd' a b)+-- 'gcd' 'mempty' a '==' 'mempty' -- @+-- @+-- 'gcd' a 'mempty' '==' 'mempty'+-- @ --+-- __/Commutativity/__+--+-- @+-- 'gcd' a b '==' 'gcd' b a+-- @+--+-- __/Associativity/__+--+-- @+-- 'gcd' ('gcd' a b) c '==' 'gcd' a ('gcd' b c)+-- @+--+-- __/Distributivity/__+--+-- @+-- 'gcd' (a '<>' b) (a '<>' c) '==' a '<>' 'gcd' b c+-- @+-- @+-- 'gcd' (a '<>' c) (b '<>' c) '==' 'gcd' a b '<>' c+-- @+--+-- __/Equivalence/__+--+-- @+-- 'gcd' a b '==' 'commonPrefix' a b+-- @+-- @+-- 'gcd' a b '==' 'commonSuffix' a b+-- @+-- -- Note that the following superclass laws are __not__ included: -- -- * 'Test.QuickCheck.Classes.monoidLaws'@@ -164,102 +214,281 @@     -> Laws gcdMonoidLaws _ = Laws "GCDMonoid"     [ makeLaw2 @a-        "gcdMonoidLaw_gcd_commonPrefix"-        (gcdMonoidLaw_gcd_commonPrefix)+        "gcdMonoidLaw_reductivity_left"+        (gcdMonoidLaw_reductivity_left)     , makeLaw2 @a-        "gcdMonoidLaw_gcd_commonSuffix"-        (gcdMonoidLaw_gcd_commonSuffix)+        "gcdMonoidLaw_reductivity_right"+        (gcdMonoidLaw_reductivity_right)+    , makeLaw3 @a+        "gcdMonoidLaw_uniqueness"+        (gcdMonoidLaw_uniqueness)+    , makeLaw1 @a+        "gcdMonoidLaw_idempotence"+        (gcdMonoidLaw_idempotence)+    , makeLaw1 @a+        "gcdMonoidLaw_identity_left"+        (gcdMonoidLaw_identity_left)+    , makeLaw1 @a+        "gcdMonoidLaw_identity_right"+        (gcdMonoidLaw_identity_right)     , makeLaw2 @a-        "gcdMonoidLaw_gcd_reduction_1"-        (gcdMonoidLaw_gcd_reduction_1)+        "gcdMonoidLaw_commutativity"+        (gcdMonoidLaw_commutativity)+    , makeLaw3 @a+        "gcdMonoidLaw_associativity"+        (gcdMonoidLaw_associativity)+    , makeLaw3 @a+        "gcdMonoidLaw_distributivity_left"+        (gcdMonoidLaw_distributivity_left)+    , makeLaw3 @a+        "gcdMonoidLaw_distributivity_right"+        (gcdMonoidLaw_distributivity_right)     , makeLaw2 @a-        "gcdMonoidLaw_gcd_reduction_2"-        (gcdMonoidLaw_gcd_reduction_2)+        "gcdMonoidLaw_equivalence_commonPrefix"+        (gcdMonoidLaw_equivalence_commonPrefix)+    , makeLaw2 @a+        "gcdMonoidLaw_equivalence_commonSuffix"+        (gcdMonoidLaw_equivalence_commonSuffix)     ] -gcdMonoidLaw_gcd_commonPrefix+gcdMonoidLaw_reductivity_left     :: (Eq a, Show a, GCDMonoid a) => a -> a -> Property-gcdMonoidLaw_gcd_commonPrefix a b =+gcdMonoidLaw_reductivity_left a b =     makeProperty-        "gcd a b == commonPrefix a b"-        (gcd a b == commonPrefix a b)+        "isJust (a </> gcd a b)"+        (isJust (a </> gcd a b))     & cover         "gcd a b /= mempty"         (gcd a b /= mempty)     & cover-        "commonPrefix a b /= mempty"-        (commonPrefix a b /= mempty)+        "(a </> gcd a b) /= mempty"+        ((a </> gcd a b) /= mempty)     & report         "gcd a b"         (gcd a b)     & report-        "commonPrefix a b"-        (commonPrefix a b)+        "a </> gcd a b"+        (a </> gcd a b) -gcdMonoidLaw_gcd_commonSuffix+gcdMonoidLaw_reductivity_right     :: (Eq a, Show a, GCDMonoid a) => a -> a -> Property-gcdMonoidLaw_gcd_commonSuffix a b =+gcdMonoidLaw_reductivity_right a b =     makeProperty-        "gcd a b == commonSuffix a b"-        (gcd a b == commonSuffix a b)+        "isJust (b </> gcd a b)"+        (isJust (b </> gcd a b))     & cover         "gcd a b /= mempty"         (gcd a b /= mempty)     & cover-        "commonSuffix a b /= mempty"-        (commonSuffix a b /= mempty)+        "(b </> gcd a b) /= mempty"+        ((b </> gcd a b) /= mempty)     & report         "gcd a b"         (gcd a b)     & report-        "commonSuffix a b"-        (commonSuffix a b)+        "b </> gcd a b"+        (b </> gcd a b) -gcdMonoidLaw_gcd_reduction_1+gcdMonoidLaw_uniqueness+    :: (Eq a, Show a, GCDMonoid a) => a -> a -> a -> Property+gcdMonoidLaw_uniqueness a b c =+    makeProperty+        "all isJust [a </> c, b </> c, c </> gcd a b] ==> (c == gcd a b)"+        (all isJust [a </> c, b </> c, c </> gcd a b] ==> (c == gcd a b))+    & cover+        "all isJust [a </> c, b </> c, c </> gcd a b]"+        (all isJust [a </> c, b </> c, c </> gcd a b])+    & cover+        "not (all isJust [a </> c, b </> c, c </> gcd a b])"+        (not (all isJust [a </> c, b </> c, c </> gcd a b]))+    & cover+        "c == gcd a b"+        (c == gcd a b)+    & cover+        "c /= gcd a b"+        (c /= gcd a b)+    & report+        "gcd a b"+        (gcd a b)+    & report+        "c </> gcd a b"+        (c </> gcd a b)+    & report+        "a </> c"+        (a </> c)+    & report+        "b </> c"+        (b </> c)++gcdMonoidLaw_idempotence+    :: (Eq a, Show a, GCDMonoid a) => a -> Property+gcdMonoidLaw_idempotence a =+    makeProperty+        "gcd a a == a"+        (gcd a a == a)+    & report+        "gcd a a"+        (gcd a a)++gcdMonoidLaw_identity_left+    :: (Eq a, Show a, GCDMonoid a) => a -> Property+gcdMonoidLaw_identity_left a =+    makeProperty+        "gcd mempty a == mempty"+        (gcd mempty a == mempty)+    & cover+        "a /= mempty"+        (a /= mempty)+    & report+        "gcd mempty a"+        (gcd mempty a)++gcdMonoidLaw_identity_right+    :: (Eq a, Show a, GCDMonoid a) => a -> Property+gcdMonoidLaw_identity_right a =+    makeProperty+        "gcd a mempty == mempty"+        (gcd a mempty == mempty)+    & cover+        "a /= mempty"+        (a /= mempty)+    & report+        "gcd a mempty"+        (gcd a mempty)++gcdMonoidLaw_commutativity     :: (Eq a, Show a, GCDMonoid a) => a -> a -> Property-gcdMonoidLaw_gcd_reduction_1 a b =+gcdMonoidLaw_commutativity a b =     makeProperty-        "isJust (a </> gcd a b)"-        (isJust (a </> gcd a b))+        "gcd a b == gcd b a"+        (gcd a b == gcd b a)     & cover+        "gcd a b == mempty"+        (gcd a b == mempty)+    & cover         "gcd a b /= mempty"         (gcd a b /= mempty)+    & report+        "gcd a b"+        (gcd a b)+    & report+        "gcd b a"+        (gcd b a)++gcdMonoidLaw_associativity+    :: (Eq a, Show a, GCDMonoid a) => a -> a -> a -> Property+gcdMonoidLaw_associativity a b c =+    makeProperty+        "gcd (gcd a b) c == gcd a (gcd b c)"+        (gcd (gcd a b) c == gcd a (gcd b c))     & cover-        "(a </> gcd a b) /= mempty"-        ((a </> gcd a b) /= mempty)+        "gcd a b /= mempty"+        (gcd a b /= mempty)+    & cover+        "gcd b c /= mempty"+        (gcd b c /= mempty)     & report         "gcd a b"         (gcd a b)     & report-        "a </> gcd a b"-        (a </> gcd a b)+        "gcd (gcd a b) c"+        (gcd (gcd a b) c)+    & report+        "gcd b c"+        (gcd b c)+    & report+        "gcd a (gcd b c)"+        (gcd a (gcd b c)) -gcdMonoidLaw_gcd_reduction_2+gcdMonoidLaw_distributivity_left+    :: (Eq a, Show a, GCDMonoid a) => a -> a -> a -> Property+gcdMonoidLaw_distributivity_left a b c =+    makeProperty+        "gcd (a <> b) (a <> c) == a <> gcd b c"+        (gcd (a <> b) (a <> c) == a <> gcd b c)+    & report+        "a <> b"+        (a <> b)+    & report+        "a <> c"+        (a <> c)+    & report+        "gcd (a <> b) (a <> c)"+        (gcd (a <> b) (a <> c))+    & report+        "gcd b c"+        (gcd b c)+    & report+        "a <> gcd b c"+        (a <> gcd b c)++gcdMonoidLaw_distributivity_right+    :: (Eq a, Show a, GCDMonoid a) => a -> a -> a -> Property+gcdMonoidLaw_distributivity_right a b c =+    makeProperty+        "gcd (a <> c) (b <> c) == gcd a b <> c"+        (gcd (a <> c) (b <> c) == gcd a b <> c)+    & report+        "a <> c"+        (a <> c)+    & report+        "b <> c"+        (b <> c)+    & report+        "gcd (a <> c) (b <> c)"+        (gcd (a <> c) (b <> c))+    & report+        "gcd a b"+        (gcd a b)+    & report+        "gcd a b <> c"+        (gcd a b <> c)++gcdMonoidLaw_equivalence_commonPrefix     :: (Eq a, Show a, GCDMonoid a) => a -> a -> Property-gcdMonoidLaw_gcd_reduction_2 a b =+gcdMonoidLaw_equivalence_commonPrefix a b =     makeProperty-        "isJust (b </> gcd a b)"-        (isJust (b </> gcd a b))+        "gcd a b == commonPrefix a b"+        (gcd a b == commonPrefix a b)     & cover         "gcd a b /= mempty"         (gcd a b /= mempty)     & cover-        "(b </> gcd a b) /= mempty"-        ((b </> gcd a b) /= mempty)+        "commonPrefix a b /= mempty"+        (commonPrefix a b /= mempty)     & report         "gcd a b"         (gcd a b)     & report-        "b </> gcd a b"-        (b </> gcd a b)+        "commonPrefix a b"+        (commonPrefix a b) +gcdMonoidLaw_equivalence_commonSuffix+    :: (Eq a, Show a, GCDMonoid a) => a -> a -> Property+gcdMonoidLaw_equivalence_commonSuffix a b =+    makeProperty+        "gcd a b == commonSuffix a b"+        (gcd a b == commonSuffix a b)+    & cover+        "gcd a b /= mempty"+        (gcd a b /= mempty)+    & cover+        "commonSuffix a b /= mempty"+        (commonSuffix a b /= mempty)+    & report+        "gcd a b"+        (gcd a b)+    & report+        "commonSuffix a b"+        (commonSuffix a b)+ -------------------------------------------------------------------------------- -- LeftGCDMonoid --------------------------------------------------------------------------------  -- | 'Laws' for instances of 'LeftGCDMonoid'. ----- Tests the following laws:+-- Includes the following laws: -- -- @ -- 'stripCommonPrefix' a b '&' \\(p, _, _) -> p '==' 'commonPrefix' a b@@ -394,7 +623,7 @@  -- | 'Laws' for instances of 'OverlappingGCDMonoid'. ----- Tests the following laws:+-- Includes the following laws: -- -- @ -- 'overlap' a b '<>' 'stripPrefixOverlap' a b '==' b@@ -536,7 +765,7 @@  -- | 'Laws' for instances of 'RightGCDMonoid'. ----- Tests the following laws:+-- Includes the following laws: -- -- @ -- 'stripCommonSuffix' a b '&' \\(_, _, s) -> s '==' 'commonSuffix' a b
+ src/public/Test/QuickCheck/Classes/Monoid/LCM.hs view
@@ -0,0 +1,421 @@+{- HLINT ignore "Use camelCase" -}+{- HLINT ignore "Redundant bracket" -}+{- HLINT ignore "Use &&" -}++-- |+-- Copyright: © 2022–2023 Jonathan Knowles+-- License: Apache-2.0+--+-- This module provides 'Laws' definitions for classes exported by+-- "Data.Monoid.LCM".+--+module Test.QuickCheck.Classes.Monoid.LCM+    ( lcmMonoidLaws+    )+    where++import Prelude hiding+    ( gcd, lcm )++import Data.Function+    ( (&) )+import Data.Maybe+    ( isJust )+import Data.Monoid.GCD+    ( GCDMonoid (..), OverlappingGCDMonoid (..) )+import Data.Monoid.LCM+    ( LCMMonoid (..) )+import Data.Monoid.Monus+    ( Monus (..) )+import Data.Proxy+    ( Proxy (..) )+import Data.Semigroup.Cancellative+    ( Cancellative (..)+    , LeftReductive (..)+    , Reductive (..)+    , RightReductive (..)+    )+import Internal+    ( cover, makeLaw1, makeLaw2, makeLaw3, makeProperty, report, (==>) )+import Test.QuickCheck+    ( Arbitrary (..), Property )+import Test.QuickCheck.Classes+    ( Laws (..) )++--------------------------------------------------------------------------------+-- LCMMonoid+--------------------------------------------------------------------------------++-- | 'Laws' for instances of 'LCMMonoid'.+--+-- Includes the following laws:+--+-- __/Reductivity/__+--+-- @+-- 'isJust' ('lcm' a b '</>' a)+-- @+-- @+-- 'isJust' ('lcm' a b '</>' b)+-- @+--+-- __/Uniqueness/__+--+-- @+-- 'all' 'isJust'+--     [ \   \   c '</>' a+--     , \   \   c '</>' b+--     , 'lcm' a b '</>' c+--     ]+-- ==>+--     ('lcm' a b '==' c)+-- @+--+-- __/Idempotence/__+--+-- @+-- 'lcm' a a '==' a+-- @+--+-- __/Identity/__+--+-- @+-- 'lcm' 'mempty' a '==' a+-- @+-- @+-- 'lcm' a 'mempty' '==' a+-- @+--+-- __/Commutativity/__+--+-- @+-- 'lcm' a b '==' 'lcm' b a+-- @+--+-- __/Associativity/__+--+-- @+-- 'lcm' ('lcm' a b) c '==' 'lcm' a ('lcm' b c)+-- @+--+-- __/Distributivity/__+--+-- @+-- 'lcm' (a '<>' b) (a '<>' c) '==' a '<>' 'lcm' b c+-- @+-- @+-- 'lcm' (a '<>' c) (b '<>' c) '==' 'lcm' a b '<>' c+-- @+-- @+-- 'lcm' a ('gcd' b c) '==' 'gcd' ('lcm' a b) ('lcm' a c)+-- @+-- @+-- 'gcd' a ('lcm' b c) '==' 'lcm' ('gcd' a b) ('gcd' a c)+-- @+--+-- __/Absorption/__+--+-- @+-- 'lcm' a ('gcd' a b) '==' a+-- @+-- @+-- 'gcd' a ('lcm' a b) '==' a+-- @+--+-- Note that the following superclass laws are __not__ included:+--+-- * 'Test.QuickCheck.Classes.Monoid.GCD.gcdMonoidLaws'+--+lcmMonoidLaws+    :: forall a. (Arbitrary a, Show a, Eq a, LCMMonoid a)+    => Proxy a+    -> Laws+lcmMonoidLaws _ = Laws "LCMMonoid"+    [ makeLaw2 @a+        "lcmMonoidLaw_reductivity_left"+        (lcmMonoidLaw_reductivity_left)+    , makeLaw2 @a+        "lcmMonoidLaw_reductivity_right"+        (lcmMonoidLaw_reductivity_right)+    , makeLaw3 @a+        "lcmMonoidLaw_uniqueness"+        (lcmMonoidLaw_uniqueness)+    , makeLaw1 @a+        "lcmMonoidLaw_idempotence"+        (lcmMonoidLaw_idempotence)+    , makeLaw1 @a+        "lcmMonoidLaw_identity_left"+        (lcmMonoidLaw_identity_left)+    , makeLaw1 @a+        "lcmMonoidLaw_identity_right"+        (lcmMonoidLaw_identity_right)+    , makeLaw2 @a+        "lcmMonoidLaw_commutativity"+        (lcmMonoidLaw_commutativity)+    , makeLaw3 @a+        "lcmMonoidLaw_associativity"+        (lcmMonoidLaw_associativity)+    , makeLaw3 @a+        "lcmMonoidLaw_distributivity_left"+        (lcmMonoidLaw_distributivity_left)+    , makeLaw3 @a+        "lcmMonoidLaw_distributivity_right"+        (lcmMonoidLaw_distributivity_right)+    , makeLaw3 @a+        "lcmMonoidLaw_distributivity_gcd_lcm"+        (lcmMonoidLaw_distributivity_gcd_lcm)+    , makeLaw3 @a+        "lcmMonoidLaw_distributivity_lcm_gcd"+        (lcmMonoidLaw_distributivity_lcm_gcd)+    , makeLaw2 @a+        "lcmMonoidLaw_absorption_gcd_lcm"+        (lcmMonoidLaw_absorption_gcd_lcm)+    , makeLaw2 @a+        "lcmMonoidLaw_absorption_lcm_gcd"+        (lcmMonoidLaw_absorption_lcm_gcd)+    ]++lcmMonoidLaw_reductivity_left+    :: (Eq a, Show a, LCMMonoid a) => a -> a -> Property+lcmMonoidLaw_reductivity_left a b =+    makeProperty+        "isJust (lcm a b </> a)"+        (isJust (lcm a b </> a))+    & cover+        "lcm a b /= mempty"+        (lcm a b /= mempty)+    & cover+        "(lcm a b </> a) /= Just mempty"+        ((lcm a b </> a) /= Just mempty)+    & report+        "lcm a b"+        (lcm a b)+    & report+        "lcm a b </> a"+        (lcm a b </> a)++lcmMonoidLaw_reductivity_right+    :: (Eq a, Show a, LCMMonoid a) => a -> a -> Property+lcmMonoidLaw_reductivity_right a b =+    makeProperty+        "isJust (lcm a b </> b)"+        (isJust (lcm a b </> b))+    & cover+        "lcm a b /= mempty"+        (lcm a b /= mempty)+    & cover+        "(lcm a b </> b) /= Just mempty"+        ((lcm a b </> b) /= Just mempty)+    & report+        "lcm a b"+        (lcm a b)+    & report+        "lcm a b </> b"+        (lcm a b </> b)++lcmMonoidLaw_uniqueness+    :: (Eq a, Show a, LCMMonoid a) => a -> a -> a -> Property+lcmMonoidLaw_uniqueness a b c =+    makeProperty+        "all isJust [c </> a, c </> b, lcm a b </> c] ==> (lcm a b == c)"+        (all isJust [c </> a, c </> b, lcm a b </> c] ==> (lcm a b == c))+    & cover+        "all isJust [c </> a, c </> b, lcm a b </> c]"+        (all isJust [c </> a, c </> b, lcm a b </> c])+    & cover+        "not (all isJust [c </> a, c </> b, lcm a b </> c])"+        (not (all isJust [c </> a, c </> b, lcm a b </> c]))+    & cover+        "c == lcm a b"+        (c == lcm a b)+    & cover+        "c /= lcm a b"+        (c /= lcm a b)+    & report+        "lcm a b"+        (lcm a b)+    & report+        "lcm a b </> c"+        (lcm a b </> c)+    & report+        "c </> a"+        (c </> a)+    & report+        "c </> b"+        (c </> b)++lcmMonoidLaw_idempotence+    :: (Eq a, Show a, LCMMonoid a) => a -> Property+lcmMonoidLaw_idempotence a =+    makeProperty+        "lcm a a == a"+        (lcm a a == a)+    & report+        "lcm a a"+        (lcm a a)++lcmMonoidLaw_identity_left+    :: (Eq a, Show a, LCMMonoid a) => a -> Property+lcmMonoidLaw_identity_left a =+    makeProperty+        "lcm mempty a == a"+        (lcm mempty a == a)+    & cover+        "a /= mempty"+        (a /= mempty)+    & report+        "lcm mempty a"+        (lcm mempty a)++lcmMonoidLaw_identity_right+    :: (Eq a, Show a, LCMMonoid a) => a -> Property+lcmMonoidLaw_identity_right a =+    makeProperty+        "lcm a mempty == a"+        (lcm a mempty == a)+    & cover+        "a /= mempty"+        (a /= mempty)+    & report+        "lcm a mempty"+        (lcm a mempty)++lcmMonoidLaw_commutativity+    :: (Eq a, Show a, LCMMonoid a) => a -> a -> Property+lcmMonoidLaw_commutativity a b =+    makeProperty+        "lcm a b == lcm b a"+        (lcm a b == lcm b a)+    & cover+        "lcm a b == mempty"+        (lcm a b == mempty)+    & cover+        "lcm a b /= mempty"+        (lcm a b /= mempty)+    & report+        "lcm a b"+        (lcm a b)+    & report+        "lcm b a"+        (lcm b a)++lcmMonoidLaw_associativity+    :: (Eq a, Show a, LCMMonoid a) => a -> a -> a -> Property+lcmMonoidLaw_associativity a b c =+    makeProperty+        "lcm (lcm a b) c == lcm a (lcm b c)"+        (lcm (lcm a b) c == lcm a (lcm b c))+    & cover+        "lcm a b /= mempty"+        (lcm a b /= mempty)+    & cover+        "lcm b c /= mempty"+        (lcm b c /= mempty)+    & report+        "lcm a b"+        (lcm a b)+    & report+        "lcm (lcm a b) c"+        (lcm (lcm a b) c)+    & report+        "lcm b c"+        (lcm b c)+    & report+        "lcm a (lcm b c)"+        (lcm a (lcm b c))++lcmMonoidLaw_distributivity_left+    :: (Eq a, Show a, LCMMonoid a) => a -> a -> a -> Property+lcmMonoidLaw_distributivity_left a b c =+    makeProperty+        "lcm (a <> b) (a <> c) == a <> lcm b c"+        (lcm (a <> b) (a <> c) == a <> lcm b c)+    & report+        "a <> b"+        (a <> b)+    & report+        "a <> c"+        (a <> c)+    & report+        "lcm (a <> b) (a <> c)"+        (lcm (a <> b) (a <> c))+    & report+        "lcm b c"+        (lcm b c)+    & report+        "a <> lcm b c"+        (a <> lcm b c)++lcmMonoidLaw_distributivity_right+    :: (Eq a, Show a, LCMMonoid a) => a -> a -> a -> Property+lcmMonoidLaw_distributivity_right a b c =+    makeProperty+        "lcm (a <> c) (b <> c) == lcm a b <> c"+        (lcm (a <> c) (b <> c) == lcm a b <> c)+    & report+        "a <> c"+        (a <> c)+    & report+        "b <> c"+        (b <> c)+    & report+        "lcm (a <> c) (b <> c)"+        (lcm (a <> c) (b <> c))+    & report+        "lcm a b"+        (lcm a b)+    & report+        "lcm a b <> c"+        (lcm a b <> c)++lcmMonoidLaw_distributivity_gcd_lcm+    :: (Eq a, Show a, LCMMonoid a) => a -> a -> a -> Property+lcmMonoidLaw_distributivity_gcd_lcm a b c =+    makeProperty+        "lcm a (gcd b c) == gcd (lcm a b) (lcm a c)"+        (lcm a (gcd b c) == gcd (lcm a b) (lcm a c))++lcmMonoidLaw_distributivity_lcm_gcd+    :: (Eq a, Show a, LCMMonoid a) => a -> a -> a -> Property+lcmMonoidLaw_distributivity_lcm_gcd a b c =+    makeProperty+        "gcd a (lcm b c) == lcm (gcd a b) (gcd a c)"+        (gcd a (lcm b c) == lcm (gcd a b) (gcd a c))++lcmMonoidLaw_absorption_gcd_lcm+    :: (Eq a, Show a, LCMMonoid a) => a -> a -> Property+lcmMonoidLaw_absorption_gcd_lcm a b =+    makeProperty+        "lcm a (gcd a b) == a"+        (lcm a (gcd a b) == a)+    & cover+        "gcd a b == mempty"+        (gcd a b == mempty)+    & cover+        "gcd a b /= mempty"+        (gcd a b /= mempty)+    & report+        "gcd a b"+        (gcd a b)+    & report+        "lcm a (gcd a b)"+        (lcm a (gcd a b))++lcmMonoidLaw_absorption_lcm_gcd+    :: (Eq a, Show a, LCMMonoid a) => a -> a -> Property+lcmMonoidLaw_absorption_lcm_gcd a b =+    makeProperty+        "gcd a (lcm a b) == a"+        (gcd a (lcm a b) == a)+    & cover+        "gcd a b == mempty"+        (gcd a b == mempty)+    & cover+        "gcd a b /= mempty"+        (gcd a b /= mempty)+    & report+        "lcm a b"+        (lcm a b)+    & report+        "gcd a (lcm a b)"+        (gcd a (lcm a b))
src/public/Test/QuickCheck/Classes/Monoid/Monus.hs view
@@ -2,7 +2,7 @@ {- HLINT ignore "Redundant bracket" -}  -- |--- Copyright: © 2022 Jonathan Knowles+-- Copyright: © 2022–2023 Jonathan Knowles -- License: Apache-2.0 -- -- This module provides 'Laws' definitions for classes exported by@@ -40,7 +40,7 @@  -- | 'Laws' for instances of 'Monus'. ----- Tests the following laws:+-- Includes the following laws: -- -- @ -- a '<\>' a '==' 'mempty'
src/public/Test/QuickCheck/Classes/Monoid/Null.hs view
@@ -2,7 +2,7 @@ {- HLINT ignore "Redundant bracket" -}  -- |--- Copyright: © 2022 Jonathan Knowles+-- Copyright: © 2022–2023 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 Jonathan Knowles+-- Copyright: © 2022–2023 Jonathan Knowles -- License: Apache-2.0 -- -- This module provides 'Laws' definitions for classes exported by@@ -54,7 +54,7 @@  -- | 'Laws' for instances of 'Cancellative'. ----- Tests the following laws:+-- Includes the following laws: -- -- @ -- (a '<>' b) '</>' a '==' 'Just' b@@ -196,7 +196,7 @@  -- | 'Laws' for instances of 'LeftReductive'. ----- Tests the following laws:+-- Includes the following laws: -- -- @ -- a '`isPrefixOf`' (a '<>' b)@@ -272,7 +272,7 @@  -- | 'Laws' for instances of 'Reductive'. ----- Tests the following laws:+-- Includes the following laws: -- -- @ -- a '</>' b '==' 'stripPrefix' b a@@ -412,7 +412,7 @@  -- | 'Laws' for instances of 'RightReductive'. ----- Tests the following laws:+-- Includes the following laws: -- -- @ -- b '`isSuffixOf`' (a '<>' b)
src/test/ClassSpec.hs view
@@ -1,7 +1,7 @@ {-# OPTIONS_GHC -fno-warn-orphans #-}  -- |--- Copyright: © 2022 Jonathan Knowles+-- Copyright: © 2022–2023 Jonathan Knowles -- License: Apache-2.0 -- module ClassSpec where@@ -63,6 +63,8 @@     , overlappingGCDMonoidLaws     , rightGCDMonoidLaws     )+import Test.QuickCheck.Classes.Monoid.LCM+    ( lcmMonoidLaws ) import Test.QuickCheck.Classes.Monoid.Monus     ( monusLaws ) import Test.QuickCheck.Classes.Monoid.Null@@ -94,6 +96,7 @@         , cancellativeLaws         , commutativeLaws         , gcdMonoidLaws+        , lcmMonoidLaws         , leftCancellativeLaws         , leftGCDMonoidLaws         , leftReductiveLaws@@ -155,6 +158,7 @@         , gcdMonoidLaws         , leftGCDMonoidLaws         , leftReductiveLaws+        , lcmMonoidLaws         , monoidNullLaws         , monusLaws         , overlappingGCDMonoidLaws@@ -168,6 +172,7 @@         , gcdMonoidLaws         , leftGCDMonoidLaws         , leftReductiveLaws+        , lcmMonoidLaws         , monoidNullLaws         , monusLaws         , overlappingGCDMonoidLaws@@ -186,6 +191,7 @@     testLawsMany @(Product Natural)         [ commutativeLaws         , gcdMonoidLaws+        , lcmMonoidLaws         , leftGCDMonoidLaws         , leftReductiveLaws         , monoidNullLaws@@ -211,6 +217,7 @@         , cancellativeLaws         , commutativeLaws         , gcdMonoidLaws+        , lcmMonoidLaws         , leftCancellativeLaws         , leftGCDMonoidLaws         , leftReductiveLaws@@ -329,6 +336,7 @@         , cancellativeLaws         , commutativeLaws         , gcdMonoidLaws+        , lcmMonoidLaws         , leftCancellativeLaws         , leftGCDMonoidLaws         , leftReductiveLaws
src/test/Test/Hspec/Laws.hs view
@@ -1,5 +1,5 @@ -- |--- Copyright: © 2022 Jonathan Knowles+-- Copyright: © 2022–2023 Jonathan Knowles -- License: Apache-2.0 -- -- Provides testing functions to check that type class instances obey laws.