Skip to content

Commit

Permalink
Added documentation
Browse files Browse the repository at this point in the history
  • Loading branch information
Erica Giordo authored and Erica Giordo committed Jun 7, 2018
1 parent 596ad6e commit 7a40d95
Showing 1 changed file with 12 additions and 0 deletions.
12 changes: 12 additions & 0 deletions core/src/main/scala/cats/data/EitherT.scala
Original file line number Diff line number Diff line change
Expand Up @@ -120,6 +120,18 @@ final case class EitherT[F[_], A, B](value: F[Either[A, B]]) {
case r@Right(_) => F.pure(r.leftCast)
})

/** Combine `leftSemiflatMap` and `semiflatMap` together.
*
* Example:
* {{{
* scala> import cats.implicits._
* scala> import cats.data.EitherT
*
* scala> val eitherT: EitherT[List, String, Int] = EitherT(List(Left("abc"), Right(123)))
* scala> eitherT.biSemiflatMap(string => List(string.length), int => List(int.toFloat))
* res0: cats.data.EitherT[List,Int,Float] = EitherT(List(Left(3), Right(123.0)))
* }}}
*/
def biSemiflatMap[C, D](fa: A => F[C], fb: B => F[D])(implicit F: Monad[F]): EitherT[F, C, D] =
EitherT(F.flatMap(value) {
case Left(a) => F.map(fa(a)) { c => Left(c) }
Expand Down

0 comments on commit 7a40d95

Please sign in to comment.