Class SemigroupLaws<A>
java.lang.Object
io.atlassian.fugue.law.SemigroupLaws<A>
Laws for a semigroup
-
Field Summary
Fields -
Constructor Summary
ConstructorsConstructorDescriptionSemigroupLaws(Semigroup<A> semigroup) Build a law instance to check semigroup properties -
Method Summary
Modifier and TypeMethodDescriptionmultiply1pEqualRepeatedAppend(int n, A a) TheSemigroup.multiply1p(int, Object)function of your semigroup must be equal toSemigroup.sumNonEmpty(Object, Iterable)applied to the input and an iterable containingn - 1copies of that inputsemigroupAssociative(A x, A y, A z) A semigroup must not care about the order elements are combined.sumNonEmptyEqualFold(A head, Iterable<A> tail) TheSemigroup.sumNonEmpty(Object, Iterable)function of your semigroup must be equal to aFunctions.fold(BiFunction, Object, Iterable)where append is used as the combining function, head is used as the initial value and tail is the iterable to check
-
Field Details
-
semigroup
-
-
Constructor Details
-
SemigroupLaws
-
-
Method Details
-
semigroupAssociative
A semigroup must not care about the order elements are combined. If you combine x with y and then with z the result should be the same as combining y with z and then with x.- Parameters:
x- an A objecty- an A objectz- an A object- Returns:
- a
IsEqinstance where append(append(x,y),z) is equal to append(x, append(y,z))
-
sumNonEmptyEqualFold
TheSemigroup.sumNonEmpty(Object, Iterable)function of your semigroup must be equal to aFunctions.fold(BiFunction, Object, Iterable)where append is used as the combining function, head is used as the initial value and tail is the iterable to check -
multiply1pEqualRepeatedAppend
TheSemigroup.multiply1p(int, Object)function of your semigroup must be equal toSemigroup.sumNonEmpty(Object, Iterable)applied to the input and an iterable containingn - 1copies of that input- Parameters:
n- a int representing the number of copies of the input to combinea- an A- Returns:
- a
IsEqwhere multiply(n,a) is equal to sumNonEmpty(a, take(n-1, cycle(a))
-