public final class Monoid<A>
extends java.lang.Object
Modifier and Type | Field and Description |
---|---|
static Monoid<java.math.BigDecimal> |
bigdecimalAdditionMonoid
A monoid that adds big decimals.
|
static Monoid<java.math.BigDecimal> |
bigdecimalMultiplicationMonoid
A monoid that multiplies big decimals.
|
static Monoid<java.math.BigInteger> |
bigintAdditionMonoid
A monoid that adds big integers.
|
static Monoid<java.math.BigInteger> |
bigintMultiplicationMonoid
A monoid that multiplies big integers.
|
static Monoid<java.lang.Boolean> |
conjunctionMonoid
A monoid that ANDs booleans.
|
static Monoid<java.lang.Boolean> |
disjunctionMonoid
A monoid that ORs booleans.
|
static Monoid<java.lang.Double> |
doubleAdditionMonoid
A monoid that adds doubles.
|
static Monoid<java.lang.Double> |
doubleMultiplicationMonoid
A monoid that multiplies doubles.
|
static Monoid<java.lang.Boolean> |
exclusiveDisjunctionMonoid
A monoid that XORs booleans.
|
static Monoid<java.lang.Integer> |
intAdditionMonoid
A monoid that adds integers.
|
static Monoid<java.lang.Integer> |
intMultiplicationMonoid
A monoid that multiplies integers.
|
static Monoid<java.lang.Long> |
longAdditionMonoid
A monoid that adds longs.
|
static Monoid<java.lang.Long> |
longMultiplicationMonoid
A monoid that multiplies longs.
|
static Monoid<Natural> |
naturalAdditionMonoid
A monoid that adds natural numbers.
|
static Monoid<Natural> |
naturalMultiplicationMonoid
A monoid that multiplies natural numbers.
|
static Monoid<java.lang.StringBuffer> |
stringBufferMonoid
A monoid that appends string buffers.
|
static Monoid<java.lang.StringBuilder> |
stringBuilderMonoid
A monoid that appends string builders.
|
static Monoid<java.lang.String> |
stringMonoid
A monoid that appends strings.
|
Modifier and Type | Method and Description |
---|---|
static <A> Monoid<Array<A>> |
arrayMonoid()
A monoid for arrays.
|
static <A> Monoid<Option<A>> |
firstOptionMonoid()
A monoid for options that take the first available value.
|
static <A,B> Monoid<F<A,B>> |
functionMonoid(Monoid<B> mb)
A monoid for functions.
|
A |
join(java.lang.Iterable<A> as,
A a)
Intersperses the given value between each two elements of the iterable, and sums the result.
|
static <A> Monoid<Option<A>> |
lastOptionMonoid()
A monoid for options that take the last available value.
|
static <A> Monoid<List<A>> |
listMonoid()
A monoid for lists.
|
static <A> Monoid<A> |
monoid(F<A,F<A,A>> sum,
A zero)
Constructs a monoid from the given sum function and zero value, which must follow the monoidal
laws.
|
static <A> Monoid<A> |
monoid(F2<A,A,A> sum,
A zero)
Constructs a monoid from the given sum function and zero value, which must follow the monoidal
laws.
|
static <A> Monoid<A> |
monoid(Semigroup<A> s,
A zero)
Constructs a monoid from the given semigroup and zero value, which must follow the monoidal laws.
|
static <A> Monoid<Option<A>> |
optionMonoid()
A monoid for options.
|
Semigroup<A> |
semigroup()
Returns a semigroup projection of this monoid.
|
static <A> Monoid<Set<A>> |
setMonoid(Ord<A> o)
A monoid for sets.
|
static <A> Monoid<Stream<A>> |
streamMonoid()
A monoid for streams.
|
F<A,F<A,A>> |
sum()
Returns a function that sums according to this monoid.
|
F<A,A> |
sum(A a1)
Returns a function that sums the given value according to this monoid.
|
A |
sum(A a1,
A a2)
Sums the two given arguments.
|
F<List<A>,A> |
sumLeft()
Returns a function that sums the given values with left-fold.
|
A |
sumLeft(List<A> as)
Sums the given values with left-fold.
|
A |
sumLeft(Stream<A> as)
Sums the given values with left-fold.
|
F<Stream<A>,A> |
sumLeftS()
Returns a function that sums the given values with left-fold.
|
F<List<A>,A> |
sumRight()
Returns a function that sums the given values with right-fold.
|
A |
sumRight(List<A> as)
Sums the given values with right-fold.
|
A |
sumRight(Stream<A> as)
Sums the given values with right-fold.
|
A |
zero()
The zero value for this monoid.
|
public static final Monoid<java.lang.Integer> intAdditionMonoid
public static final Monoid<java.lang.Integer> intMultiplicationMonoid
public static final Monoid<java.lang.Double> doubleAdditionMonoid
public static final Monoid<java.lang.Double> doubleMultiplicationMonoid
public static final Monoid<java.math.BigInteger> bigintAdditionMonoid
public static final Monoid<java.math.BigInteger> bigintMultiplicationMonoid
public static final Monoid<java.math.BigDecimal> bigdecimalAdditionMonoid
public static final Monoid<java.math.BigDecimal> bigdecimalMultiplicationMonoid
public static final Monoid<Natural> naturalAdditionMonoid
public static final Monoid<Natural> naturalMultiplicationMonoid
public static final Monoid<java.lang.Long> longAdditionMonoid
public static final Monoid<java.lang.Long> longMultiplicationMonoid
public static final Monoid<java.lang.Boolean> disjunctionMonoid
public static final Monoid<java.lang.Boolean> exclusiveDisjunctionMonoid
public static final Monoid<java.lang.Boolean> conjunctionMonoid
public static final Monoid<java.lang.String> stringMonoid
public static final Monoid<java.lang.StringBuffer> stringBufferMonoid
public static final Monoid<java.lang.StringBuilder> stringBuilderMonoid
public Semigroup<A> semigroup()
public A sum(A a1, A a2)
a1
- A value to sum with another.a2
- A value to sum with another.public F<A,A> sum(A a1)
a1
- The value to sum.public F<A,F<A,A>> sum()
public A zero()
public A sumRight(List<A> as)
as
- The values to sum.public A sumRight(Stream<A> as)
as
- The values to sum.public A sumLeft(List<A> as)
as
- The values to sum.public A sumLeft(Stream<A> as)
as
- The values to sum.public F<List<A>,A> sumLeft()
public F<List<A>,A> sumRight()
public F<Stream<A>,A> sumLeftS()
public A join(java.lang.Iterable<A> as, A a)
as
- An iterable of values to sum.a
- The value to intersperse between values of the given iterable.public static <A> Monoid<A> monoid(F<A,F<A,A>> sum, A zero)
sum
- The sum function for the monoid.zero
- The zero for the monoid.public static <A> Monoid<A> monoid(F2<A,A,A> sum, A zero)
sum
- The sum function for the monoid.zero
- The zero for the monoid.public static <A> Monoid<A> monoid(Semigroup<A> s, A zero)
s
- The semigroup for the monoid.zero
- The zero for the monoid.public static <A,B> Monoid<F<A,B>> functionMonoid(Monoid<B> mb)
mb
- The monoid for the function codomain.public static <A> Monoid<List<A>> listMonoid()
public static <A> Monoid<Option<A>> optionMonoid()
public static <A> Monoid<Option<A>> firstOptionMonoid()
public static <A> Monoid<Option<A>> lastOptionMonoid()
public static <A> Monoid<Stream<A>> streamMonoid()
public static <A> Monoid<Array<A>> arrayMonoid()