public final class MonoidLaws<A> extends Object
| Constructor and Description |
|---|
MonoidLaws(Monoid<A> monoid)
Build a law instance to check monoid properties
|
| Modifier and Type | Method and Description |
|---|---|
IsEq<A> |
monoidLeftIdentity(A x)
If the zero of your monoid is combine with an element of the type your
monoid works with the result should be that element.
|
IsEq<A> |
monoidRightIdentity(A x)
If an element of the type your monoid works with is combined with the zero
of your monoid result should be that element.
|
IsEq<A> |
multiplyEqualRepeatedAppend(int n,
A a)
The multiply function of your monoid must be equal to the sum function
called with an iterable containing
n copies of the input type. |
IsEq<A> |
semigroupAssociative(A x,
A y,
A z)
A monoid must not care about the order elements are combined.
|
IsEq<A> |
sumEqualFold(Iterable<A> as)
The sum function of your monoid must be equal to
Functions.fold(BiFunction, Object, Iterable) using append as the
folding function and zero() as the initial value |
public IsEq<A> semigroupAssociative(A x, A y, A z)
x - an A objecty - an A objectz - an A objectIsEq instance where
append(append(x,y),z) is equal to append(x, append(y,z))public IsEq<A> monoidLeftIdentity(A x)
x - an element of your monoid typeIsEq where x is equal to
append(zero(), x)public IsEq<A> monoidRightIdentity(A x)
x - an element of your monoid typeIsEq where x is equal to append(x,
zero())public IsEq<A> sumEqualFold(Iterable<A> as)
Functions.fold(BiFunction, Object, Iterable) using append as the
folding function and zero() as the initial valuepublic IsEq<A> multiplyEqualRepeatedAppend(int n, A a)
n copies of the input type.n - a inta - an AIsEq where multiply(n,a) is equal
to sum(take(n, cycle(a))Copyright © 2017 Atlassian. All rights reserved.