Safe Haskell | Safe-Infered |
---|

Properties for testing that instances of the `Monad`

class
perform correctly.

This testing requires an `Eq`

instance, which not all `Monad`

s
actually have. It also requires a `Show`

instance, which is also
uncommon. The `Label1`

wrapper may be useful in dealing with the
`Show`

requirement.

Tests are supplied both in regular "unlabelled" form, and also
in a special "labelled" form, where function objects have
`Label`

s attached to them. Because of this, the function used for
each test can be recorded in the test log, which can be quite
helpful.

- p_return_bind :: (Monad m, Eq (m y), Show x, Show (m x), Show (m y)) => x -> (x -> m y) -> Test
- p_bind_return :: (Monad m, Eq (m x), Show (m x)) => m x -> Test
- p_bind_associative :: (Monad m, Eq (m z), Show (m x), Show (m y), Show (m z)) => m x -> (x -> m y) -> (y -> m z) -> Test
- p_Monad :: (Monad m, Eq (m x), Show x, Show (m x)) => [x] -> [x -> m x] -> [m x] -> Test
- p_Functor_Monad :: (Functor m, Monad m, Eq (m y), Show (m x), Show (m y)) => m x -> (x -> y) -> Test
- p_return_bind_L :: (Monad m, Eq (m y), Show x, Show (m x), Show (m y)) => x -> Label (x -> m y) -> Test
- p_bind_associative_L :: (Monad m, Eq (m z), Show (m x), Show (m y), Show (m z)) => m x -> Label (x -> m y) -> Label (y -> m z) -> Test
- p_Monad_L :: (Monad m, Eq (m x), Show x, Show (m x)) => [x] -> [Label (x -> m x)] -> [m x] -> Test
- p_Functor_Monad_L :: (Functor m, Monad m, Eq (m y), Show (m x), Show (m y)) => m x -> Label (x -> y) -> Test

# Unlabelled tests

p_return_bind :: (Monad m, Eq (m y), Show x, Show (m x), Show (m y)) => x -> (x -> m y) -> TestSource

Check that `return x >>= f `

.
`==`

f x

p_bind_return :: (Monad m, Eq (m x), Show (m x)) => m x -> TestSource

Check that `mx >>= return `

.
`==`

mx

p_bind_associative :: (Monad m, Eq (m z), Show (m x), Show (m y), Show (m z)) => m x -> (x -> m y) -> (y -> m z) -> TestSource

p_Monad :: (Monad m, Eq (m x), Show x, Show (m x)) => [x] -> [x -> m x] -> [m x] -> TestSource

Given a list of *distinct* inputs, run all applicable `Monad`

tests on all combinations of inputs. (If the inputs are not
distinct, some redundant tests will be performed.)

The argument types have been constrainted a bit to keep the function's type signature reasonably simple.

p_Functor_Monad :: (Functor m, Monad m, Eq (m y), Show (m x), Show (m y)) => m x -> (x -> y) -> TestSource

Check that `fmap f mx `

.
`==`

mx >>= return . f

# Labelled tests

p_return_bind_L :: (Monad m, Eq (m y), Show x, Show (m x), Show (m y)) => x -> Label (x -> m y) -> TestSource

Check that `return x >>= f `

.
`==`

f x

p_bind_associative_L :: (Monad m, Eq (m z), Show (m x), Show (m y), Show (m z)) => m x -> Label (x -> m y) -> Label (y -> m z) -> TestSource

p_Monad_L :: (Monad m, Eq (m x), Show x, Show (m x)) => [x] -> [Label (x -> m x)] -> [m x] -> TestSource

Given a list of *distinct* inputs, run all applicable `Monad`

tests on all combinations of inputs. (If the inputs are not
distinct, some redundant tests will be performed.)

The argument types have been constrainted a bit to keep the function's type signature reasonably simple.