Safe Haskell | Safe-Inferred |
---|---|

Language | Haskell2010 |

- (<=>) :: Eq b => (a -> b) -> (a -> b) -> a -> Bool
- (&>) :: Testable b => (a -> Bool) -> (a -> b) -> a -> Property
- idempotent :: Eq a => (a -> a) -> a -> Bool
- pointSymmetric :: (Num a, Num b, Eq b) => (a -> b) -> a -> Bool
- reflectionSymmetric :: (Num a, Eq b) => (a -> b) -> a -> Bool
- monotonicIncreasing :: (Ord a, Ord b) => (a -> b) -> a -> a -> Bool
- monotonicIncreasing' :: (Ord a, Ord b) => (a -> b) -> a -> a -> Bool
- monotonicDecreasing :: (Ord a, Ord b) => (a -> b) -> a -> a -> Bool
- monotonicDecreasing' :: (Ord a, Ord b) => (a -> b) -> a -> a -> Bool
- involutory :: Eq a => (a -> a) -> a -> Bool
- inverts :: Eq a => (b -> a) -> (a -> b) -> a -> Bool
- commutative :: Eq b => (a -> a -> b) -> a -> a -> Bool
- associative :: Eq a => (a -> a -> a) -> a -> a -> a -> Bool
- distributesLeftOver :: Eq a => (a -> a -> a) -> (a -> a -> a) -> a -> a -> a -> Bool
- distributesRightOver :: Eq a => (a -> a -> a) -> (a -> a -> a) -> a -> a -> a -> Bool
- distributesOver :: Eq a => (a -> a -> a) -> (a -> a -> a) -> a -> a -> a -> Bool
- inflating :: ([a] -> [b]) -> [a] -> Bool
- inflating' :: ([a] -> [b]) -> [a] -> Bool
- deflating :: ([a] -> [b]) -> [a] -> Bool
- deflating' :: ([a] -> [b]) -> [a] -> Bool
- cyclesWithin :: Eq a => (a -> a) -> Int -> a -> Bool
- invariatesOver :: Eq b => (a -> b) -> (a -> a) -> a -> Bool
- fixedBy :: Eq c => (a -> b -> c) -> a -> b -> b -> Bool
- (<~~) :: Eq b => (a -> b) -> (a -> a) -> a -> Bool
- (@~>) :: Eq a => (b -> a) -> (a -> b) -> a -> Bool
- (<?>) :: Eq a => (a -> a) -> (a -> a) -> a -> Bool
- (<??>) :: Eq a => (a -> a) -> (a -> a -> a) -> a -> a -> Bool
- (<???>) :: Eq a => (a -> a) -> (a -> a -> a -> a) -> a -> a -> a -> Bool

# Documentation

(<=>) :: Eq b => (a -> b) -> (a -> b) -> a -> Bool infix 2 Source

Defines extensional equality. This allows concise, point-free, definitions of laws.

f(x) == g(x) f <=> g

(&>) :: Testable b => (a -> Bool) -> (a -> b) -> a -> Property infix 1 Source

Pointfree version of QuickChecks ==>. This notation reduces a lot of lambdas, for example:

`>>>`

+++ OK, passed 100 tests.`quickCheck $ (/=0) &> not . idempotent (*(2::Int))`

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

Checks whether a function is idempotent.

f(f(x)) == f(x)

`>>>`

+++ OK, passed 100 tests.`quickCheck $ idempotent (abs :: Int -> Int)`

pointSymmetric :: (Num a, Num b, Eq b) => (a -> b) -> a -> Bool Source

Checks whether a function is pointSymmetric.

f(-x) == -f(x)

`>>>`

+++ OK, passed 100 tests.`quickCheck $ pointSymmetric (^3)`

reflectionSymmetric :: (Num a, Eq b) => (a -> b) -> a -> Bool Source

Checks whether a function is reflectionSymmetric.

f(x) == f(-x)

`>>>`

+++ OK, passed 100 tests.`quickCheck $ pointSymmetric (^2)`

monotonicIncreasing :: (Ord a, Ord b) => (a -> b) -> a -> a -> Bool Source

Checks whether a function is monotonicIncreasing.

x >= y, f(x) >= f(y)

`>>>`

+++ OK, passed 100 tests.`quickCheck $ monotonicIncreasing ceiling`

monotonicIncreasing' :: (Ord a, Ord b) => (a -> b) -> a -> a -> Bool Source

Checks whether a function is strictly monotonicIncreasing'.

x > y, f(x) > f(y)

`>>>`

+++ OK, passed 100 tests.`quickCheck $ monotonicIncreasing' (+1)`

monotonicDecreasing :: (Ord a, Ord b) => (a -> b) -> a -> a -> Bool Source

