BinestedBitraverse
Value members
Concrete methods
Inherited methods
Collapse the structure by mapping each element to an element of a type that has a cats.Monoid
Collapse the structure by mapping each element to an element of a type that has a cats.Monoid
- Inherited from
- Bifoldable
- Inherited from
- BinestedBifoldable
- Definition Classes
- Inherited from
- Bitraverse
Invert the structure from F[G[A], G[B]] to G[F[A, B]].
Invert the structure from F[G[A], G[B]] to G[F[A, B]].
Example:
scala> import cats.implicits._
scala> val rightSome: Either[Option[String], Option[Int]] = Either.right(Some(3))
scala> rightSome.bisequence
res0: Option[Either[String, Int]] = Some(Right(3))
scala> val rightNone: Either[Option[String], Option[Int]] = Either.right(None)
scala> rightNone.bisequence
res1: Option[Either[String, Int]] = None
scala> val leftSome: Either[Option[String], Option[Int]] = Either.left(Some("foo"))
scala> leftSome.bisequence
res2: Option[Either[String, Int]] = Some(Left(foo))
scala> val leftNone: Either[Option[String], Option[Int]] = Either.left(None)
scala> leftNone.bisequence
res3: Option[Either[String, Int]] = None
- Inherited from
- Bitraverse
If F and G are both cats.Bitraverse then so is their composition F[G[_, _], G[_, _]]
If F and G are both cats.Bitraverse then so is their composition F[G[_, _], G[_, _]]
- Inherited from
- Bitraverse
The composition of two Bifunctors is itself a Bifunctor
The composition of two Bifunctors is itself a Bifunctor
- Inherited from
- Bifunctor
apply a function to the "left" functor
apply a function to the "left" functor
- Inherited from
- Bifunctor
Sequence the left side of the structure.
For the right side, use the standard sequence
from cats.Traverse.
Sequence the left side of the structure.
For the right side, use the standard sequence
from cats.Traverse.
Example:
scala> import cats.implicits._
scala> val optionalErrorRight: Either[Option[String], Int] = Either.right(123)
scala> optionalErrorRight.leftSequence
res1: Option[Either[String, Int]] = Some(Right(123))
scala> val optionalErrorLeftSome: Either[Option[String], Int] = Either.left(Some("something went wrong"))
scala> optionalErrorLeftSome.leftSequence
res2: Option[Either[String, Int]] = Some(Left(something went wrong))
scala> val optionalErrorLeftNone: Either[Option[String], Int] = Either.left(None)
scala> optionalErrorLeftNone.leftSequence
res3: Option[Either[String,Int]] = None
- Inherited from
- Bitraverse
Traverse over the left side of the structure.
For the right side, use the standard traverse
from cats.Traverse.
Traverse over the left side of the structure.
For the right side, use the standard traverse
from cats.Traverse.
Example:
scala> import cats.implicits._
scala> val intAndString: (Int, String) = (7, "test")
scala> Bitraverse[Tuple2].leftTraverse(intAndString)(i => Option(i).filter(_ > 5))
res1: Option[(Int, String)] = Some((7,test))
scala> Bitraverse[Tuple2].leftTraverse(intAndString)(i => Option(i).filter(_ < 5))
res2: Option[(Int, String)] = None
- Inherited from
- Bitraverse
Widens A into a supertype AA. Example:
Widens A into a supertype AA. Example:
scala> import cats.implicits._
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
- Inherited from
- Bifunctor