Witchcraft v0.3.0 Witchcraft.Monoid.Property

Check samples of your monoid to confirm that your data adheres to the monoidal properties. All members of your datatype should adhere to these rules. They are placed here as a quick way to spotcheck some of your values.

Summary

Functions

Spotcheck all monoid properties

Check that Monoid.append is associative (ie: brackets don’t matter)

Check that some member of your monoid combines with the identity to return itself

Functions

spotcheck(a, b, c)

Specs

spotcheck(any, any, any) :: boolean

Spotcheck all monoid properties


iex> spotcheck(1,2,3)
true

# Float under division
iex> spotcheck(%Witchcraft.Sad{sad: -9.1}, %Witchcraft.Sad{sad: 42.0}, %Witchcraft.Sad{sad: 88.8})
false
spotcheck_associativity(member1, member2, member3)

Specs

spotcheck_associativity(any, any, any) :: boolean

Check that Monoid.append is associative (ie: brackets don’t matter)


iex> spotcheck_associativity("a", "b", "c")
true

# Float under division
iex> spotcheck_associativity(%Witchcraft.Sad{sad: -9.1}, %Witchcraft.Sad{sad: 42.0}, %Witchcraft.Sad{sad: 88.8})
false
spotcheck_identity(member)

Specs

spotcheck_identity(any) :: boolean

Check that some member of your monoid combines with the identity to return itself


iex> spotcheck_identity("well formed")
true

# Float under division
iex> spotcheck_identity(%Witchcraft.Sad{})
false