Package io.atlassian.fugue.law
Class SemigroupLaws<A>
- java.lang.Object
-
- io.atlassian.fugue.law.SemigroupLaws<A>
-
public final class SemigroupLaws<A> extends java.lang.ObjectLaws for a semigroup
-
-
Constructor Summary
Constructors Constructor Description SemigroupLaws(Semigroup<A> semigroup)Build a law instance to check semigroup properties
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description IsEq<A>multiply1pEqualRepeatedAppend(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 inputIsEq<A>semigroupAssociative(A x, A y, A z)A semigroup must not care about the order elements are combined.IsEq<A>sumNonEmptyEqualFold(A head, java.lang.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
-
-
-
Method Detail
-
semigroupAssociative
public IsEq<A> semigroupAssociative(A x, A y, A z)
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
public IsEq<A> sumNonEmptyEqualFold(A head, java.lang.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- Parameters:
head- an Atail- aIterableof A's- Returns:
- a
IsEqwhere sumeNonEmpty(head, tail) is equal to fold(append, head, tail)
-
multiply1pEqualRepeatedAppend
public IsEq<A> multiply1pEqualRepeatedAppend(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 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))
-
-