The coproduct (or free product) of monoids M
and N
.
Conceptually this is an alternating list of M
and N
values, with
the identity as the empty list, and composition as list concatenation that
combines adjacent elements when possible.
- Companion
- object
Value members
Concrete methods
A homomorphism to a monoid Z
(if f
and g
are homomorphisms).
A homomorphism to a monoid Z
(if f
and g
are homomorphisms).
Take a value from the coproduct monoid where each monoid acts on the
other, and untangle into a pair of values. Before being folded into the answer
an N
value is combined with the sum of the M
values to its left via g
and
an M
value is combined with the sum of the N
values to its left via f
.
This allows you to add up N
values while having the opportunity to "track"
an evolving M
value, and vice versa.
Take a value from the coproduct monoid where each monoid acts on the
other, and untangle into a pair of values. Before being folded into the answer
an N
value is combined with the sum of the M
values to its left via g
and
an M
value is combined with the sum of the N
values to its left via f
.
This allows you to add up N
values while having the opportunity to "track"
an evolving M
value, and vice versa.
Like untangle
, except M
values are simply combined without regard to the
N
values to the left of it.
Like untangle
, except M
values are simply combined without regard to the
N
values to the left of it.