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

[extras-cats] Add innerMap, innerFlatMap, innerFlatMapF, innerGetOrElse, innerGetOrElseF, innerFold and innerFoldF extension methods to F[Either[A, B]] #356

Closed
kevin-lee opened this issue Mar 10, 2023 · 0 comments · Fixed by #357
Assignees
Labels
task Task
Milestone

Comments

@kevin-lee
Copy link
Owner

kevin-lee commented Mar 10, 2023

Task

Summary

[extras-cats] Add innerMap, innerFlatMap, innerFlatMapF, innerGetOrElse, innerGetOrElseF, innerFold and innerFoldF extension methods to F[Either[A, B]]

Project Details

Version: 0.35.0

Description

  • innerMap
    val feab: F[Either[A, B]] = ...
    feab.innerMap(B => D) // F[Either[A, D]]
    val feab: F[Either[String, Int]] = IO.pure(Right(1))
    // IO[Either[String, Int]] = IO(Right(1))
    feab.innerMap(_ + 999)
    // IO[Either[String, Int]] = IO(Right(1000))

  • innerFlatMap
    val feab: F[Either[A, B]] = ...
    feab.innerFlatMap(B => Either[A, D]) // F[Either[A, D]]
    val feab: F[Either[String, Int]] = IO.pure(Right(1))
    // IO[Either[String, Int]] = IO(Right(1))
    feab.innerFlatMap(b => (b + 999).asRight[String])
    // IO[Either[String, Int]] = IO(Right(1000))

  • innerFlatMapF
    val feab: F[Either[A, B]] = ...
    feab.innerFlatMapF(B => F[Either[A, D]]) // F[Either[A, D]]
    val feab: F[Either[String, Int]] = IO.pure(Right(1))
    // IO[Either[String, Int]] = IO(Right(1))
    feab.innerFlatMapF(b => IO.pure((b + 999).asRight[String]))
    // IO[Either[String, Int]] = IO(Right(1000))

  • innerGetOrElse
    val feab: F[Either[A, B]] = ...
    feab.innerGetOrElse[D >: B](=> D) // F[D]
    val feab: F[Either[String, Int]] = IO.pure(Right(999))
    // IO[Either[String, Int]] = IO(Right(999))
    feab.innerGetOrElse(0)
    // IO[Int] = IO(999)
    
    val feab2: F[Either[String, Int]] = IO.pure("Error".asLeft[Int])
    // IO[Either[String, Int]] = IO(Left("Error"))
    feab2.innerGetOrElse(0)
    // IO[Int] = IO(0)

  • innerGetOrElseF
    val feab: F[Either[A, B]] = ...
    feab.innerGetOrElseF[D >: B](=> F[D]) // F[D]
    val feab: F[Either[String, Int]] = IO.pure(Right(999))
    // IO[Either[String, Int]] = IO(Right(999))
    feab.innerGetOrElseF(IO.pure(0))
    // IO[Either[String, Int]] = IO(Right(999))
    
    val feab2: F[Either[String, Int]] = IO.pure("Error".asLeft[Int])
    // IO[Either[String, Int]] = IO(Left("Error"))
    feab2.innerGetOrElseF(IO.pure(0))
    // IO[Int] = IO(0)

  • innerFold
    val feab: F[Either[A, B]] = ...
    feab.innerFold[D](=> D)(B => D) // F[D]
    val feab: F[Either[String, Int]] = IO.pure(Right(1))
    // IO[Either[String, Int]] = IO(Right(1))
    feab.innerFold(0)(_ + 999)
    // IO[Int] = IO(1000)
    
    val feab: F[Either[String, Int]] = IO.pure("Error".asLeft)
    // IO[Either[String, Int]] = IO(Left("Error"))
    feab.innerFold(0)(_ + 999)
    // IO[Int] = IO(0)

  • innerFoldF
    val feab: F[Either[A, B]] = ...
    feab.innerFoldF[D](=> F[D])(B => F[D]) // F[D]
    val feab: F[Either[String, Int]] = IO.pure(Right(1))
    // IO[Either[String, Int]] = IO(Right(1))
    feab.innerFoldF(IO.pure(0))(b => IO.pure(b + 999))
    // IO[Int] = IO(1000)
    
    val feab: F[Either[String, Int]] = IO.pure("Error".asLeft)
    // IO[Either[String, Int]] = IO(Left("Error"))
    feab.innerFoldF(IO.pure(0))(b => IO.pure(b + 999))
    // IO[Int] = IO(0)
@kevin-lee kevin-lee added the task Task label Mar 10, 2023
@kevin-lee kevin-lee added this to the milestone37 milestone Mar 10, 2023
@kevin-lee kevin-lee self-assigned this Mar 10, 2023
kevin-lee added a commit that referenced this issue Mar 10, 2023
… innerGetOrElse, innerGetOrElseF, innerFold and innerFoldF extension methods to F[Either[A, B]]
kevin-lee added a commit that referenced this issue Mar 10, 2023
… innerGetOrElse, innerGetOrElseF, innerFold and innerFoldF extension methods to F[Either[A, B]]
kevin-lee added a commit that referenced this issue Mar 11, 2023
Close #356 - [`extras-cats`] Add `innerMap`, `innerFlatMap`, `innerFlatMapF`, `innerGetOrElse`, `innerGetOrElseF`, `innerFold` and `innerFoldF` extension methods to `F[Either[A, B]]`
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment