-- 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
--   <a>checkers</a>. This library differs from other solutions by not
--   introducing any new typeclasses that the user needs to learn. The
--   source code for this library should be easy to understand if you are
--   already familiar with quickcheck. Open an issue if you feel that this
--   is not the case.
@package quickcheck-classes
@version 0.3.3


-- | This library provides lists of properties that should hold for common
--   typeclasses. All of these take a <a>Proxy</a> argument that is used to
--   nail down the type for which the typeclass dictionaries should be
--   tested. For example, at GHCi:
--   
--   <pre>
--   &gt;&gt;&gt; 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.
--   </pre>
--   
--   Assuming that the <a>Arbitrary</a> instance for <a>Ordering</a> is
--   good, we now have confidence that the <a>Monoid</a> instance for
--   <a>Ordering</a> satisfies the monoid laws. We can check multiple
--   typeclasses with:
--   
--   <pre>
--   &gt;&gt;&gt; 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.
--   </pre>
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 the following properties:
--   
--   <ul>
--   <li><i><i>Associative</i></i> <tt>a &lt;&gt; (b &lt;&gt; c) ≡ (a
--   &lt;&gt; b) &lt;&gt; c</tt></li>
--   </ul>
semigroupLaws :: (Semigroup a, Eq a, Arbitrary a, Show a) => Proxy a -> Laws

-- | Tests the following properties:
--   
--   <ul>
--   <li><i><i>Associative</i></i> <tt>mappend a (mappend b c) ≡ mappend
--   (mappend a b) c</tt></li>
--   <li><i><i>Left Identity</i></i> <tt>mappend mempty a ≡ a</tt></li>
--   <li><i><i>Right Identity</i></i> <tt>mappend a mempty ≡ a</tt></li>
--   </ul>
monoidLaws :: (Monoid a, Eq a, Arbitrary a, Show a) => Proxy a -> Laws

-- | Tests everything from <tt>monoidProps</tt> plus the following:
--   
--   <ul>
--   <li><i><i>Commutative</i></i> <tt>mappend a b ≡ mappend b a</tt></li>
--   </ul>
commutativeMonoidLaws :: (Monoid a, Eq a, Arbitrary a, Show a) => Proxy a -> Laws

-- | Tests the following properties:
--   
--   <ul>
--   <li><i><i>Transitive</i></i> <tt>a == b ∧ b == c ⇒ a == c</tt></li>
--   <li><i><i>Symmetric</i></i> <tt>a == b ⇒ b == a</tt></li>
--   <li><i><i>Reflexive</i></i> <tt>a == a</tt></li>
--   </ul>
--   
--   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:
--   
--   <ul>
--   <li><i><i>Transitive</i></i> <tt>a ≤ b ∧ b ≤ c ⇒ a ≤ c</tt></li>
--   <li><i><i>Comparable</i></i> <tt>a ≤ b ∨ a &gt; b</tt></li>
--   </ul>
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:
--   
--   <ul>
--   <li><i><i>Partial Isomorphism</i></i> <tt>decode . encode ≡
--   Just</tt></li>
--   <li><i><i>Encoding Equals Value</i></i> <tt>decode . encode ≡ Just .
--   toJSON</tt></li>
--   </ul>
--   
--   Note that in the second propertiy, the type of decode is
--   <tt>ByteString -&gt; Value</tt>, not <tt>ByteString -&gt; a</tt>
jsonLaws :: (ToJSON a, FromJSON a, Show a, Arbitrary a, Eq a) => Proxy a -> Laws

-- | Tests the following properties:
--   
--   <ul>
--   <li><i><i>Partial Isomorphism</i></i> <tt>fromList . toList ≡
--   id</tt></li>
--   <li><i><i>Length Preservation</i></i> <tt>fromList xs ≡ fromListN
--   (length xs) xs</tt></li>
--   </ul>
isListLaws :: (IsList a, Show a, Show (Item a), Arbitrary a, Arbitrary (Item a), Eq a) => Proxy a -> Laws

-- | Test that a <a>Prim</a> instance obey the several laws.
primLaws :: (Prim a, Eq a, Arbitrary a, Show a) => Proxy a -> Laws
storableLaws :: (Storable a, Eq a, Arbitrary a, Show a) => Proxy a -> Laws

-- | Tests the following properties:
--   
--   <ul>
--   <li><i><i>Quotient Remainder</i></i> <tt>(quot x y) * y + (rem x y) ≡
--   x</tt></li>
--   <li><i><i>Division Modulus</i></i> <tt>(div x y) * y + (mod x y) ≡
--   x</tt></li>
--   <li><i><i>Integer Roundtrip</i></i> <tt>fromInteger (toInteger x) ≡
--   x</tt></li>
--   </ul>
integralLaws :: (Integral a, Arbitrary a, Show a) => Proxy a -> Laws

-- | Tests the following properties:
--   
--   <ul>
--   <li><i><i>Conjunction Idempotence</i></i> <tt>n .&amp;. n ≡
--   n</tt></li>
--   <li><i><i>Disjunction Idempotence</i></i> <tt>n .|. n ≡ n</tt></li>
--   <li><i><i>Double Complement</i></i> <tt>complement (complement n) ≡
--   n</tt></li>
--   <li><i><i>Set Bit</i></i> <tt>setBit n i ≡ n .|. bit i</tt></li>
--   <li><i><i>Clear Bit</i></i> <tt>clearBit n i ≡ n .&amp;. complement
--   (bit i)</tt></li>
--   <li><i><i>Complement Bit</i></i> <tt>complementBit n i ≡ xor n (bit
--   i)</tt></li>
--   <li><i><i>Clear Zero</i></i> <tt>clearBit zeroBits i ≡
--   zeroBits</tt></li>
--   <li><i><i>Set Zero</i></i> <tt>setBit zeroBits i ≡ bit i</tt></li>
--   <li><i><i>Test Zero</i></i> <tt>testBit zeroBits i ≡ False</tt></li>
--   <li><i><i>Pop Zero</i></i> <tt>popCount zeroBits ≡ 0</tt></li>
--   </ul>
--   
--   All of the useful instances of the <a>Bits</a> typeclass also have
--   <a>FiniteBits</a> instances, so these property tests actually require
--   that instance as well.
bitsLaws :: (FiniteBits a, Arbitrary a, Show a) => Proxy a -> Laws

-- | Tests the following applicative properties:
--   
--   <ul>
--   <li><i><i>Identity</i></i> <tt><a>fmap</a> <a>id</a> ≡
--   <a>id</a></tt></li>
--   <li><i><i>Composition</i></i> <tt>fmap (f . g) ≡ <a>fmap</a> f .
--   <a>fmap</a> g</tt></li>
--   <li><i><i>Const</i></i> <tt>(&lt;$) ≡ <a>fmap</a>
--   <a>const</a></tt></li>
--   </ul>
functorLaws :: (Functor f, Eq1 f, Show1 f, Arbitrary1 f) => Proxy f -> Laws

-- | Tests the following applicative properties:
--   
--   <ul>
--   <li><i><i>Identity</i></i> <tt><a>pure</a> <a>id</a> <a>&lt;*&gt;</a>
--   v ≡ v</tt></li>
--   <li><i><i>Composition</i></i> <tt><a>pure</a> (.) <a>&lt;*&gt;</a> u
--   <a>&lt;*&gt;</a> v <a>&lt;*&gt;</a> w ≡ u <a>&lt;*&gt;</a> (v
--   <a>&lt;*&gt;</a> w)</tt></li>
--   <li><i><i>Homomorphism</i></i> <tt><a>pure</a> f <a>&lt;*&gt;</a>
--   <a>pure</a> x ≡ <a>pure</a> (f x)</tt></li>
--   <li><i><i>Interchange</i></i> <tt>u <a>&lt;*&gt;</a> <a>pure</a> y ≡
--   <a>pure</a> (<a>$</a> y) <a>&lt;*&gt;</a> u</tt></li>
--   <li><i><i>LiftA2 (1)</i></i> <tt>(<a>&lt;*&gt;</a>) ≡ <a>liftA2</a>
--   <a>id</a></tt></li>
--   </ul>
applicativeLaws :: (Applicative f, Eq1 f, Show1 f, Arbitrary1 f) => Proxy f -> Laws

-- | Tests the following monadic properties:
--   
--   <ul>
--   <li><i><i>Left Identity</i></i> <tt><a>return</a> a <a>&gt;&gt;=</a> k
--   ≡ k a</tt></li>
--   <li><i><i>Right Identity</i></i> <tt>m <a>&gt;&gt;=</a> <a>return</a>
--   ≡ m</tt></li>
--   <li><i><i>Associativity</i></i> <tt>m <a>&gt;&gt;=</a> (\x -&gt; k x
--   <a>&gt;&gt;=</a> h) ≡ (m <a>&gt;&gt;=</a> k) <a>&gt;&gt;=</a>
--   h</tt></li>
--   <li><i><i>Return</i></i> <tt><a>pure</a> ≡ <a>return</a></tt></li>
--   <li><i><i>Ap</i></i> <tt>(<a>&lt;*&gt;</a>) ≡ <a>ap</a></tt></li>
--   </ul>
monadLaws :: (Monad f, Eq1 f, Show1 f, Arbitrary1 f) => Proxy f -> Laws

-- | Tests the following <a>Foldable</a> properties:
--   
--   <ul>
--   <li><i><i>fold</i></i> <tt><tt>fold</tt> ≡ <a>foldMap</a>
--   <a>id</a></tt></li>
--   <li><i><i>foldMap</i></i> <tt><a>foldMap</a> f ≡ <a>foldr</a>
--   (<a>mappend</a> . f) <a>mempty</a></tt></li>
--   <li><i><i>foldr</i></i> <tt><a>foldr</a> f z t ≡ <tt>appEndo</tt>
--   (<a>foldMap</a> (<tt>Endo</tt> . f) t ) z</tt></li>
--   <li><i><i>foldr'</i></i> <tt><tt>foldr'</tt> f z0 xs = let f' k x z =
--   k <a>$!</a> f x z in <a>foldl</a> f' <a>id</a> xs z0</tt></li>
--   <li><i><i>foldl</i></i> <tt><a>foldl</a> f z t ≡ <tt>appEndo</tt>
--   (<tt>getDual</tt> (<a>foldMap</a> (<tt>Dual</tt> . <tt>Endo</tt> .
--   <a>flip</a> f) t)) z</tt></li>
--   <li><i><i>foldl'</i></i> <tt><tt>foldl'</tt> f z0 xs = let f' x k z =
--   k <a>$!</a> f z x in <a>foldr</a> f' <a>id</a> xs z0</tt></li>
--   <li><i><i>toList</i></i> <tt><a>toList</a> ≡ <a>foldr</a> (:)
--   []</tt></li>
--   <li><i><i>null</i></i> <tt><a>null</a> ≡ <a>foldr</a> (<a>const</a>
--   (<a>const</a> <a>False</a>)) <a>True</a></tt></li>
--   <li><i><i>length</i></i> <tt><a>length</a> ≡ getSum . foldMap
--   (<a>const</a> (<tt>Sum</tt> 1))</tt></li>
--   </ul>
--   
--   Note that this checks to ensure that <tt>foldl'</tt> and
--   <tt>foldr'</tt> are suitably strict.
foldableLaws :: (Foldable f, Eq1 f, Show1 f, Arbitrary1 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 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 Test.QuickCheck.Arbitrary.Arbitrary Test.QuickCheck.Classes.LinearEquation
instance (Data.Functor.Classes.Eq1 f, GHC.Classes.Eq a) => GHC.Classes.Eq (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 (GHC.Base.Applicative f, GHC.Base.Monoid a) => GHC.Base.Monoid (Test.QuickCheck.Classes.Ap f a)
instance GHC.Base.Monoid Test.QuickCheck.Classes.Status
