MaxMonoid

data class MaxMonoid<A : Comparable<A>>(val value: Maybe<A>) : Monoid<Maybe<A>, MaxMonoid<A>> , Band<Maybe<A>, MaxMonoid<A>> (source)

Monoid that keeps the maximum value, with Maybe.None as identity (no bounded type needed). Also a Band.

On ties the left operand is kept.

val clazz = MaxMonoid::class.java as Class<MaxMonoid<Int>>
Monoid.op(clazz, Maybe.Just(1).toMaxMonoid(), Maybe.Just(3).toMaxMonoid()) // MaxMonoid(Just(3))

Constructors

Link copied to clipboard
constructor(value: Maybe<A>)
constructor()

Creates the identity element; required by reflective lookups such as Monoid.mzero(type).

Properties

Link copied to clipboard
val value: Maybe<A>

Functions

Link copied to clipboard
open override fun mzero(): MaxMonoid<A>

The identity element of op.

Link copied to clipboard
open override fun op(a: MaxMonoid<A>, b: MaxMonoid<A>): MaxMonoid<A>

Combines a and b; the receiver is only used to select the instance.