Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Rename EitherT.biflatMap #2603

Merged
merged 1 commit into from
Nov 15, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion core/src/main/scala/cats/data/EitherT.scala
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ final case class EitherT[F[_], A, B](value: F[Either[A, B]]) {
applicativeG: Applicative[G]): G[EitherT[F, C, D]] =
applicativeG.map(traverseF.traverse(value)(axb => Bitraverse[Either].bitraverse(axb)(f, g)))(EitherT.apply)

def biFlatMap[AA >: A, BB >: B](fa: A => EitherT[F, AA, BB],
def biflatMap[AA >: A, BB >: B](fa: A => EitherT[F, AA, BB],
fb: B => EitherT[F, AA, BB])(implicit F: FlatMap[F]): EitherT[F, AA, BB] =
EitherT(F.flatMap(value) {
case Left(a) => fa(a).value
Expand Down
12 changes: 6 additions & 6 deletions tests/src/test/scala/cats/tests/EitherTSuite.scala
Original file line number Diff line number Diff line change
Expand Up @@ -523,28 +523,28 @@ class EitherTSuite extends CatsSuite {
}
}

test("biFlatMap consistent with flatMap") {
test("biflatMap consistent with flatMap") {
forAll { (eithert: EitherT[List, String, Int], fb: Int => EitherT[List, String, Int]) =>
val noChangeLeft = (s: String) => EitherT.left[Int](List(s))

eithert.biFlatMap(noChangeLeft, fb) should ===(eithert.flatMap(fb))
eithert.biflatMap(noChangeLeft, fb) should ===(eithert.flatMap(fb))
}
}

test("biFlatMap consistent with leftFlatMap") {
test("biflatMap consistent with leftFlatMap") {
forAll { (eithert: EitherT[List, String, Int], fa: String => EitherT[List, String, Int]) =>
val noChangeRight = (i: Int) => EitherT.right[String](List(i))

eithert.biFlatMap(fa, noChangeRight) should ===(eithert.leftFlatMap(fa))
eithert.biflatMap(fa, noChangeRight) should ===(eithert.leftFlatMap(fa))
}
}

test("biFlatMap with Left and Right consistent with leftFlatMap and then flatMap") {
test("biflatMap with Left and Right consistent with leftFlatMap and then flatMap") {
forAll { (eithert: EitherT[List, String, Int], string: String, int: Int) =>
val leftFun = (_: String) => EitherT.left[Int](List(string))
val rightFun = (_: Int) => EitherT.right[String](List(int))

eithert.biFlatMap(leftFun, rightFun) should ===(eithert.leftFlatMap(leftFun).flatMap(rightFun))
eithert.biflatMap(leftFun, rightFun) should ===(eithert.leftFlatMap(leftFun).flatMap(rightFun))
}
}

Expand Down