smallcheck-laws-0.3: SmallCheck properties for common laws

Safe HaskellSafe-Inferred
LanguageHaskell2010

Test.SmallCheck.Laws.Monoid

Contents

Synopsis

Identity

leftIdentity :: (Eq a, Monad m, Show a, Monoid a) => Series m a -> Property m Source

Check the left identity law holds for the given Monoid Series:

mempty <> x ≡ x

rightIdentity :: (Eq a, Monad m, Show a, Monoid a) => Series m a -> Property m Source

Check the right identity law holds for the given Monoid Series:

x <> mempty ≡ x

Associativity

associativity :: (Eq a, Monad m, Show a, Monoid a) => Series m a -> Series m a -> Series m a -> Property m Source

Check the associativity law holds for the given Monoid Series:

x <> (y <> z) ≡ (x <> y) <> z

This uses the product of the 3 Series, be aware of combinatorial explosion.

associativitySum :: (Eq a, Monad m, Show a, Monoid a) => Series m a -> Series m a -> Series m a -> Property m Source

Check the associativity law hold for the given Monoid Series:

x <> (y <> z) ≡ (x <> y) <> z

This uses the sum of the 3 Series.

mconcat

mconcatProp :: (Eq a, Monad m, Show a, Monoid a) => Series m a -> Property m Source

When implementing mconcat yourself this must hold:

mconcatfoldr mappend mempty