Bifunctor

cats.Bifunctor
See theBifunctor companion object
trait Bifunctor[F[_, _]] extends Serializable

A type class of types which give rise to two independent, covariant functors.

Attributes

Companion
object
Source
Bifunctor.scala
Graph
Supertypes
trait Serializable
class Object
trait Matchable
class Any
Known subtypes
trait Bitraverse[F]
class BinestedBitraverse[F, G, H]
Self type

Members list

Value members

Abstract methods

def bimap[A, B, C, D](fab: F[A, B])(f: A => C, g: B => D): F[C, D]

The quintessential method of the Bifunctor trait, it applies a function to each "side" of the bifunctor.

The quintessential method of the Bifunctor trait, it applies a function to each "side" of the bifunctor.

Example:

scala> import cats.syntax.all._

scala> val x: (List[String], Int) = (List("foo", "bar"), 3)
scala> x.bimap(_.headOption, _.toLong + 1)
res0: (Option[String], Long) = (Some(foo),4)

Attributes

Source
Bifunctor.scala

Concrete methods

def compose[G[_, _]](implicit G0: Bifunctor[G]): Bifunctor[[α, β] =>> F[G[α, β], G[α, β]]]

The composition of two Bifunctors is itself a Bifunctor

The composition of two Bifunctors is itself a Bifunctor

Attributes

Source
Bifunctor.scala
def leftFunctor[X]: Functor[F]

Attributes

Source
Bifunctor.scala
def leftLiftTo[A, B, C[_]](fab: F[A, B])(implicit C: Applicative[C]): F[C[A], B]

Lift left into F using Applicative.

Lift left into F using Applicative. * Example:

scala> import cats.implicits._
scala> val x0: Either[String, Int] = Either.left("foo")
scala> val x1: Either[List[String], Int] = x0.leftLiftTo[List]

Attributes

Source
Bifunctor.scala
def leftMap[A, B, C](fab: F[A, B])(f: A => C): F[C, B]

apply a function to the "left" functor

apply a function to the "left" functor

Attributes

Source
Bifunctor.scala
def leftWiden[A, B, AA >: A](fab: F[A, B]): F[AA, B]

Widens A into a supertype AA.

Widens A into a supertype AA. Example:

scala> import cats.syntax.all._
scala> sealed trait Foo
scala> case object Bar extends Foo
scala> val x1: Either[Bar.type, Int] = Either.left(Bar)
scala> val x2: Either[Foo, Int] = x1.leftWiden

Attributes

Source
Bifunctor.scala
def rightFunctor[X]: Functor[[_] =>> F[X, _$3]]

Attributes

Source
Bifunctor.scala