catsInstances

object catsInstances extends ContravariantMonoidal[Observer] with MonoidK[Observer]
trait MonoidK[Observer]
trait SemigroupK[Observer]
trait ContravariantMonoidal[Observer]
trait InvariantMonoidal[Observer]
trait ContravariantSemigroupal[Observer]
trait Contravariant[Observer]
trait InvariantSemigroupal[Observer]
trait Invariant[Observer]
trait Semigroupal[Observer]
trait Serializable
class Object
trait Matchable
class Any

Value members

Concrete methods

@inline
override def combineK[T](a: Observer[T], b: Observer[T]): Observer[T]
Definition Classes
SemigroupK
@inline
override def contramap[A, B](fa: Observer[A])(f: B => A): Observer[B]
Definition Classes
Contravariant
@inline
override def empty[T]: Observer[T]
Definition Classes
MonoidK
@inline
override def product[A, B](fa: Observer[A], fb: Observer[B]): Observer[(A, B)]
Definition Classes
Semigroupal
@inline
override def unit: Observer[Unit]
Definition Classes
InvariantMonoidal

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 combineAllK[A](as: IterableOnce[Observer[A]]): Observer[A]

Given a sequence of as, sum them using the monoidK and return the total.

Given a sequence of as, sum them using the monoidK and return the total.

Example:

scala> MonoidK[List].combineAllK(List(List("One"), List("Two"), List("Three")))
res0: List[String] = List(One, Two, Three)

scala> MonoidK[List].combineAllK[String](List.empty)
res1: List[String] = List()
Inherited from:
MonoidK
def combineAllOptionK[A](as: IterableOnce[Observer[A]]): Option[Observer[A]]

Given a sequence of as, combine them and return the total.

Given a sequence of as, combine them and return the total.

If the sequence is empty, returns None. Otherwise, returns Some(total).

Example:

scala> SemigroupK[List].combineAllOptionK(List(List("One"), List("Two"), List("Three")))
res0: Option[List[String]] = Some(List(One, Two, Three))

scala> SemigroupK[List].combineAllOptionK[String](List.empty)
res1: Option[List[String]] = None
Inherited from:
SemigroupK
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 combineNK[A](a: Observer[A], n: Int): Observer[A]

Return a combined with itself n times.

Return a combined with itself n times.

Example:

scala> SemigroupK[List].combineNK(List(1), 5)
res0: List[Int] = List(1, 1, 1, 1, 1)

scala> MonoidK[List].combineNK(List("ha"), 0)
res1: List[String] = List()

Definition Classes
MonoidK -> SemigroupK
Inherited from:
MonoidK
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 compose[G[_] : Invariant]: Invariant[[α] =>> Observer[G[α]]]

Compose Invariant F[_] and G[_] then produce Invariant[F[G[_]]] using their imap.

Compose Invariant F[_] and G[_] then produce Invariant[F[G[_]]] using their imap.

Example:

scala> import cats.implicits._
scala> import scala.concurrent.duration._

scala> val durSemigroupList: Semigroup[List[FiniteDuration]] =
    | Invariant[Semigroup].compose[List].imap(Semigroup[List[Long]])(Duration.fromNanos)(_.toNanos)
scala> durSemigroupList.combine(List(2.seconds, 3.seconds), List(4.seconds))
res1: List[FiniteDuration] = List(2 seconds, 3 seconds, 4 seconds)
Inherited from:
Invariant
def compose[G[_] : Contravariant]: Functor[[α] =>> Observer[G[α]]]
Inherited from:
Contravariant
def composeApply[G[_] : Apply]: InvariantSemigroupal[[α] =>> Observer[G[α]]]
Inherited from:
InvariantSemigroupal
def composeContravariant[G[_] : Contravariant]: Invariant[[α] =>> Observer[G[α]]]

Compose Invariant F[_] and Contravariant G[_] then produce Invariant[F[G[_]]] using F's imap and G's contramap.

Compose Invariant F[_] and Contravariant G[_] then produce Invariant[F[G[_]]] using F's imap and G's contramap.

Example:

scala> import cats.implicits._
scala> import scala.concurrent.duration._

scala> type ToInt[T] = T => Int
scala> val durSemigroupToInt: Semigroup[ToInt[FiniteDuration]] =
    | Invariant[Semigroup]
    |   .composeContravariant[ToInt]
    |   .imap(Semigroup[ToInt[Long]])(Duration.fromNanos)(_.toNanos)
// semantically equal to (2.seconds.toSeconds.toInt + 1) + (2.seconds.toSeconds.toInt * 2) = 7
scala> durSemigroupToInt.combine(_.toSeconds.toInt + 1, _.toSeconds.toInt * 2)(2.seconds)
res1: Int = 7
Inherited from:
Invariant
override def composeFunctor[G[_] : Functor]: ContravariantSemigroupal[[α] =>> Observer[G[α]]]
Definition Classes
ContravariantSemigroupal -> Contravariant -> Invariant
Inherited from:
ContravariantSemigroupal
override def imap[A, B](fa: Observer[A])(f: A => B)(fi: B => A): Observer[B]
Definition Classes
Contravariant -> Invariant
Inherited from:
Contravariant
def isEmpty[A](a: Observer[A])(implicit ev: Eq[Observer[A]]): Boolean

Tests if a is the identity.

Tests if a is the identity.

Example:

scala> MonoidK[List].isEmpty(List.empty[String])
res0: Boolean = true

scala> MonoidK[List].isEmpty(List("something"))
res1: Boolean = false
Inherited from:
MonoidK
def liftContravariant[A, B](f: A => B): Observer[B] => Observer[A]
Inherited from:
Contravariant
def narrow[A, B <: A](fa: Observer[A]): Observer[B]

Lifts natural subtyping contravariance of contravariant Functors. could be implemented as contramap(identity), but the Functor laws say this is equivalent

Lifts natural subtyping contravariance of contravariant Functors. could be implemented as contramap(identity), but the Functor laws say this is equivalent

Inherited from:
Contravariant
def point[A](a: A): Observer[A]

point lifts any value into a Monoidal Functor.

point lifts any value into a Monoidal Functor.

Example:

scala> import cats.implicits._

scala> InvariantMonoidal[Option].point(10)
res0: Option[Int] = Some(10)
Inherited from:
InvariantMonoidal
override def reverse: MonoidK[Observer]
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
def trivial[A]: Observer[A]

trivial produces an instance of F for any type A that is trivial with respect to contramap2 along the diagonal

trivial produces an instance of F for any type A that is trivial with respect to contramap2 along the diagonal

Inherited from:
ContravariantMonoidal