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 v0.36.0 #365

Merged
merged 1 commit into from
Mar 12, 2023
Merged

extras v0.36.0 #365

merged 1 commit into from
Mar 12, 2023

Conversation

kevin-lee
Copy link
Owner

@kevin-lee kevin-lee commented Mar 12, 2023

extras v0.36.0

0.36.0 - 2023-03-12

New Feature

extras-cats



  • Add innerFlatMapF extension method to F[Option[A]] ([extras-cats] Add innerFlatMapF extension method to F[Option[A]] #352)
    val foa: F[Option[A]] = ...
    foa.innerFlatMapF(A => F[Option[B]]) // F[Option[B]]
    val foa: IO[Option[Int]] = IO.pure(1)
    // IO[Option[Int]] = IO(Some(1))
    foa.innerFlatMapF(a => IO.pure((a + 999).some))
    // IO[Option[Int]] = IO(Some(1000))

  • innerGetOrElse, innerGetOrElseF, innerFold and innerFoldF to extension methods to F[Option[A]] ([extras-cats] innerGetOrElse, innerGetOrElseF, innerFold and innerFoldF to extension methods to F[Option[A]] #354)
    • innerGetOrElse

      val foa: F[Option[A]] = ...
      foa.innerGetOrElse[B >: A](=> B) // F[Option[B]]
      val foa: IO[Option[Int]] = IO.pure(999)
      // IO[Option[Int]] = IO(Some(999))
      foa.innerGetOrElse(0)
      // IO[Option[Int]] = IO(Some(1000))
      
      val foa2: IO[Option[Int]] = IO.pure(Option.empty[Int])
      // IO[Option[Int]] = None
      foa2.innerGetOrElse(0)
      // IO[Option[Int]] = IO(Some(0))
    • innerGetOrElseF

      val foa: F[Option[A]] = ...
      foa.innerGetOrElseF[B >: A](=> F[B]) // F[Option[B]]
      val foa: IO[Option[Int]] = IO.pure(999)
      // IO[Option[Int]] = IO(Some(999))
      foa.innerGetOrElseF(IO.pure(0))
      // IO[Option[Int]] = IO(Some(1000))
      
      val foa2: IO[Option[Int]] = IO.pure(Option.empty[Int])
      // IO[Option[Int]] = None
      foa2.innerGetOrElseF(IO.pure(0))
      // IO[Option[Int]] = IO(Some(0))
    • innerFold

      val foa: F[Option[A]] = ...
      foa.innerFold[B](=> B)(A => B) // F[Option[B]]
      val foa: IO[Option[Int]] = IO.pure(1)
      // IO[Option[Int]] = IO(Some(1))
      foa.innerFold(0)(_ + 999)
      // IO[Option[Int]] = IO(Some(1000))
      
      val foa2: IO[Option[Int]] = IO.pure(Option.empty[Int])
      // IO[Option[Int]] = None
      foa2.innerFold(0)(_ + 999)
      // IO[Option[Int]] = IO(Some(0))
    • innerFoldF

      val foa: F[Option[A]] = ...
      foa.innerFoldF[B >: A](=> F[B]) // F[Option[B]]
      val foa: IO[Option[Int]] = IO.pure(1)
      // IO[Option[Int]] = IO(Some(1))
      foa.innerFoldF(IO.pure(0))(a => IO.pure(a + 999))
      // IO[Option[Int]] = IO(Some(1000))
      
      val foa2: IO[Option[Int]] = IO.pure(Option.empty[Int])
      // IO[Option[Int]] = None
      foa2.innerFoldF(IO.pure(0))(a => IO.pure(a + 999))
      // IO[Option[Int]] = IO(Some(0))

  • Add innerMap, innerFlatMap, innerFlatMapF, innerGetOrElse, innerGetOrElseF, innerFold and innerFoldF extension methods to F[Either[A, B]] ([extras-cats] Add innerMap, innerFlatMap, innerFlatMapF, innerGetOrElse, innerGetOrElseF, innerFold and innerFoldF extension methods to F[Either[A, B]] #356)
    • 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)

  • Add innerLeftMap, innerLeftFlatMap and innerLeftFlatMapF extension methods to F[Either[A, B]] ([extras-cats] Add innerLeftMap, innerLeftFlatMap and innerLeftFlatMapF extension methods to F[Either[A, B]] #358)

    • innerLeftMap

      val feab: F[Either[A, B]] = ...
      feab.innerLeftMap(A => C) // F[Either[C, B]]
      val feab: F[Either[String, Int]] = IO.pure(Left("Error"))
      // IO[Either[String, Int]] = IO(Left("Error"))
      feab.innerLeftMap("Failed: " + _)
      // IO[Either[String, Int]] = IO(Left("Failed: Error"))
    • innerLeftFlatMap

      val feab: F[Either[A, B]] = ...
      feab.innerFlatMap(A => Either[C, B]) // F[Either[C, B]]
      val feab: F[Either[String, Int]] = IO.pure(Left("Error"))
      // IO[Either[String, Int]] = IO(Left("Error"))
      feab.innerFlatMap(a => ("Failed: " + a).asLeft[Int])
      // IO[Either[String, Int]] = IO(Left("Failed: Error"))
    • innerLeftFlatMapF

      val feab: F[Either[A, B]] = ...
      feab.innerFlatMapF(A => F[Either[C, B]]) // F[Either[C, B]]
      val feab: F[Either[String, Int]] = IO.pure(Left("Error"))
      // IO[Either[String, Int]] = IO(Left("Error"))
      feab.innerFlatMapF(a => IO.pure(("Failed: " + a).asLeft[Int]))
      // IO[Either[String, Int]] = IO(Left("Failed: Error"))
  • Add innerFilter, innerExists, innerContains, innerForall, innerCollect, innerOrElse and innerOrElseF extension methods to F[Option[A]] ([extras-cats] Add innerFilter, innerExists, innerContains, innerForall, innerCollect, innerOrElse and innerOrElseF extension methods to F[Option[A]] #360)

    • innerFilter

      val foa: F[Option[A]] = ...
      foa.innerFilter(A => Boolean) // F[Option[A]]
      val foa: IO[Option[Int]] = IO.pure(Some(1))
      // IO[Option[Int]] = IO(Some(1))
      foa.innerFilter(_ > 0)
      // IO[Option[Int]] = IO(Some(1))
      foa.innerFilter(_ > 1)
      // IO[Option[Int]] = IO(None)
    • innerExists

      val foa: F[Option[A]] = ...
      foa.innerExists(A => Boolean) // F[Boolean]
      val foa: IO[Option[Int]] = IO.pure(Some(1))
      // IO[Option[Int]] = IO(Some(1))
      foa.innerExists(_ > 0)
      // IO[Boolean] = IO(true)
      foa.innerExists(_ > 1)
      // IO[Boolean] = IO(false)
    • innerContains

      val foa: F[Option[A]] = ...
      foa.innerContains(A) // F[Boolean]
      val foa: IO[Option[Int]] = IO.pure(Some(1))
      // IO[Option[Int]] = IO(Some(1))
      foa.innerContains(1)
      // IO[Boolean] = IO(true)
      foa.innerContains(0)
      // IO[Boolean] = IO(false)
    • innerForall

      val foa: F[Option[A]] = ...
      foa.innerForall(A) // F[Boolean]
      val foa: IO[Option[Int]] = IO.pure(Some(1))
      // IO[Option[Int]] = IO(Some(1))
      foa.innerForall(_ > 0)
      // IO[Boolean] = IO(true)
      foa.innerForall(_ > 1)
      // IO[Boolean] = IO(false)
      
      val foa2: IO[Option[Int]] = IO.pure(None)
      // IO[Option[Int]] = IO(None)
      foa2.innerForall(_ > 1)
      // IO[Boolean] = IO(true)
    • innerCollect

      val foa: F[Option[A]] = ...
      foa.innerCollect(PartialFunction[A, B]) // F[Option[B]]
      val foa: IO[Option[Int]] = IO.pure(Some(1))
      // IO[Option[Int]] = IO(Some(1))
      foa.innerCollect {
        case 1 => 0
        case 2 => 999
      }
      // IO[Option[Int]] = IO(0)
      
      val foa2: IO[Option[Int]] = IO.pure(Some(2))
      // IO[Option[Int]] = IO(2)
      foa.innerCollect {
        case 1 => 0
        case 2 => 999
      }
      // IO[Option[Int]] = IO(999)
      
      val foa3: IO[Option[Int]] = IO.pure(Some(3))
      // IO[Option[Int]] = IO(3)
      foa.innerCollect {
        case 1 => 0
        case 2 => 999
      }
      // IO[Option[Int]] = IO(None)
    • innerOrElse

      val foa: F[Option[A]] = ...
      foa.innerOrElse[B >: A](Option[B]) // F[Option[B]]
      val foa: IO[Option[Int]] = IO.pure(Some(1))
      // IO[Option[Int]] = IO(Some(1))
      foa.innerOrElse(Some(0))
      // IO[Option[Int]] = IO(Some(1))
      
      val foa2: IO[Option[Int]] = IO.pure(None)
      // IO[Option[Int]] = IO(None)
      foa2.innerOrElse(Some(0))
      // IO[Option[Int]] = IO(Some(0))
    • innerOrElseF

      val foa: F[Option[A]] = ...
      foa.innerOrElse[B >: A](F[Option[B]]) // F[Option[B]]
      val foa: IO[Option[Int]] = IO.pure(Some(1))
      // IO[Option[Int]] = IO(Some(1))
      foa.innerOrElse(IO.pure(Some(0)))
      // IO[Option[Int]] = IO(Some(1))
      
      val foa2: IO[Option[Int]] = IO.pure(None)
      // IO[Option[Int]] = IO(None)
      foa2.innerOrElse(IO.pure(Some(0)))
      // IO[Option[Int]] = IO(Some(0))
  • Add innerFind, innerFilterOrElse, innerExists, innerForall, innerContains, innerCollectFirst, innerOrElse and innerOrElseF extension methods to F[Either[A, B]] ([extras-cats] Add innerFind, innerFilterOrElse, innerExists, innerForall, innerContains, innerCollectFirst, innerOrElse and innerOrElseF extension methods to F[Either[A, B]] #362)

    • innerFind

      val feab: F[Either[A, B]] = ...
      feab.innerFind(B => Boolean): F[Option[B]]
      val feab: IO[Either[String, Int]] = IO(Right(1))
      // IO[Either[String, Int]] = IO(Right(1))
      feab.innerFind(_ > 0)
      // IO[Option[Int]] = IO(Some(1))
      feab.innerFind(_ > 1)
      // IO[Option[Int]] = IO(None)
    • innerFilterOrElse

      val feab: F[Either[A, B]] = ...
      feab.innerFilterOrElse[C >: A](B => Boolean, C): F[Either[C, B]]
      val feab: IO[Either[String, Int]] = IO(Right(1))
      // IO[Either[String, Int]] = IO(Right(1))
      feab.innerFilterOrElse(_ > 0, "Error")
      // IO[Either[String, Int]] = IO(Right(1))
      feab.innerFilterOrElse(_ > 1, "Error")
      // IO[Either[String, Int]] = IO(Left("Error"))
    • innerExists

      val feab: F[Either[A, B]] = ...
      feab.innerExists(B => Boolean): F[Boolean]
      val feab: IO[Either[String, Int]] = IO(Right(1))
      // IO[Either[String, Int]] = IO(Right(1))
      feab.innerExists(_ > 0)
      // IO[Boolean] = IO(true)
      feab.innerExists(_ > 1)
      // IO[Boolean] = IO(false)
    • innerForall

      val feab: F[Either[A, B]] = ...
      feab.innerForall(B => Boolean): F[Boolean]
      val feab: IO[Either[String, Int]] = IO(Right(1))
      // IO[Either[String, Int]] = IO(Right(1))
      feab.innerForall(_ > 0)
      // IO[Boolean] = IO(true)
      feab.innerForall(_ > 1)
      // IO[Boolean] = IO(false)
      
      val feab2: IO[Either[String, Int]] = IO(Left("Error"))
      // IO[Either[String, Int]] = IO(Left("Error"))
      feab2.innerForall(_ > 1)
      // IO[Boolean] = IO(true)
    • innerContains

      val feab: F[Either[A, B]] = ...
      feab.innerContains(B): F[Boolean]
      val feab: IO[Either[String, Int]] = IO(Right(1))
      // IO[Either[String, Int]] = IO(Right(1))
      feab.innerContains(1)
      // IO[Boolean] = IO(true)
      feab.innerContains(0)
      // IO[Boolean] = IO(false)
      
      val feab2: IO[Either[String, Int]] = IO(Left("Error"))
      // IO[Either[String, Int]] = IO(Left("Error"))
      feab2.innerContains(1)
      // IO[Boolean] = IO(false)
    • innerCollectFirst

      val feab: F[Either[A, B]] = ...
      feab.innerCollectFirst[D](PartialFunction[B, D]): F[Option[D]]
      val feab: IO[Either[String, Int]] = IO(Right(1))
      // IO[Either[String, Int]] = IO(Right(1))
      feab.innerCollectFirst {
        case 1 => 0
        case 2 => 999
      }
      // IO[Option[Int]] = IO(Some(0))
      
      val feab2: IO[Either[String, Int]] = IO(Right(2))
      // IO[Either[String, Int]] = IO(Right(2))
      feab2.innerCollectFirst {
        case 1 => 0
        case 2 => 999
      }
      // IO[Option[Int]] = IO(Some(999))
      
      val feab3: IO[Either[String, Int]] = IO(Right(3))
      // IO[Either[String, Int]] = IO(Right(3))
      feab3.innerCollectFirst {
        case 1 => 0
        case 2 => 999
      }
      // IO[Option[Int]] = IO(None)
      
      val feab4: IO[Either[String, Int]] = IO(Left("Error"))
      // IO[Either[String, Int]] = IO(Left("Error"))
      feab4.innerCollectFirst {
        case 1 => 0
        case 2 => 999
      }
      // IO[Option[Int]] = IO(None)
    • innerOrElse

      val feab: F[Either[A, B]] = ...
      feab.innerOrElse[C >: A, D >: B](=> Either[C, D]): F[Either[C, D]]
      val feab: IO[Either[String, Int]] = IO(Right(1))
      // IO[Either[String, Int]] = IO(Right(1))
      feab.innerOrElse(0.asRight[String])
      // IO[Option[Int]] = IO(Some(1))
      
      val feab2: IO[Either[String, Int]] = IO(Left("Error"))
      // IO[Either[String, Int]] = IO(Left("Error"))
      feab2.innerOrElse(0.asRight[String])
      // IO[Option[Int]] = IO(Some(0))
    • innerOrElseF

      val feab: F[Either[A, B]] = ...
      feab.innerOrElseF[C >: A, D >: B](=> F[Either[C, D]]): F[Either[C, D]]
      val feab: IO[Either[String, Int]] = IO(Right(1))
      // IO[Either[String, Int]] = IO(Right(1))
      feab.innerOrElseF(IO.pure(0.asRight[String]))
      // IO[Option[Int]] = IO(Some(1))
      
      val feab2: IO[Either[String, Int]] = IO(Left("Error"))
      // IO[Either[String, Int]] = IO(Left("Error"))
      feab2.innerOrElseF(IO.pure(0.asRight[String]))
      // IO[Option[Int]] = IO(Some(0))
  • [extras-cats] Add tests for all new extension methods in AllSyntax inherited from OptionSyntax and EitherSyntax ([extras-cats] Add tests for all new extension methods in AllSyntax inherited from OptionSyntax and EitherSyntax #366)

@kevin-lee kevin-lee added this to the milestone37 milestone Mar 12, 2023
@kevin-lee kevin-lee self-assigned this Mar 12, 2023
@github-actions github-actions bot added pr release Release labels Mar 12, 2023
@codecov
Copy link

codecov bot commented Mar 12, 2023

Codecov Report

❗ No coverage uploaded for pull request base (main@0d6c8ce). Click here to learn what that means.
Patch has no changes to coverable lines.

Additional details and impacted files
@@           Coverage Diff           @@
##             main     #365   +/-   ##
=======================================
  Coverage        ?   89.27%           
=======================================
  Files           ?       39           
  Lines           ?      606           
  Branches        ?       28           
=======================================
  Hits            ?      541           
  Misses          ?       65           
  Partials        ?        0           

Help us with your feedback. Take ten seconds to tell us how you rate us. Have a feature suggestion? Share it here.

☔ View full report in Codecov by Sentry.
📢 Do you have feedback about the report comment? Let us know in this issue.

@kevin-lee kevin-lee marked this pull request as ready for review March 12, 2023 06:42
@kevin-lee kevin-lee merged commit eca970f into main Mar 12, 2023
@kevin-lee kevin-lee deleted the prepare-to-release branch March 12, 2023 06:57
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant