props-0.1: Properties of functions and relations, perhaps for use with quickcheck

Safe HaskellSafe-Inferred
LanguageHaskell2010

Test.Properties

Synopsis

Documentation

symmetric :: Eq b => (t -> t -> b) -> t -> t -> Bool Source

f a b == f b a
symmetric (==) :: Int -> Int -> Bool
symmetric (+)  :: Int -> Int -> Bool

antisymmetric :: Eq b => (b -> b -> b) -> b -> b -> Bool Source

symmetric f a b implies a == b

antisymmetric (-) :: Int -> Int -> Bool

inverts :: Eq b => (b -> b1) -> (b1 -> b) -> b -> Bool Source

a == (g . f) a
inverts pred succ :: Int -> Bool
inverts succ pred :: Char -> Bool

involutive :: Eq b => (b -> b) -> b -> Bool Source

a == (f . f) a (alternatively, inverts f f)

involutive negate
involutive reverse :: String -> Bool

nonDecreasing :: Ord b => (b -> b) -> b -> Bool Source

a <= f a
nonDecreasing id
nonDecreasing (\x -> if even x then x else succ x)

increasing :: Ord b => (b -> b) -> b -> Bool Source

a < f a
increasing succ :: Int -> Bool

fixes :: Eq b => (b -> b) -> b -> Bool Source

Alias for idempotent

idempotent :: Eq b => (b -> b) -> b -> Bool Source

f a == f (f a)
idempotent (const "thingy")
idempotent (*0)
idempotent (&& False)

leftId :: Eq b => (t -> b -> b) -> t -> b -> Bool Source

f e a == a
leftId (+) 0

rightId :: Eq b => (b -> t -> b) -> t -> b -> Bool Source

f a e == a
rightId (+) 0

identity :: Eq b => (b -> b -> b) -> b -> b -> Bool Source

leftId f e && rightId f e
identity (+) 0

associative :: Eq b => (b -> b -> b) -> b -> b -> b -> Bool Source

f a (f b c) == f (f a b) c
associative (&&)
associative (||)
associative (++)
associative (*)

monoidal :: Eq b => (b -> b -> b) -> b -> b -> b -> b -> Bool Source

identity f e and associative f a b c

monoidal (&&) True
monoidal (||) False
monoidal (++) []
monoidal (*) 1

equalizes :: Eq b => (a -> b) -> (t -> a) -> (t -> a) -> t -> Bool Source

eq (f a) == eq (g a)
equalizes even (*2) (*4)
equalizes (const [4]) (take 7) (take 12)

eqBy :: Eq b => (a -> b) -> a -> a -> Bool Source

leqBy :: Ord b => (a -> b) -> a -> a -> Bool Source

leBy :: Ord b => (a -> b) -> a -> a -> Bool Source

symmetricBy :: Eq b => (a -> b) -> (t -> t -> a) -> t -> t -> Bool Source

antisymmetricBy :: Eq b => (t -> b) -> (t -> t -> t) -> t -> t -> Bool Source

invertsBy :: Eq b => (s -> b) -> (s -> b1) -> (b1 -> s) -> s -> Bool Source

involutiveBy :: Eq b => (b1 -> b) -> (b1 -> b1) -> b1 -> Bool Source

nonDecreasingBy :: Ord b => (a -> b) -> (a -> a) -> a -> Bool Source

increasingBy :: Ord b => (a -> b) -> (a -> a) -> a -> Bool Source

fixesBy :: Eq b => (s -> b) -> (s -> s) -> s -> Bool Source

idempotentBy :: Eq b => (s -> b) -> (s -> s) -> s -> Bool Source

associativeBy :: Eq b => (a -> b) -> (a -> a -> a) -> a -> a -> a -> Bool Source

monoidalBy :: Eq b => (a -> b) -> (a -> a -> a) -> a -> a -> a -> a -> Bool Source

leftIdBy :: Eq b => (a -> b) -> (t -> a -> a) -> t -> a -> Bool Source

rightIdBy :: Eq b => (a -> b) -> (a -> t -> a) -> t -> a -> Bool Source

identityBy :: Eq b => (t -> b) -> (t -> t -> t) -> t -> t -> Bool Source