ClassLaws-0.3.0.0: Stating and checking laws for type class methods

Safe HaskellSafe-Infered

Test.ClassLaws.TestingEquality

Description

The following class + helper functions implement law-agnostic testing functionality that is used to test laws for various classes.

Synopsis

Documentation

class TestEqual b whereSource

A class for types which can be checked for Equality, possibly needing some extra Parameters.

Methods

testEqual :: Equal b -> Param b -> PropertySource

Instances

(Eq a, Show a) => TestEqual [a] 
(SemanticEq (Endo a), Show (Partial (Endo a))) => TestEqual (Endo a) 
(Eq a, Show a) => TestEqual (Maybe a) 
(Eq a, Show a) => TestEqual (MyList a) 
(Eq a, Show a, Eq s, Show s) => TestEqual (State s a) 
(SemanticEq a, Show (Partial a), SemanticEq s, Show (Partial s), Bounded s, Enum s) => TestEqual (SS s a) 
(SemanticEq a, Show (Partial a), SemanticEq s, Show (Partial s), Bounded s, Enum s) => TestEqual (State s a) 

testRunEq :: Show r => (t -> p -> r) -> (r -> r -> Bool) -> Equal t -> p -> PropertySource

The first function, testRunEq, returns a property implementing an equality check. It takes a function that can run a value and a comparison operator to a predicate (which in turn takes some supposedly equal values, and a parameter needed for the run function, and returns a Property).

testEq :: Show a => (a -> a -> Bool) -> Equal a -> PropertySource

The second function, testEq, does the same, but now for pairs that are not necessarily runnable.

testRunEqPartial :: Show (Partial r) => (t -> p -> r) -> (r -> r -> Bool) -> Equal t -> p -> PropertySource

Variant of testRunEq intended for Partial values. (Only the Show part differs - the user also needs to supply an equality operator handling Partial values.)

testEqPartial :: Show (Partial a) => (a -> a -> Bool) -> Equal a -> PropertySource

Similar variant of testEq for Partial values.

pairwiseEq :: (r -> r -> Bool) -> [r] -> BoolSource

Local helper

type Pos = IntSource

Position in an equality proof

failingPair :: (a -> a -> Bool) -> Equal a -> (Pos, a, a)Source

Local helper

failingPair' :: Num t => t -> (t1 -> t1 -> Bool) -> [t1] -> (t, t1, t1)Source

Local helper