Monoid

com.phasmid.majabigwaduce.core.Monoid
See theMonoid companion trait
object Monoid

Provides Monoid instances for standard types and utility methods for working with monoids.

Attributes

Companion
trait
Graph
Supertypes
class Object
trait Matchable
class Any
Self type
Monoid.type

Members list

Type members

Classlikes

object MonoidDouble extends DoubleZero, Monoid[Double]

An implicit object representing a monoid instance for the Double type. This instance provides the monoid operation (addition) and identity element (zero) for Double.

An implicit object representing a monoid instance for the Double type. This instance provides the monoid operation (addition) and identity element (zero) for Double.

Attributes

Supertypes
trait Monoid[Double]
trait DoubleZero
trait Zero[Double]
trait Serializable
class Object
trait Matchable
class Any
Show all
Self type
object MonoidInt extends IntZero, Monoid[Int]

Attributes

Supertypes
trait Monoid[Int]
trait IntZero
trait Zero[Int]
trait Serializable
class Object
trait Matchable
class Any
Show all
Self type
MonoidInt.type
object MonoidString extends StringZero, Monoid[String]

Provides an implicit instance of Monoid for the String type, with behavior defined as string concatenation and an empty string as the identity element.

Provides an implicit instance of Monoid for the String type, with behavior defined as string concatenation and an empty string as the identity element.

This implementation extends Zero.StringZero, inheriting the zero value for String.

Attributes

Supertypes
trait Monoid[String]
trait StringZero
trait Zero[String]
trait Serializable
class Object
trait Matchable
class Any
Show all
Self type

Value members

Concrete methods

def foldLeft[X : Monoid](xs: Seq[X]): X

Folds a sequence of elements of type X into a single value using the provided Monoid instance. The folding operation starts with the zero value of the Monoid and combines all elements of the sequence using the combine method of the Monoid.

Folds a sequence of elements of type X into a single value using the provided Monoid instance. The folding operation starts with the zero value of the Monoid and combines all elements of the sequence using the combine method of the Monoid.

Value parameters

xs

the sequence of elements to fold

Attributes

Returns

the result of folding the sequence using the Monoid

Implicits

Implicits

implicit def monoidTuple[A : Monoid, B : Monoid]: Monoid[(A, B)]

Returns a Monoid instance for a tuple (A, B) where both A and B have Monoid instances. The combine method for this tuple Monoid combines the elements of each tuple using the combine method of their respective Monoid instances. The zero value represents a tuple where each element is the zero value of the corresponding Monoid.

Returns a Monoid instance for a tuple (A, B) where both A and B have Monoid instances. The combine method for this tuple Monoid combines the elements of each tuple using the combine method of their respective Monoid instances. The zero value represents a tuple where each element is the zero value of the corresponding Monoid.

Type parameters

A

the type of the first element in the tuple, which has a Monoid instance

B

the type of the second element in the tuple, which has a Monoid instance

Attributes

Returns

a Monoid instance for the tuple (A, B)