-- Hoogle documentation, generated by Haddock
-- See Hoogle, http://www.haskell.org/hoogle/
-- | QuickCheck common typeclasses
--
-- This library provides quickcheck properties to ensure that typeclass
-- instances the set of laws that they are supposed to. There are other
-- libraries that do similar things, such as `genvalidity-hspec` and
-- checkers. This library differs from other solutions by not
-- introducing any new typeclasses that the user needs to learn.
@package quickcheck-classes
@version 0.4.3
-- | This library provides lists of properties that should hold for common
-- typeclasses. All of these take a Proxy argument that is used to
-- nail down the type for which the typeclass dictionaries should be
-- tested. For example, at GHCi:
--
--
-- >>> lawsCheck (monoidLaws (Proxy :: Proxy Ordering))
-- Monoid: Associative +++ OK, passed 100 tests.
-- Monoid: Left Identity +++ OK, passed 100 tests.
-- Monoid: Right Identity +++ OK, passed 100 tests.
--
--
-- Assuming that the Arbitrary instance for Ordering is
-- good, we now have confidence that the Monoid instance for
-- Ordering satisfies the monoid laws. We can check multiple
-- typeclasses with:
--
--
-- >>> foldMap (lawsCheck . ($ (Proxy :: Proxy Word))) [jsonLaws,showReadLaws]
-- ToJSON/FromJSON: Encoding Equals Value +++ OK, passed 100 tests.
-- ToJSON/FromJSON: Partial Isomorphism +++ OK, passed 100 tests.
-- Show/Read: Partial Isomorphism +++ OK, passed 100 tests.
--
module Test.QuickCheck.Classes
-- | A convenience function for working testing properties in GHCi. See the
-- test suite of this library for an example of how to integrate multiple
-- properties into larger test suite.
lawsCheck :: Laws -> IO ()
-- | A convenience function for checking multiple typeclass instances of
-- multiple types.
lawsCheckMany :: [(String, [Laws])] -> IO ()
-- | Tests everything from monoidProps plus the following:
--
--
-- - Commutative mappend a b ≡ mappend b a
--
commutativeMonoidLaws :: (Monoid a, Eq a, Arbitrary a, Show a) => Proxy a -> Laws
-- | Tests the following properties:
--
--
-- - Transitive a == b ∧ b == c ⇒ a == c
-- - Symmetric a == b ⇒ b == a
-- - Reflexive a == a
--
--
-- Some of these properties involve implication. In the case that the
-- left hand side of the implication arrow does not hold, we do not
-- retry. Consequently, these properties only end up being useful when
-- the data type has a small number of inhabitants.
eqLaws :: (Eq a, Arbitrary a, Show a) => Proxy a -> Laws
-- | Tests the following properties:
--
--
-- - Antisymmetry @a ≤ b ∧ b ≤ a ⇒ a = b
-- - Transitivity a ≤ b ∧ b ≤ c ⇒ a ≤ c
-- - Totality a ≤ b ∨ a > b
--
ordLaws :: (Ord a, Arbitrary a, Show a) => Proxy a -> Laws
showReadLaws :: (Show a, Read a, Eq a, Arbitrary a) => Proxy a -> Laws
-- | Tests the following properties:
--
--
-- - Partial Isomorphism decode . encode ≡
-- Just
-- - Encoding Equals Value decode . encode ≡ Just .
-- toJSON
--
--
-- Note that in the second propertiy, the type of decode is
-- ByteString -> Value, not ByteString -> a
jsonLaws :: (ToJSON a, FromJSON a, Show a, Arbitrary a, Eq a) => Proxy a -> Laws
-- | Tests the following properties:
--
--
-- - Quotient Remainder (quot x y) * y + (rem x y) ≡
-- x
-- - Division Modulus (div x y) * y + (mod x y) ≡
-- x
-- - Integer Roundtrip fromInteger (toInteger x) ≡
-- x
--
integralLaws :: (Integral a, Arbitrary a, Show a) => Proxy a -> Laws
-- | Tests the following properties:
--
--
-- - Partial Isomorphism decode . encode ≡
-- Just
-- - Encoding Equals Value decode . encode ≡ Just .
-- toJSON
--
--
-- Note that in the second propertiy, the type of decode is
-- ByteString -> Value, not ByteString -> a
jsonLaws :: (ToJSON a, FromJSON a, Show a, Arbitrary a, Eq a) => Proxy a -> Laws
-- | Tests the following properties:
--
--
-- - Associative mappend a (mappend b c) ≡ mappend
-- (mappend a b) c
-- - Left Identity mappend mempty a ≡ a
-- - Right Identity mappend a mempty ≡ a
--
monoidLaws :: (Monoid a, Eq a, Arbitrary a, Show a) => Proxy a -> Laws
-- | Tests the following properties:
--
--
-- - Antisymmetry @a ≤ b ∧ b ≤ a ⇒ a = b
-- - Transitivity a ≤ b ∧ b ≤ c ⇒ a ≤ c
-- - Totality a ≤ b ∨ a > b
--
ordLaws :: (Ord a, Arbitrary a, Show a) => Proxy a -> Laws
-- | Test that a Prim instance obey the several laws.
primLaws :: (Prim a, Eq a, Arbitrary a, Show a) => Proxy a -> Laws
-- | Tests the following properties:
--
--
-- - Associative a <> (b <> c) ≡ (a
-- <> b) <> c
--
semigroupLaws :: (Semigroup a, Eq a, Arbitrary a, Show a) => Proxy a -> Laws
showReadLaws :: (Show a, Read a, Eq a, Arbitrary a) => Proxy a -> Laws
storableLaws :: (Storable a, Eq a, Arbitrary a, Show a) => Proxy a -> Laws
-- | Tests the following properties:
--
--
-- - Quotient Remainder (quot x y) * y + (rem x y) ≡
-- x
-- - Division Modulus (div x y) * y + (mod x y) ≡
-- x
-- - Integer Roundtrip fromInteger (toInteger x) ≡
-- x
--
integralLaws :: (Integral a, Arbitrary a, Show a) => Proxy a -> Laws
-- | Tests the following properties:
--
--
-- - Conjunction Idempotence n .&. n ≡
-- n
-- - Disjunction Idempotence n .|. n ≡ n
-- - Double Complement complement (complement n) ≡
-- n
-- - Set Bit setBit n i ≡ n .|. bit i
-- - Clear Bit clearBit n i ≡ n .&. complement
-- (bit i)
-- - Complement Bit complementBit n i ≡ xor n (bit
-- i)
-- - Clear Zero clearBit zeroBits i ≡
-- zeroBits
-- - Set Zero setBit zeroBits i ≡ bit i
-- - Test Zero testBit zeroBits i ≡ False
-- - Pop Zero popCount zeroBits ≡ 0
-- - Count Leading Zeros of Zero countLeadingZeros
-- zeroBits ≡ finiteBitSize ⊥
-- - Count Trailing Zeros of Zero countTrailingZeros
-- zeroBits ≡ finiteBitSize ⊥
--
--
-- All of the useful instances of the Bits typeclass also have
-- FiniteBits instances, so these property tests actually require
-- that instance as well.
--
-- Note: This property test is only available when using
-- base-4.7 or newer.
bitsLaws :: (FiniteBits a, Arbitrary a, Show a) => Proxy a -> Laws
-- | Tests the following properties:
--
--
-- - Partial Isomorphism fromList . toList ≡
-- id
-- - Length Preservation fromList xs ≡ fromListN
-- (length xs) xs
--
--
-- Note: This property test is only available when using
-- base-4.7 or newer.
isListLaws :: (IsList a, Show a, Show (Item a), Arbitrary a, Arbitrary (Item a), Eq a) => Proxy a -> Laws
-- | Tests the following alt properties:
--
--
altLaws :: (Alt f, Eq1 f, Show1 f, Arbitrary1 f) => proxy f -> Laws
-- | Tests the following alternative properties:
--
--
alternativeLaws :: (Alternative f, Eq1 f, Show1 f, Arbitrary1 f) => proxy f -> Laws
-- | Tests the following applicative properties:
--
--
applicativeLaws :: (Applicative f, Eq1 f, Show1 f, Arbitrary1 f) => proxy f -> Laws
-- | Tests the following Foldable properties:
--
--
--
-- Note that this checks to ensure that foldl' and
-- foldr' are suitably strict.
foldableLaws :: (Foldable f, Eq1 f, Show1 f, Arbitrary1 f) => proxy f -> Laws
-- | Tests the following Traversable properties:
--
--
--
-- Where an applicative transformation is a function
--
--
-- t :: (Applicative f, Applicative g) => f a -> g a
--
--
-- preserving the Applicative operations, i.e.
--
--
-- - Identity: t (pure x) = pure x
-- - Distributivity: t (x <*> y) = t x
-- <*> t y
--
traversableLaws :: (Traversable f, Eq1 f, Show1 f, Arbitrary1 f) => proxy f -> Laws
-- | Tests the following functor properties:
--
--
functorLaws :: (Functor f, Eq1 f, Show1 f, Arbitrary1 f) => proxy f -> Laws
-- | Tests the following monadic properties:
--
--
monadLaws :: (Monad f, Applicative f, Eq1 f, Show1 f, Arbitrary1 f) => proxy f -> Laws
-- | Tests the following Bifunctor properties:
--
--
--
-- Note: This property test is only available when this package is
-- built with base-4.9+ or transformers-0.5+.
bifunctorLaws :: (Bifunctor f, Eq2 f, Show2 f, Arbitrary2 f) => proxy f -> Laws
-- | A set of laws associated with a typeclass.
data Laws
Laws :: String -> [(String, Property)] -> Laws
-- | Name of the typeclass whose laws are tested
[lawsTypeclass] :: Laws -> String
-- | Pairs of law name and property
[lawsProperties] :: Laws -> [(String, Property)]
instance GHC.Classes.Eq Test.QuickCheck.Classes.EquationTwo
instance GHC.Classes.Eq Test.QuickCheck.Classes.Equation
instance GHC.Classes.Eq Test.QuickCheck.Classes.LinearEquation
instance GHC.Classes.Eq a => GHC.Classes.Eq (Test.QuickCheck.Classes.Bottom a)
instance GHC.Classes.Eq Test.QuickCheck.Classes.LastNothing
instance GHC.Classes.Eq Test.QuickCheck.Classes.ChooseFirst
instance GHC.Classes.Eq Test.QuickCheck.Classes.ChooseSecond
instance GHC.Classes.Eq a => GHC.Classes.Eq (Test.QuickCheck.Classes.Triple a)
instance GHC.Show.Show a => GHC.Show.Show (Test.QuickCheck.Classes.Triple a)
instance (GHC.Classes.Eq a, Data.Primitive.Types.Prim a) => GHC.Classes.Eq (Test.QuickCheck.Classes.PrimArray a)
instance Data.Primitive.Types.Prim a => GHC.Exts.IsList (Test.QuickCheck.Classes.PrimArray a)
instance Data.Bits.FiniteBits a => Test.QuickCheck.Arbitrary.Arbitrary (Test.QuickCheck.Classes.BitIndex a)
instance GHC.Show.Show Test.QuickCheck.Classes.EquationTwo
instance Test.QuickCheck.Arbitrary.Arbitrary Test.QuickCheck.Classes.EquationTwo
instance GHC.Show.Show Test.QuickCheck.Classes.Equation
instance Test.QuickCheck.Arbitrary.Arbitrary Test.QuickCheck.Classes.Equation
instance Data.Functor.Classes.Eq1 m => GHC.Classes.Eq (Test.QuickCheck.Classes.LinearEquationM m)
instance Data.Functor.Classes.Show1 m => GHC.Show.Show (Test.QuickCheck.Classes.LinearEquationM m)
instance Test.QuickCheck.Arbitrary.Arbitrary1 m => Test.QuickCheck.Arbitrary.Arbitrary (Test.QuickCheck.Classes.LinearEquationM m)
instance GHC.Show.Show Test.QuickCheck.Classes.LinearEquation
instance Test.QuickCheck.Arbitrary.Arbitrary Test.QuickCheck.Classes.LinearEquation
instance (Data.Functor.Classes.Eq2 f, GHC.Classes.Eq a, GHC.Classes.Eq b) => GHC.Classes.Eq (Test.QuickCheck.Classes.Apply2 f a b)
instance (Data.Functor.Classes.Show2 f, GHC.Show.Show a, GHC.Show.Show b) => GHC.Show.Show (Test.QuickCheck.Classes.Apply2 f a b)
instance (Test.QuickCheck.Arbitrary.Arbitrary2 f, Test.QuickCheck.Arbitrary.Arbitrary a, Test.QuickCheck.Arbitrary.Arbitrary b) => Test.QuickCheck.Arbitrary.Arbitrary (Test.QuickCheck.Classes.Apply2 f a b)
instance (Data.Functor.Classes.Eq1 f, GHC.Classes.Eq a) => GHC.Classes.Eq (Test.QuickCheck.Classes.Apply f a)
instance (GHC.Base.Applicative f, GHC.Base.Monoid a) => Data.Semigroup.Semigroup (Test.QuickCheck.Classes.Apply f a)
instance (GHC.Base.Applicative f, GHC.Base.Monoid a) => GHC.Base.Monoid (Test.QuickCheck.Classes.Apply f a)
instance (Data.Functor.Classes.Show1 f, GHC.Show.Show a) => GHC.Show.Show (Test.QuickCheck.Classes.Apply f a)
instance (Test.QuickCheck.Arbitrary.Arbitrary1 f, Test.QuickCheck.Arbitrary.Arbitrary a) => Test.QuickCheck.Arbitrary.Arbitrary (Test.QuickCheck.Classes.Apply f a)
instance GHC.Show.Show a => GHC.Show.Show (Test.QuickCheck.Classes.Bottom a)
instance Test.QuickCheck.Arbitrary.Arbitrary a => Test.QuickCheck.Arbitrary.Arbitrary (Test.QuickCheck.Classes.Bottom a)
instance GHC.Show.Show Test.QuickCheck.Classes.LastNothing
instance Test.QuickCheck.Arbitrary.Arbitrary Test.QuickCheck.Classes.LastNothing
instance GHC.Show.Show Test.QuickCheck.Classes.ChooseFirst
instance Test.QuickCheck.Arbitrary.Arbitrary Test.QuickCheck.Classes.ChooseFirst
instance GHC.Show.Show Test.QuickCheck.Classes.ChooseSecond
instance Test.QuickCheck.Arbitrary.Arbitrary Test.QuickCheck.Classes.ChooseSecond
instance Data.Functor.Classes.Eq1 Test.QuickCheck.Classes.Triple
instance Data.Functor.Classes.Show1 Test.QuickCheck.Classes.Triple
instance Test.QuickCheck.Arbitrary.Arbitrary1 Test.QuickCheck.Classes.Triple
instance Test.QuickCheck.Arbitrary.Arbitrary a => Test.QuickCheck.Arbitrary.Arbitrary (Test.QuickCheck.Classes.Triple a)
instance GHC.Base.Functor Test.QuickCheck.Classes.Triple
instance GHC.Base.Applicative Test.QuickCheck.Classes.Triple
instance Data.Foldable.Foldable Test.QuickCheck.Classes.Triple
instance Data.Traversable.Traversable Test.QuickCheck.Classes.Triple
instance (GHC.Base.Applicative f, Data.Semigroup.Semigroup a) => Data.Semigroup.Semigroup (Test.QuickCheck.Classes.Ap f a)
instance (GHC.Base.Applicative f, GHC.Base.Monoid a, Data.Semigroup.Semigroup a) => GHC.Base.Monoid (Test.QuickCheck.Classes.Ap f a)
instance Data.Semigroup.Semigroup Test.QuickCheck.Classes.Status
instance GHC.Base.Monoid Test.QuickCheck.Classes.Status