Idempotent

zio.prelude.Idempotent
See theIdempotent companion object
trait Idempotent[A] extends Associative[A]

The Idempotent type class describes a binary operator for a type A that is both associative and produces the same value when combining two identical values. This means that a <> a is equal to a for all values a. Example of idempotent operations is union of sets, but not addition of integers.

Idempotent operators are useful because combining the values with an idempotent operation results in the same value regardless of the number of values are combined, allowing us to optimize out unnecessary combinations of the same values.

Attributes

Companion
object
Graph
Supertypes
trait Associative[A]
class Object
trait Matchable
class Any
Known subtypes
trait EqualIdempotent[A]
Self type

Members list

Value members

Concrete methods

final def combineIdempotent(l: => A, r: => A)(implicit A: Equal[A]): A
Implicitly added by MapIdempotent

If the values are equal, it doesn't attempt to combine them and promptly returns the first one. If not equal, the values are combined normally.

If the values are equal, it doesn't attempt to combine them and promptly returns the first one. If not equal, the values are combined normally.

Attributes

final def combineIdempotent(l: => A, r: => A)(implicit A: Equal[A]): A
Implicitly added by OptionIdempotent

If the values are equal, it doesn't attempt to combine them and promptly returns the first one. If not equal, the values are combined normally.

If the values are equal, it doesn't attempt to combine them and promptly returns the first one. If not equal, the values are combined normally.

Attributes

final def combineIdempotent(l: => A, r: => A)(implicit A: Equal[A]): A

If the values are equal, it doesn't attempt to combine them and promptly returns the first one. If not equal, the values are combined normally.

If the values are equal, it doesn't attempt to combine them and promptly returns the first one. If not equal, the values are combined normally.

Attributes

def idempotent(implicit A: Equal[A]): Idempotent[A]
Implicitly added by MapIdempotent

Creates a new instance which internally uses combineIdempotent for combining values.

Creates a new instance which internally uses combineIdempotent for combining values.

Attributes

def idempotent(implicit A: Equal[A]): Idempotent[A]
Implicitly added by OptionIdempotent

Creates a new instance which internally uses combineIdempotent for combining values.

Creates a new instance which internally uses combineIdempotent for combining values.

Attributes

def idempotent(implicit A: Equal[A]): Idempotent[A]

Creates a new instance which internally uses combineIdempotent for combining values.

Creates a new instance which internally uses combineIdempotent for combining values.

Attributes

Inherited methods

def combine(l: => A, r: => A): A
Implicitly added by MapIdempotent

Attributes

Inherited from:
Associative
def combine(l: => A, r: => A): A
Implicitly added by OptionIdempotent

Attributes

Inherited from:
Associative
def combine(l: => A, r: => A): A

Attributes

Inherited from:
Associative
final def intersperse(middle: A): Associative[A]
Implicitly added by MapIdempotent

Attributes

Inherited from:
Associative
final def intersperse(middle: A): Associative[A]
Implicitly added by OptionIdempotent

Attributes

Inherited from:
Associative
final def intersperse(middle: A): Associative[A]

Attributes

Inherited from:
Associative
def multiplyOption(n: Int)(a: A): Option[A]
Implicitly added by MapIdempotent

Attributes

Inherited from:
Associative
def multiplyOption(n: Int)(a: A): Option[A]
Implicitly added by OptionIdempotent

Attributes

Inherited from:
Associative
def multiplyOption(n: Int)(a: A): Option[A]

Attributes

Inherited from:
Associative
final def repeat(a: A)(n: Int): A
Implicitly added by MapIdempotent

Attributes

Inherited from:
Associative
final def repeat(a: A)(n: Int): A
Implicitly added by OptionIdempotent

Attributes

Inherited from:
Associative
final def repeat(a: A)(n: Int): A

Attributes

Inherited from:
Associative