Is their a simple raison why Scalaz SemiGroup is not covariant :
https://github.com/scalaz/scalaz/blob/series/7.1.x/core/src/main/scala/scalaz/Semigroup.scala
Thanks.
Is their a simple raison why Scalaz SemiGroup is not covariant :
https://github.com/scalaz/scalaz/blob/series/7.1.x/core/src/main/scala/scalaz/Semigroup.scala
Thanks.
Copyright © 2021 Jogjafile Inc.
How could it be? the type parameter appears both in covariant and contravariant position (result and argument) in the main operation of semigroup,
append, so it can be neither covariant nor contravariantJust to give a simple counter example, consider
Seq[Int](Intis just to fix the type, could be anything). You can easily define a semigroup there, withappendbeing++. Now Option does not extends Seq, but it would be easy to arrange an option-like type that would extends Seq (or even just a typecase class Single[A](a: A) extends Seq[A]).Yet the semigroup ofSeq[Int]could in no way be a semigroup of Option[Int] or Single[Int], appending two options does not give an option, nor appending two singles.