An associative binary operation, circumscribed by type and the semigroup laws. Unlike scalaz.Monoid, there is not necessarily a zero.
- See also
- Companion
- object
Type members
Classlikes
A semigroup in type F must satisfy two laws:
A semigroup in type F must satisfy two laws:
- '''closure''':
∀ a, b in F, append(a, b)
is also inF
. This is enforced by the type system. - '''associativity''':
∀ a, b, c
inF
, the equationappend(append(a, b), c) = append(a, append(b , c))
holds.
Value members
Abstract methods
Concrete methods
An scalaz.Apply, that implements ap
with append
. Note
that the type parameter α
in Apply[λ[α => F]]
is
discarded; it is a phantom type. As such, the functor cannot
support scalaz.Bind.
An scalaz.Apply, that implements ap
with append
. Note
that the type parameter α
in Apply[λ[α => F]]
is
discarded; it is a phantom type. As such, the functor cannot
support scalaz.Bind.
Every Semigroup
gives rise to a scalaz.Compose, for which
the type parameters are phantoms.
Every Semigroup
gives rise to a scalaz.Compose, for which
the type parameters are phantoms.
- Note
compose.semigroup
=this
For n = 0
, value
For n = 1
, append(value, value)
For n = 2
, append(append(value, value), value)
For n = 0
, value
For n = 1
, append(value, value)
For n = 2
, append(append(value, value), value)
The default definition uses peasant multiplication, exploiting associativity to only
require O(log n)
uses of append