In cats there are 2 semigroup types classes: Semigroup
and SemigroupK
with the latter working on type constructors.
I fail to see the advantages of the latter over the former. If I look at the list instances they are providing Monoid
(although there is a MonoidK
), whereas NonEmptyList
is providing a SemigroupK
. Note that NonEmptyList
is also providing a Semigroup
via the following method:
implicit def catsDataSemigroupForNonEmptyList[A]: Semigroup[NonEmptyList[A]] =
SemigroupK[NonEmptyList].algebra[A]
Why the discrepancy?
Then it seems that most semigroup operations are only available on Semigroup
and not SemigroupK
(there's reduceK
in Reducible
but that's the only one I saw, and it delegates to reduce
which works on Semigroup
).
So, given a type T[_]
, what would you gain by having both a SemigroupK[T]
and a Semigroup[T[A]] for some A
?
Edit
There's now an issue to remove MonoidK and SemigroupK: https://github.com/typelevel/cats/issues/1932