We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
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
Looking into the methods available on an EitherT instance I came across the need of having something like the following:
EitherT
def biSemiflatMap[C, D](fa: A => F[C], fb: B => F[D]): EitherT[F, C, D] = eitherT.leftSemiflatMap(fa).semiflatMap(fb)
Here's an example:
import cats.data._, cats.implicits._, cats.Monad val eitherT: EitherT[List, String, Int] = EitherT(List(Left("abc"), Right(123))) implicit class EitherTOps[F[_]: Monad, A, B](val eitherT: EitherT[F, A, B]) { def biSemiflatMap[C, D](fa: A => F[C], fb: B => F[D]): EitherT[F, C, D] = eitherT.leftSemiflatMap(fa).semiflatMap(fb) } eitherT.biSemiflatMap(string => List(string.length), int => List(int.toFloat)) // res: cats.data.EitherT[List,Int,Float] = EitherT(List(Left(3), Right(123.0)))
Happy to open a PR if it sounds reasonable.
The text was updated successfully, but these errors were encountered:
Adding biSemiflatMap to EitherT (#2269) (#2274)
bfbf021
* Adding biSemiflatMap to EitherT * Expanding leftSemiflatMap and semiflatMap * Added documentation * Added EitherT types for 2.10 and 2.11
Adding biSemiflatMap to EitherT (typelevel#2269) (typelevel#2274)
1bbd891
No branches or pull requests
Looking into the methods available on an
EitherT
instance I came across the need of having something like the following:Here's an example:
Happy to open a PR if it sounds reasonable.
The text was updated successfully, but these errors were encountered: