quickcheck-classes-0.2: QuickCheck common typeclasses

Safe HaskellNone
LanguageHaskell2010

Test.QuickCheck.Classes

Synopsis

Documentation

primProps :: (Prim a, Eq a, Arbitrary a, Show a) => Proxy a -> [(String, Property)] Source #

semigroupProps :: (Semigroup a, Eq a, Arbitrary a, Show a) => Proxy a -> [(String, Property)] Source #

Tests the following properties:

Associative
a <> (b <> c) ≡ (a <> b) <> c

monoidProps :: (Monoid a, Eq a, Arbitrary a, Show a) => Proxy a -> [(String, Property)] Source #

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

eqProps :: (Eq a, Arbitrary a, Show a) => Proxy a -> [(String, Property)] Source #

Tests the following properties:

Transitive
a == b ∧ b == c ⇒ a == c
Symmetric
a == b ⇒ b == 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.

functorProps :: (Functor f, Eq1 f, Show1 f, Arbitrary1 f) => Proxy f -> [(String, Property)] Source #

Tests the following applicative properties:

Identity
fmap idid
Composition
fmap (f . g) ≡ fmap f . fmap g
Const
(<$) ≡ fmap const

applicativeProps :: (Applicative f, Eq1 f, Show1 f, Arbitrary1 f) => Proxy f -> [(String, Property)] Source #

Tests the following applicative properties:

Identity
pure id <*> v ≡ v
Composition
pure (.) <*> u <*> v <*> w ≡ u <*> (v <*> w)
Homomorphism
pure f <*> pure x ≡ pure (f x)
Interchange
u <*> pure y ≡ pure ($ y) <*> u
LiftA2 (1)
(<*>) ≡ liftA2 id

monadProps :: (Monad f, Eq1 f, Show1 f, Arbitrary1 f) => Proxy f -> [(String, Property)] Source #

Tests the following monadic properties:

Left Identity
return a >>= k ≡ k a
Right Identity
m >>= return ≡ m
Associativity
m >>= (\x -> k x >>= h) ≡ (m >>= k) >>= h
Return
purereturn
Ap
(<*>) ≡ ap