Choice

trait Choice[F[_, _]] extends Category[F]
Companion:
object
trait Category[F]
trait Compose[F]
class Object
trait Matchable
class Any
trait ArrowChoice[F]

Value members

Abstract methods

def choice[A, B, C](f: F[A, C], g: F[B, C]): F[Either[A, B], C]

Given two Fs (f and g) with a common target type, create a new F with the same target type, but with a source type of either f's source type OR g's source type.

Given two Fs (f and g) with a common target type, create a new F with the same target type, but with a source type of either f's source type OR g's source type.

Example:

scala> import cats.implicits._
scala> val b: Boolean => String = _.toString + " is a boolean"
scala> val i: Int => String =  _.toString + " is an integer"
scala> val f: (Either[Boolean, Int]) => String = b ||| i

scala> f(Right(3))
res0: String = 3 is an integer

scala> f(Left(false))
res0: String = false is a boolean

Concrete methods

def codiagonal[A]: F[Either[A, A], A]

An F that, given a source A on either the right or left side, will return that same A object.

An F that, given a source A on either the right or left side, will return that same A object.

Example:

scala> import cats.implicits._
scala> val f: (Either[Int, Int]) => Int = Choice[Function1].codiagonal[Int]

scala> f(Right(3))
res0: Int = 3

scala> f(Left(3))
res1: Int = 3

Inherited methods

override def algebra[A]: Monoid[F[A, A]]
Definition Classes
Inherited from:
Category
override def algebraK: MonoidK[F]
Definition Classes
Inherited from:
Category
def andThen[A, B, C](f: F[A, B], g: F[B, C]): F[A, C]
Inherited from:
Compose
def compose[A, B, C](f: F[B, C], g: F[A, B]): F[A, C]
Inherited from:
Compose
def id[A]: F[A, A]
Inherited from:
Category