smallcheck-laws-0.3: SmallCheck properties for common laws

Safe HaskellSafe-Inferred
LanguageHaskell2010

Test.SmallCheck.Laws.Monad

Contents

Description

Provided a Monad is already an Applicative there is no need to check the first 2 monad laws. See Bind for which laws are exclusive for the >>= method.

Synopsis

Monad laws

associativity :: (Monad m, Monad f, Show a, Show b, Show c, Show (f a), Show (f b), Show (f c), Eq (f a), Eq (f c), Serial Identity a, Serial Identity b, Serial Identity c) => Series m (f a) -> Series m (a -> f b) -> Series m (b -> f c) -> Property m Source

Check the associativity law hold for the given Monad Series:

(m >>= f) >>= g ≡ m (f >=> g)

This is equivalent to:

(f >=> g) >=> h == f >=> (g >=> h)

Exhaustive generation of m, f and g. Be aware of combinatorial explosion.

This assumes join derived from >>= from the default implementation of Monad.

associativitySum :: (Monad m, Monad f, Show a, Show b, Show c, Show (f a), Show (f b), Show (f c), Eq (f a), Eq (f c), Serial Identity a, Serial Identity b, Serial Identity c) => Series m (f a) -> Series m (a -> f b) -> Series m (b -> f c) -> Property m Source

Check the associativity law hold for the given Monad Series:

(m >>= f) >>= g ≡ m (f >=> g)

This is equivalent to:

(f >=> g) >=> h == f >=> (g >=> h)

This uses zipLogic3 for the generation Series of m, f and g.

This assumes join derived from >>= from the default implementation of Monad.