- Companion:
- object
Value members
Abstract methods
Given two F
s (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 F
s (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
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