0

Semigroup に Option タイプがあり、None が Monoid のニュートラル要素のように動作するのはなぜですか?

val two: Option[Int] = Option(2)
val n: Option[Int] = None

n |+| two should be(Some(2))//why do we have the opportunity to do this?
two |+| n should be(Some(2))//n look like neutral here

Semigroup[Option[Int]].combine(Option(1), None) should be(Some(1))//why does semigroup has it?
4

1 に答える 1