:+:

sealed
class :+:[M, N](rep: Vector[M \/ N])

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
class Object
trait Matchable
class Any

Value members

Concrete methods

def appendLeft(m: M)(implicit M: Monoid[M], N: Monoid[N]): M :+: N

Append a value from the left monoid

Append a value from the left monoid

def appendRight(n: N)(implicit M: Monoid[M], N: Monoid[N]): M :+: N

Append a value from the right monoid

Append a value from the right monoid

def both[A >: M : Monoid, B >: N : Monoid]: (A, B)

Project out both monoids individually

Project out both monoids individually

def fold[Z : Monoid](f: M => Z, g: N => Z): Z

A homomorphism to a monoid Z (if f and g are homomorphisms).

A homomorphism to a monoid Z (if f and g are homomorphisms).

def left[A >: M : Monoid]: A

Project out the value in the left monoid

Project out the value in the left monoid

def prependLeft(m: M)(implicit M: Monoid[M], N: Monoid[N]): M :+: N

Prepend a value from the left monoid

Prepend a value from the left monoid

def prependRight(n: N)(implicit M: Monoid[M], N: Monoid[N]): M :+: N

Prepend a value from the right monoid

Prepend a value from the right monoid

def right[A >: N : Monoid]: A

Project out the value in the right monoid

Project out the value in the right monoid

def untangle[A >: M : Monoid, B >: N : Monoid](f: (B, A) => A, g: (A, B) => B): (A, B)

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.

def untangleLeft[A >: M : Monoid, B >: N : Monoid](f: (A, B) => B): (A, B)

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.

def untangleRight[A >: M : Monoid, B >: N : Monoid](f: (B, A) => A): (A, B)

Like untangle, except N values are simply combined without regard to the N values to the left of it.

Like untangle, except N values are simply combined without regard to the N values to the left of it.

def |+|(m: M :+: N)(implicit M: Monoid[M], N: Monoid[N]): M :+: N

The associative operation of the monoid coproduct

The associative operation of the monoid coproduct