Combine two F[A] values.
Combine two F[A] values.
Example:
scala> import cats.implicits._ scala> SemigroupK[List].combineK(List(1, 2), List(3, 4)) res0: List[Int] = List(1, 2, 3, 4)
Given a type A, create an "empty" F[A] value.
Given a type A, create an "empty" F[A] value.
Example:
scala> import cats.implicits._ scala> MonoidK[List].empty[Long] res0: List[Long] = List()
Given a type A, create a concrete Monoid[F[A]].
Given a type A, create a concrete Monoid[F[A]].
"Compose" with a G[_]
type to form a SemigroupK
for λ[α => F[G[α]]]
.
"Compose" with a G[_]
type to form a SemigroupK
for λ[α => F[G[α]]]
.
Note that this universally works for any G
, because the "inner" structure
isn't considered when combining two instances.
Example:
scala> import cats.implicits._ scala> type ListOption[A] = List[Option[A]] scala> val s: SemigroupK[ListOption] = SemigroupK[List].compose[Option] scala> s.combineK(List(Some(1), None, Some(2)), List(Some(3), None)) res0: List[Option[Int]] = List(Some(1), None, Some(2), Some(3), None)
MonoidK is a universal monoid which operates on kinds.
This type class is useful when its type parameter F[_] has a structure that can be combined for any particular type, and which also has an "empty" representation. Thus, MonoidK is like a Monoid for kinds (i.e. parametrized types).
A MonoidK[F] can produce a Monoid[F[A]] for any type A.
Here's how to distinguish Monoid and MonoidK: