Monoid<T> mixin
A monoid is a semigroup with an identity (empty
).
A monoid is a specialization of a semigroup, so its operation must be associative.
Additionally, combine(x, empty) == combine(empty, x) == x
.
For example, if we have Monoid<String>
,
with combine
as string concatenation, then empty = ""
:
final instance = Monoid.instance<String>('', (a1, a2) => '$a1$a2');
expect(instance.combine('abc', instance.empty), instance.combine(instance.empty, 'abc'));
expect(instance.combine('abc', instance.empty), 'abc');
 Superclass Constraints
 Semigroup<
T>
 Semigroup<
Properties
 empty → T

Return the identity element for this monoid.
readonly
 hashCode → int

The hash code for this object.
readonlyinherited
 runtimeType → Type

A representation of the runtime type of the object.
readonlyinherited
Methods

combine(
T x, T y) → T 
Associative operation which combines two values.
inherited

combineN(
T a, int n) → T 
Return
a
appended to itselfn
times.override 
intercalate(
T middle) → Semigroup< T> 
Return a
Semigroup
which insertsmiddle
between each pair of elements.inherited 
isEmpty(
T a, Eq< T> eq) → bool 
Tests if
a
is the identity (empty
). 
noSuchMethod(
Invocation invocation) → dynamic 
Invoked when a nonexistent method or property is accessed.
inherited

reverse(
) → Monoid< T> 
Return a
Monoid
that reverses the order.override 
toString(
) → String 
A string representation of this object.
inherited
Operators

operator ==(
Object other) → bool 
The equality operator.
inherited