flix

0.79.0

Monoid

Trait for types that form a monoid, and its functions.

trait Monoid[a: Type] with SemiGroup[a]Source

Trait for types that form a monoid.

A monoid supports an associative binary operation combine and a neutral element empty.

Instances

Primitives
Unit, Float32, Float64, BigDecimal, Int8, Int16, Int32, Int64, BigInt, String, Vector[a] and tuples of 2 to 10 elements
Non-primitives
All, Any, Chain[a], DelayList[a], Identity[a], List[a], Map[k, v], MultiMap[k, v], Option[a], RichString, Set[a], Validation[e, t]

Signatures

def empty(): a with Monoid[a]§ Source

Returns a neutral element.

Trait Definitions

def combine(x: a, y: a): a with Monoid[a]§ Source

Returns the result of combining x and y using SemiGroup's combine.

Module Definitions

def fold(t: t[a]): a \ Aef[t] with Foldable[t], Monoid[a]§ Source

Returns the result of applying combine to all the elements in t, using empty as the initial value.