Checks whether a function is monotonicDecreasing.

x >= y, f(x) <= f(y)

`>>>`

+++ OK, passed 100 tests.`quickCheck $ monotonicDecreasing (\x -> floor $ negate x)`

monotonicDecreasing' :: (Ord a, Ord b) => (a -> b) -> a -> a -> Bool Source

Checks whether a function is strictly monotonicDecreasing'.

x > y, f(x) < f(y)

`>>>`

+++ OK, passed 100 tests.`quickCheck $ monotonicDecreasing' (-1)`

involutory :: Eq a => (a -> a) -> a -> Bool Source

Checks whether a function is involutory.

f(f(x)) = x

`>>>`

+++ OK, passed 100 tests.`quickCheck $ involutory negate`

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

Checks whether a function is the inverse of another function.

f(g(x)) = x

`>>>`

+++ OK, passed 100 tests.`quickCheck $ (`div` 2) `inverts` (*2)`

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

Checks whether an binary operator is commutative.

a * b = b * a

`>>>`

+++ OK, passed 100 tests.`quickCheck $ commutative (+)`

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

Checks whether an binary operator is associative.

a + (b + c) = (a + b) + c

`>>>`

+++ OK, passed 100 tests.`quickCheck $ associative (+)`

distributesLeftOver :: Eq a => (a -> a -> a) -> (a -> a -> a) -> a -> a -> a -> Bool Source

Checks whether an operator is left-distributive over an other operator.

a * (b + c) = (a * b) + (a * c)

`>>>`

+++ OK, passed 100 tests.`quickCheck $ (*) `distributesLeftOver` (+)`

distributesRightOver :: Eq a => (a -> a -> a) -> (a -> a -> a) -> a -> a -> a -> Bool Source

Checks whether an operator is right-distributive over an other operator.

(b + c) / a = (b / a) + (c / a)

`>>>`

+++ OK, passed 100 tests.`quickCheck $ (/) `distributesRightOver` (+)`

distributesOver :: Eq a => (a -> a -> a) -> (a -> a -> a) -> a -> a -> a -> Bool Source

Checks whether an operator is distributive over an other operator.

a * (b + c) = (a * b) + (a * c) = (b + c) * a

`>>>`

+++ OK, passed 100 tests.`quickCheck $ (*) `distributesOver` (+)`

inflating :: ([a] -> [b]) -> [a] -> Bool Source

Checks whether a function increases the size of a list.

`>>>`

+++ OK, passed 100 tests.`quickCheck $ inflating (1:)`

inflating' :: ([a] -> [b]) -> [a] -> Bool Source

Checks whether a function increases strictly the size of a list.

`>>>`

+++ OK, passed 100 tests.`quickCheck $ inflating (1:)`

deflating :: ([a] -> [b]) -> [a] -> Bool Source

Checks whether a function decreases the size of a list.

`>>>`

+++ OK, passed 100 tests.`quickCheck $ deflating tail`

deflating' :: ([a] -> [b]) -> [a] -> Bool Source

Checks whether a function decreases strictly the size of a list.

`>>>`

+++ OK, passed 100 tests.`quickCheck $ deflating tail`

cyclesWithin :: Eq a => (a -> a) -> Int -> a -> Bool Source

Checks whether a function is cyclic by applying its result to itself within n applications.

`>>>`

+++ OK, passed 100 tests.`quickCheck $ (`div` 10) `cyclesWithin` 100`

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

Checks whether a function is invariant over an other function.

`>>>`

+++ OK, passed 100 tests.`quickCheck $ length `invariatesOver` reverse`

fixedBy :: Eq c => (a -> b -> c) -> a -> b -> b -> Bool Source

Checks whether a binary function is fixed by an argument.

f x y == const a y

`>>>`

+++ OK, passed 100 tests.`quickCheck $ (*) `fixedBy` 0`

(<~~) :: Eq b => (a -> b) -> (a -> a) -> a -> Bool infix 2 Source

Checks whether a function is invariant over an other function.

`>>>`

+++ OK, passed 100 tests.`quickCheck $ length <~~ reverse`

(@~>) :: Eq a => (b -> a) -> (a -> b) -> a -> Bool infix 2 Source

Checks whether a function is the inverse of another function.

f(g(x)) = x

`>>>`

+++ OK, passed 100 tests.`quickCheck $ (`div` 2) @~> (*2)`

(<?>) :: Eq a => (a -> a) -> (a -> a) -> a -> Bool infix 2 Source

Checks whether a function is an endomorphism in relation to a unary operator.

f(g(x)) = g(f(x))

`>>>`

+++ OK, passed 100 tests.`quickCheck $ (*7) <?> abs`