Witchcraft v0.3.0 Witchcraft.Applicative.Property

Check samples of your applicative functor to confirm that your data adheres to the applicative properties. All members of your datatype should adhere to these rules, plus implement Witchcraft.Functor.

They are placed here as a quick way to spotcheck some of your values.

Summary

Functions

Being an applicative functor, apply behaves as lift on wrapped values

applying a wrapped function to a wrapped value is the same as wrapping the result of the function on that value

applying a lifted id to some lifted value v does not change v

The order does not matter when applying to a wrapped value and a wrapped function

Functions

spotcheck_composition(value, fun1, fun2)

Specs

spotcheck_composition(any, any, any) :: boolean

apply composes normally.

iex> spotcheck_composition([1, 2], [&(&1 * 2)], [&(&1 * 10)]) true

spotcheck_functor(wrapped_value, fun)

Specs

spotcheck_functor(any, (... -> any)) :: boolean

Being an applicative functor, apply behaves as lift on wrapped values


iex> spotcheck_functor([1,2,3], &(&1 * 10))
true

iex> spotcheck_functor(%Witchcraft.Id{id: 7}, &(&1 * 99))
true
spotcheck_homomorphism(specemin, val, fun)

Specs

spotcheck_homomorphism(any, any, (... -> any)) :: boolean

applying a wrapped function to a wrapped value is the same as wrapping the result of the function on that value.


iex> spotcheck_homomorphism([], 1, &(&1 * 10))
true
spotcheck_identity(value)

Specs

spotcheck_identity(any) :: boolean

applying a lifted id to some lifted value v does not change v


iex> spotcheck_identity []
true

iex> spotcheck_identity %Witchcraft.Id{}
true
spotcheck_interchange(bare_val, wrapped_fun)

Specs

spotcheck_interchange(any, any) :: boolean

The order does not matter when applying to a wrapped value and a wrapped function.


iex> spotcheck_interchange(1, [&(&1 * 10)])
true