props-0.1.2: Reusable quickcheck properties

Safe HaskellSafe-Inferred

Test.Properties

Synopsis

Documentation

symmetric :: Eq b => (t -> t -> b) -> t -> t -> BoolSource

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

antisymmetric :: Eq b => (b -> b -> b) -> b -> b -> BoolSource

symmetric f a b implies a == b

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

inverts :: Eq b => (b -> b1) -> (b1 -> b) -> b -> BoolSource

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

involutive :: Eq b => (b -> b) -> b -> BoolSource

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

involutive negate
involutive reverse :: String -> Bool

nonDecreasing :: Ord b => (b -> b) -> b -> BoolSource

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

increasing :: Ord b => (b -> b) -> b -> BoolSource

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

fixes :: Eq b => (b -> b) -> b -> BoolSource

Alias for idempotent

idempotent :: Eq b => (b -> b) -> b -> BoolSource

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

leftId :: Eq b => (t -> b -> b) -> t -> b -> BoolSource

f e a == a
leftId (+) 0

rightId :: Eq b => (b -> t -> b) -> t -> b -> BoolSource

f a e == a
rightId (+) 0

identity :: Eq b => (b -> b -> b) -> b -> b -> BoolSource

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

associative :: Eq b => (b -> b -> b) -> b -> b -> b -> BoolSource

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

monoidal :: Eq b => (b -> b -> b) -> b -> b -> b -> b -> BoolSource

identity f e and associative f a b c

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

isomorphic :: (Eq b, Eq b1) => (b -> b1) -> (b1 -> b) -> b -> b1 -> BoolSource

a == (f . g) a && b == (g . f) b
isomorphic succ (pred :: Int -> Int)
isomorphic not not
isomorphic reverse (reverse :: String -> String)
isomorphic snd (((),) :: Int -> ((),Int))

partiallyIsomorphic :: Eq b => (b -> b1) -> (b1 -> Maybe b) -> b -> BoolSource

Just a == (g . f) a
partiallyIsomorphic id Just
partiallyIsomorphic show readMaybe

absorptive :: Eq b => (b -> b -> b) -> (b -> b -> b) -> b -> b -> BoolSource

f a (g a b) == a && g a (f a b) == a

http://en.wikipedia.org/wiki/Absorption_law

absorptive (&&) (||)
absorptive min max

equalizes :: Eq b => (a -> b) -> (t -> a) -> (t -> a) -> t -> BoolSource

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

eqBy :: Eq b => (a -> b) -> a -> a -> BoolSource

leqBy :: Ord b => (a -> b) -> a -> a -> BoolSource

leBy :: Ord b => (a -> b) -> a -> a -> BoolSource

symmetricBy :: Eq b => (a -> b) -> (t -> t -> a) -> t -> t -> BoolSource

antisymmetricBy :: Eq b => (t -> b) -> (t -> t -> t) -> t -> t -> BoolSource

invertsBy :: Eq b => (a -> b) -> (a -> b1) -> (b1 -> a) -> a -> BoolSource

involutiveBy :: Eq b => (b1 -> b) -> (b1 -> b1) -> b1 -> BoolSource

nonDecreasingBy :: Ord b => (a -> b) -> (a -> a) -> a -> BoolSource

increasingBy :: Ord b => (a -> b) -> (a -> a) -> a -> BoolSource

fixesBy :: Eq b => (a -> b) -> (a -> a) -> a -> BoolSource

idempotentBy :: Eq b => (a -> b) -> (a -> a) -> a -> BoolSource

associativeBy :: Eq b => (a -> b) -> (a -> a -> a) -> a -> a -> a -> BoolSource

monoidalBy :: Eq b => (a -> b) -> (a -> a -> a) -> a -> a -> a -> a -> BoolSource

leftIdBy :: Eq b => (a -> b) -> (t -> a -> a) -> t -> a -> BoolSource

rightIdBy :: Eq b => (a -> b) -> (a -> t -> a) -> t -> a -> BoolSource

identityBy :: Eq b => (t -> b) -> (t -> t -> t) -> t -> t -> BoolSource

isomorphicBy :: (Eq b, Eq b1) => (b2 -> b) -> (a -> b1) -> (b2 -> a) -> (a -> b2) -> b2 -> a -> BoolSource

partiallyIsomorphicBy :: Eq b => (a -> b) -> (a -> b1) -> (b1 -> Maybe a) -> a -> BoolSource

absorptiveBy :: Eq b => (a -> b) -> (a -> a -> a) -> (a -> a -> a) -> a -> a -> BoolSource

= DocTest Setup

>>> :set -XTupleSections
>>> import Text.Read (readMaybe)