A semigroup is required to be associative, but I could define a Semigroup
like:
trait Semigroup[T] {
def op(t1:T, t2:T) : T
}
def plus = new Semigroup[Int] { def op(t1:Int, t2:Int) = t1 - t2 }
I am able to implement plus
which is not associative, yet the class is still a Semigroup
. Is there a safeguard in place against this or is the user expected to rely on testing to prevent this?