quickcheck-monoid-subclasses-0.3.0.4: Testing monoid subclass instances with QuickCheck
Copyright© 2022–2024 Jonathan Knowles
LicenseApache-2.0
Safe HaskellNone
LanguageHaskell2010

Test.QuickCheck.Classes.Monoid.GCD

Description

This module provides Laws definitions for classes exported by Data.Monoid.GCD.

Synopsis

Documentation

gcdMonoidLaws :: (Arbitrary a, Show a, Eq a, GCDMonoid a) => Proxy a -> Laws Source #

Laws for instances of GCDMonoid.

Includes the following laws:

Reductivity

isJust (a </> gcd a b)
isJust (b </> gcd a b)

Uniqueness

all isJust
    [ a </> c
    , b </> c
    , c </> gcd a b
    ]
==>
    (c == gcd a b)

Idempotence

gcd a a == a

Identity

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)

Equivalences

gcd a b == commonPrefix a b
gcd a b == commonSuffix a b

Note that the following superclass laws are not included:

leftGCDMonoidLaws :: (Arbitrary a, Show a, Eq a, LeftGCDMonoid a) => Proxy a -> Laws Source #

Laws for instances of LeftGCDMonoid.

Includes the following laws:

Reductivity

isJust (stripPrefix (commonPrefix a b) a)
isJust (stripPrefix (commonPrefix a b) b)

Uniqueness

all isJust
    [ stripPrefix c a
    , stripPrefix c b
    , stripPrefix (commonPrefix a b) c
    ]
==>
    (c == commonPrefix a b)

Idempotence

commonPrefix a a == a

Identity

commonPrefix mempty a == mempty
commonPrefix a mempty == mempty

Commutativity

commonPrefix a b == commonPrefix b a

Associativity

commonPrefix (commonPrefix a b) c
==
commonPrefix a (commonPrefix b c)

Equivalences

stripCommonPrefix a b & \(p, _, _) -> p == commonPrefix a b
stripCommonPrefix a b & \(p, x, _) -> p <> x == a
stripCommonPrefix a b & \(p, _, x) -> p <> x == b
stripCommonPrefix a b & \(p, x, _) -> Just x == stripPrefix p a
stripCommonPrefix a b & \(p, _, x) -> Just x == stripPrefix p b

Note that the following superclass laws are not included:

rightGCDMonoidLaws :: (Arbitrary a, Show a, Eq a, RightGCDMonoid a) => Proxy a -> Laws Source #

Laws for instances of RightGCDMonoid.

Includes the following laws:

Reductivity

isJust (stripSuffix (commonSuffix a b) a)
isJust (stripSuffix (commonSuffix a b) b)

Uniqueness

all isJust
    [ stripSuffix c a
    , stripSuffix c b
    , stripSuffix (commonSuffix a b) c
    ]
==>
    (c == commonSuffix a b)

Idempotence

commonSuffix a a == a

Identity

commonSuffix mempty a == mempty
commonSuffix a mempty == mempty

Commutativity

commonSuffix a b == commonSuffix b a

Associativity

commonSuffix (commonSuffix a b) c
==
commonSuffix a (commonSuffix b c)

Equivalences

stripCommonSuffix a b & \(_, _, s) -> s == commonSuffix a b
stripCommonSuffix a b & \(x, _, s) -> x <> s == a
stripCommonSuffix a b & \(_, x, s) -> x <> s == b
stripCommonSuffix a b & \(x, _, s) -> Just x == stripSuffix s a
stripCommonSuffix a b & \(_, x, s) -> Just x == stripSuffix s b

Note that the following superclass laws are not included:

overlappingGCDMonoidLaws :: (Arbitrary a, Show a, Eq a, OverlappingGCDMonoid a) => Proxy a -> Laws Source #

Laws for instances of OverlappingGCDMonoid.

Includes the following laws:

Reductivity

isJust (stripSuffix (overlap a b) a)
isJust (stripPrefix (overlap a b) b)

Idempotence

overlap a a == a

Identity

overlap mempty a == mempty
overlap a mempty == mempty

Equivalences

overlap a b <> stripPrefixOverlap a b == b
stripSuffixOverlap b a <> overlap a b == a
stripOverlap a b & \(_, x, _) -> x == overlap a b
stripOverlap a b & \(_, _, x) -> x == stripPrefixOverlap a b
stripOverlap a b & \(x, _, _) -> x == stripSuffixOverlap b a

Note that the following superclass laws are not included:

distributiveGCDMonoidLaws :: (Arbitrary a, Show a, Eq a, DistributiveGCDMonoid a) => Proxy a -> Laws Source #

Laws for instances of DistributiveGCDMonoid.

Includes the following laws:

Left-distributivity

gcd (a <> b) (a <> c) == a <> gcd b c

Right-distributivity

gcd (a <> c) (b <> c) == gcd a b <> c

Note that the following superclass laws are not included:

leftDistributiveGCDMonoidLaws :: (Arbitrary a, Show a, Eq a, LeftDistributiveGCDMonoid a) => Proxy a -> Laws Source #

Laws for instances of LeftDistributiveGCDMonoid.

Includes the following law:

Left-distributivity

commonPrefix (a <> b) (a <> c) == a <> commonPrefix b c

Note that the following superclass laws are not included:

rightDistributiveGCDMonoidLaws :: (Arbitrary a, Show a, Eq a, RightDistributiveGCDMonoid a) => Proxy a -> Laws Source #

Laws for instances of RightDistributiveGCDMonoid.

Includes the following law:

Right-distributivity

commonSuffix (a <> c) (b <> c) == commonSuffix a b <> c

Note that the following superclass laws are not included: