monoidK

object monoidK extends MonoidK[Observer]
trait MonoidK[Observer]
trait SemigroupK[Observer]
trait Serializable
class Object
trait Matchable
class Any
monoidK.type

Value members

Concrete methods

@inline
def combineK[T](a: Observer[T], b: Observer[T]): Observer[T]
@inline
def empty[T]: Observer[T]

Inherited methods

override def algebra[A]: Monoid[Observer[A]]

Given a type A, create a concrete Monoid[F[A]].

Given a type A, create a concrete Monoid[F[A]].

Example:

scala> import cats.implicits._
scala> MonoidK[List].algebra[Long].empty
res0: List[Long] = List()
Definition Classes
MonoidK -> SemigroupK
Inherited from:
MonoidK
def combineKEval[A](x: Observer[A], y: Eval[Observer[A]]): Eval[Observer[A]]

Similar to combineK but uses Eval to allow for laziness in the second argument. This can allow for "short-circuiting" of computations.

Similar to combineK but uses Eval to allow for laziness in the second argument. This can allow for "short-circuiting" of computations.

NOTE: the default implementation of combineKEval does not short-circuit computations. For data structures that can benefit from laziness, SemigroupK instances should override this method.

In the following example, x.combineK(bomb) would result in an error, but combineKEval "short-circuits" the computation. x is Some and thus the result of bomb doesn't even need to be evaluated in order to determine that the result of combineKEval should be x.

scala> import cats.{Eval, Later}
scala> import cats.implicits._
scala> val bomb: Eval[Option[Int]] = Later(sys.error("boom"))
scala> val x: Option[Int] = Some(42)
scala> x.combineKEval(bomb).value
res0: Option[Int] = Some(42)
Inherited from:
SemigroupK
override def compose[G[_]]: MonoidK[[α] =>> Observer[G[α]]]

Given a kind G, create an "composed" MonoidK[F[G[_]]

Given a kind G, create an "composed" MonoidK[F[G[_]]

Example:

scala> import cats.implicits._
scala> val monoidK = MonoidK[List].compose[Option]
scala> monoidK.combineK(List(Some(1)), List(Some(2), None))
res0: List[Option[Int]] = List(Some(1), Some(2), None)
Definition Classes
MonoidK -> SemigroupK
Inherited from:
MonoidK
def sum[A, B](fa: Observer[A], fb: Observer[B])(implicit F: Functor[Observer]): Observer[Either[A, B]]

Combines F[A] and F[B] into a F[Either[A,B]]].

Combines F[A] and F[B] into a F[Either[A,B]]].

Example:

scala> import cats.SemigroupK
scala> import cats.data.NonEmptyList
scala> SemigroupK[NonEmptyList].sum(NonEmptyList.one("abc"), NonEmptyList.one(2))
res0: NonEmptyList[Either[String,Int]] = NonEmptyList(Left(abc), Right(2))
Inherited from:
SemigroupK