|
Copyright 2008 - 2009 Tony Morris, Runar Bjarnason, Tom Adams, Brad Clow, Ricky Clarkson, Nick Partridge, Jason Zaugg This software is released under an open source BSD licence. |
||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectfj.pre.Monoid<A>
public final class Monoid<A>
A monoid abstraction to be defined across types of the given type argument. Implementations must follow the monoidal laws:
Field Summary | |
---|---|
static Monoid<BigDecimal> |
bigdecimalAdditionMonoid
A monoid that adds big decimals. |
static Monoid<BigDecimal> |
bigdecimalMultiplicationMonoid
A monoid that multiplies big decimals. |
static Monoid<BigInteger> |
bigintAdditionMonoid
A monoid that adds big integers. |
static Monoid<BigInteger> |
bigintMultiplicationMonoid
A monoid that multiplies big integers. |
static Monoid<Boolean> |
conjunctionMonoid
A monoid that ANDs booleans. |
static Monoid<Boolean> |
disjunctionMonoid
A monoid that ORs booleans. |
static Monoid<Boolean> |
exclusiveDisjunctionMonoid
A monoid that XORs booleans. |
static Monoid<Integer> |
intAdditionMonoid
A monoid that adds integers. |
static Monoid<Integer> |
intMultiplicationMonoid
A monoid that multiplies integers. |
static Monoid<Long> |
longAdditionMonoid
A monoid that adds longs. |
static Monoid<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<StringBuffer> |
stringBufferMonoid
A monoid that appends string buffers. |
static Monoid<StringBuilder> |
stringBuilderMonoid
A monoid that appends string builders. |
static Monoid<String> |
stringMonoid
A monoid that appends strings. |
Method Summary | ||
---|---|---|
static
|
arrayMonoid()
A monoid for arrays. |
|
static
|
functionMonoid(Monoid<B> mb)
A monoid for functions. |
|
A |
join(Iterable<A> as,
A a)
Intersperses the given value between each two elements of the iterable, and sums the result. |
|
static
|
listMonoid()
A monoid for lists. |
|
static
|
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
|
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
|
monoid(Semigroup<A> s,
A zero)
Constructs a monoid from the given semigroup and zero value, which must follow the monoidal laws. |
|
static
|
optionMonoid()
A monoid for options. |
|
Semigroup<A> |
semigroup()
Returns a semigroup projection of this monoid. |
|
static
|
setMonoid(Ord<A> o)
A monoid for sets. |
|
static
|
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. |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
---|
public static final Monoid<Integer> intAdditionMonoid
public static final Monoid<Integer> intMultiplicationMonoid
public static final Monoid<BigInteger> bigintAdditionMonoid
public static final Monoid<BigInteger> bigintMultiplicationMonoid
public static final Monoid<BigDecimal> bigdecimalAdditionMonoid
public static final Monoid<BigDecimal> bigdecimalMultiplicationMonoid
public static final Monoid<Natural> naturalAdditionMonoid
public static final Monoid<Natural> naturalMultiplicationMonoid
public static final Monoid<Long> longAdditionMonoid
public static final Monoid<Long> longMultiplicationMonoid
public static final Monoid<Boolean> disjunctionMonoid
public static final Monoid<Boolean> exclusiveDisjunctionMonoid
public static final Monoid<Boolean> conjunctionMonoid
public static final Monoid<String> stringMonoid
public static final Monoid<StringBuffer> stringBufferMonoid
public static final Monoid<StringBuilder> stringBuilderMonoid
Method Detail |
---|
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(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<Stream<A>> streamMonoid()
public static <A> Monoid<Array<A>> arrayMonoid()
public static <A> Monoid<Set<A>> setMonoid(Ord<A> o)
o
- An order for set elements.
|
Copyright 2008 - 2009 Tony Morris, Runar Bjarnason, Tom Adams, Brad Clow, Ricky Clarkson, Nick Partridge, Jason Zaugg This software is released under an open source BSD licence. |
||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |