Monoid instances must satisfy SemigroupLaw and 2 additional laws:
A semigroup in type F must satisfy two laws:
The binary operation to combine f1
and f2
.
The binary operation to combine f1
and f2
.
Implementations should not evaluate the by-name parameter f2
if result
can be determined by f1
.
The identity element for append
.
A monoidal applicative functor, that implements point
and ap
with the operations zero
and append
respectively.
A monoidal applicative functor, that implements point
and ap
with the operations zero
and append
respectively. Note that
the type parameter α
in Applicative[({type λ[α]=F})#λ]
is
discarded; it is a phantom type. As such, the functor cannot
support Bind.
An Apply, that implements ap
with append
.
Every Monoid
gives rise to a Category, for which
the type parameters are phantoms.
Every Monoid
gives rise to a Category, for which
the type parameters are phantoms.
category.monoid
= this
Every Semigroup
gives rise to a Compose, for which
the type parameters are phantoms.
Whether a
== zero
.
For n = 0
, zero
For n = 1
, append(zero, value)
For n = 2
, append(append(zero, value), value)
Provides an identity element (
zero
) to the binaryappend
operation in Semigroup, subject to the monoid laws.Example instances:
Monoid[Int]
:zero
andappend
are0
andInt#+
respectivelyMonoid[List[A]]
:zero
andappend
areNil
andList#++
respectivelyReferences:
MonoidLaw
,MonoidOps