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)
Modify the right side context G
using transformation f
.
The underlying scala.util.Either
.
F
on the left andG
on the right ofscala.util.Either
.The underlying
scala.util.Either
.