CommutativeZeroMonoid

trait CommutativeZeroMonoid[@specialized(Int, Long, Float, Double) A] extends ZeroMonoid[A] with CommutativeMonoid[A] with CommutativeZeroSemigroup[A]

CommutativeZeroMonoid represents a commutative zero monoid.

CommutativeZeroMonoid represents a commutative zero monoid.

A zero monoid is commutative if for all x and y, x |+| y === y |+| x.

Companion
object
trait CommutativeMonoid[A]
trait CommutativeSemigroup[A]
trait ZeroMonoid[A]
trait ZeroSemigroup[A]
trait Monoid[A]
trait Semigroup[A]
trait Serializable
class Any

Value members

Concrete methods

Definition Classes
CommutativeZeroSemigroup -> CommutativeMonoid -> CommutativeSemigroup -> ZeroMonoid -> ZeroSemigroup -> Monoid -> Semigroup

Inherited methods

def absorbing: A

Return the absorbing element for this zero semigroup.

Return the absorbing element for this zero semigroup.

Inherited from
ZeroSemigroup
def combine(x: A, y: A): A

Associative operation which combines two values.

Associative operation which combines two values.

Example:

scala> import cats.kernel.instances.string._
scala> import cats.kernel.instances.int._
scala> import cats.kernel.instances.option._

scala> Semigroup[String].combine("Hello ", "World!")
res0: String = Hello World!

scala> Semigroup[Option[Int]].combine(None, Some(1))
res1: Option[Int] = Some(1)
Inherited from
Semigroup
def combineAll(as: IterableOnce[A]): A

Given a sequence of as, sum them using the monoid and return the total.

Given a sequence of as, sum them using the monoid and return the total.

Example:

scala> import cats.kernel.instances.string._

scala> Monoid[String].combineAll(List("One ", "Two ", "Three"))
res0: String = One Two Three

scala> Monoid[String].combineAll(List.empty)
res1: String = ""
Inherited from
Monoid
override def combineAllOption(as: IterableOnce[A]): Option[A]
Definition Classes
Monoid -> Semigroup
Inherited from
Monoid
override def combineN(a: A, n: Int): A

Return a appended to itself n times.

Return a appended to itself n times.

Example:

scala> import cats.kernel.instances.string._

scala> Monoid[String].combineN("ha", 3)
res0: String = hahaha

scala> Monoid[String].combineN("ha", 0)
res1: String = ""
Definition Classes
Monoid -> Semigroup
Inherited from
Monoid
def empty: A

Return the identity element for this monoid.

Return the identity element for this monoid.

Example:

scala> import cats.kernel.instances.int._
scala> import cats.kernel.instances.string._

scala> Monoid[String].empty
res0: String = ""

scala> Monoid[Int].empty
res1: Int = 0
Inherited from
Monoid
override def intercalate(middle: A): CommutativeZeroSemigroup[A]
Definition Classes
CommutativeZeroSemigroup -> CommutativeSemigroup -> Semigroup
Inherited from
CommutativeZeroSemigroup
def isAbsorbing(a: A)(ev: Eq[A]): Boolean

Tests if a is the absorbing element.

Tests if a is the absorbing element.

Inherited from
ZeroSemigroup
def isEmpty(a: A)(ev: Eq[A]): Boolean

Tests if a is the identity.

Tests if a is the identity.

Example:

scala> import cats.kernel.instances.string._

scala> Monoid[String].isEmpty("")
res0: Boolean = true

scala> Monoid[String].isEmpty("something")
res1: Boolean = false
Inherited from
Monoid