F
on the left and G
on the right of scala.util.Either
.
- Value parameters:
- run
The underlying
scala.util.Either
.
- Companion:
- object
Value members
Concrete methods
Fold this eitherK into a new type constructor using two natural transformations.
Fold this eitherK into a new type constructor using two natural transformations.
Example:
scala> import cats.arrow.FunctionK
scala> import cats.data.EitherK
scala> val listToOption = λ[FunctionK[List, Option]](_.headOption)
scala> val optionToOption = FunctionK.id[Option]
scala> val cp1: EitherK[List, Option, Int] = EitherK.leftc(List(1,2,3))
scala> val cp2: EitherK[List, Option, Int] = EitherK.rightc(Some(4))
scala> cp1.fold(listToOption, optionToOption)
res0: Option[Int] = Some(1)
scala> cp2.fold(listToOption, optionToOption)
res1: Option[Int] = Some(4)