- Every monoid is a semiGroup but not the other way around. It has all characteristics of a semigroup + more
- Laws:
- Left Identity
append(a, 0) == a
- Right Identity
append(0, a) == a
- Left Identity
NotEmpty
is not a monoid since it has no zero value.- Permission systems should be implemented as monoidal systems.
1
2
3
4
trait Monoid[A] extends SemiGroup[A] {
def zero: A // example: Zero value for a string is ""
// Note that we have inherited append from SemiGroup
}
Comments powered by Disqus.