uncomplicate.fluokitten.test

Macros that generate Midje tests for various laws that
categorical concepts have to satisfy. You should use these tests
to check if your implementations of clojure protocols are valid
beyond what the compiler can assert.

applicative-law1

macro

(applicative-law1 f x & xs)
Generates a test that checks if the applicative functor x
satisfies the first applicative law:

(fapply (pure x f) x) => (fmap f x)

applicative-law2-identity

macro

(applicative-law2-identity x)
Generates a test that checks if the applicative functor x
satisfies the second applicative law:

(fapply (pure x identity) x) => x

applicative-law3-composition

macro

(applicative-law3-composition u v x & xs)
Generates a test that checks if the applicative functor x
satisfies the third applicative law:

(<*> (pure x (curry comp)) u v x)
=> (fapply u (fapply v x))

applicative-law4-homomorphism

macro

(applicative-law4-homomorphism ap f x & xs)
Generates a test that checks if the applicative functor x
satisfies the fourth applicative law:

(fapply (pure a f) (pure a x)) => (f x)

applicative-law5-interchange

macro

(applicative-law5-interchange ap f x & xs)
Generates a test that checks if the applicative functor x
satisfies the fifth applicative law:

(fapply u (pure a y)) => (fapply (pure a fn(% y)) u)

check-eq

(check-eq expected)(check-eq expected actual)
Midje checker that check for the equality of contents in contexts such
as references and reducibles.

data-structures-should-preserve-metadata

macro

(data-structures-should-preserve-metadata f1 f2 builder x y)
Generates the tests that check whether the implementations
of functions defined in Fluokitten protocols that extend
Clojure core data structures preserve metadata.

fapply-keeps-type

macro

(fapply-keeps-type f x & xs)
Generates a test that checks if the applicative functor x's
implementation of fapply keeps the type of x when the function
inside f is applied to its content.

fmap-keeps-type

macro

(fmap-keeps-type f x & xs)
Generates a test that checks if the functor x's implementation of
fmap keeps the type of x when f is applied to its content.

functor-law2

macro

(functor-law2 f x)(functor-law2 f g x & xs)
Generates a test that checks if the functor x satisfies
the Second Functor Law:

(fmap (comp f g)) => (fmap f (fmap g))

or, when applied to a concrete functor:

(fmap (comp f g) x) => (fmap f (fmap g x))

magma-op-keeps-type

macro

(magma-op-keeps-type x y & ys)
Generates a test that checks if the operation op is closed on magma x.

monad-law1-left-identity

macro

(monad-law1-left-identity m g x & xs)
Generates a test that checks if the monad x
satisfies the first monad law:

(bind (pure m x) f) => (g x)

monad-law2-right-identity

macro

(monad-law2-right-identity m)
Generates a test that checks if the monad x
satisfies the secondmonad law:

(bind m (pure m)) => m

monad-law3-associativity

macro

(monad-law3-associativity f g m & ms)
Generates a test that checks if the monad x
satisfies the third monad law:

(bind m (fn [x] (bind (f x) g)

monoid-identity-law

macro

(monoid-identity-law x & xs)
Generates a test that checks whether the Monoid implementation x
satisfies the monoid identity law, i.e. if identity element for op
exists:
   (op x (id x)) => x
   (op (id x) x) => x

semigroup-op-associativity

macro

(semigroup-op-associativity x y & ys)
Generates a test that checks if x and op form a semigroup,
i.e whether op is associative:

(op (op a b)) => (op a (op b c))