Skip to content

Commit

Permalink
Expanding leftSemiflatMap and semiflatMap
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 76fc39a commit 596ad6e
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion core/src/main/scala/cats/data/EitherT.scala
Original file line number Diff line number Diff line change
Expand Up @@ -121,7 +121,10 @@ final case class EitherT[F[_], A, B](value: F[Either[A, B]]) {
})

def biSemiflatMap[C, D](fa: A => F[C], fb: B => F[D])(implicit F: Monad[F]): EitherT[F, C, D] =
leftSemiflatMap(fa).semiflatMap(fb)
EitherT(F.flatMap(value) {
case Left(a) => F.map(fa(a)) { c => Left(c) }
case Right(b) => F.map(fb(b)) { d => Right(d) }
})

def compare(that: EitherT[F, A, B])(implicit o: Order[F[Either[A, B]]]): Int =
o.compare(value, that.value)
Expand Down

0 comments on commit 596ad6e

Please sign in to comment.