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.Semigroup.Factorial

Description

This module provides Laws definitions for classes exported by Data.Semigroup.Factorial.

Synopsis

Documentation

factorialLaws :: (Arbitrary a, Show a, Eq a, Factorial a) => Proxy a -> Laws Source #

Laws for instances of Factorial.

Includes the following laws:

length a == Data.List.length (factors a)
maybe a sconcat (nonEmpty           $ factors a) ==         a
maybe a sconcat (nonEmpty $ reverse $ factors a) == reverse a
all (\f -> factors f == [f]) (factors a)
primePrefix a == foldr (\x _ -> x) a a
primeSuffix a == foldl (\_ x -> x) a a
foldl  f x a == Data.List.foldl  f x (factors a)
foldl' f x a == Data.List.foldl' f x (factors a)
foldr  f x a == Data.List.foldr  f x (factors a)

Note that the following superclass laws are not included:

stableFactorialLaws :: (Arbitrary a, Show a, Eq a, StableFactorial a) => Proxy a -> Laws Source #

Laws for instances of StableFactorial.

Includes the following laws:

factors (a <> b) == factors a <> factors b
factors (reverse a) == Data.List.reverse (factors a)
primePrefix a == primeSuffix (reverse a)
primeSuffix a == primePrefix (reverse a)

Note that the following superclass laws are not included: