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 innerFilter, innerExists, innerContains, innerForall, innerCollect, innerOrElse and innerOrElseF extension methods to F[Option[A]] #360

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

Comments

@kevin-lee
Copy link
Owner

kevin-lee commented Mar 11, 2023

Task

Summary

[extras-cats] Add innerFilter, innerExists, innerContains, innerForall, innerCollect, innerOrElse and innerOrElseF extension methods to F[Option[A]]

Project Details

Version: 0.35.0

Description

  • 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))
@kevin-lee kevin-lee added the task Task label Mar 11, 2023
@kevin-lee kevin-lee added this to the milestone37 milestone Mar 11, 2023
@kevin-lee kevin-lee self-assigned this Mar 11, 2023
@kevin-lee kevin-lee changed the title [extras-cats] Add innerFilter, innerExists, innerContains, innerForall, innerCollect, innerOrElse and innerOrElseF extension method to F[Option[A]] [extras-cats] Add innerFilter, innerExists, innerContains, innerForall, innerCollect, innerOrElse and innerOrElseF extension methods to F[Option[A]] Mar 11, 2023
kevin-lee added a commit that referenced this issue Mar 11, 2023
…s, innerForall, innerCollect, innerOrElse and innerOrElseF extension methods to F[Option[A]]
kevin-lee added a commit that referenced this issue Mar 11, 2023
…s, innerForall, innerCollect, innerOrElse and innerOrElseF extension methods to F[Option[A]]
kevin-lee added a commit that referenced this issue Mar 11, 2023
…s, innerForall, innerCollect, innerOrElse and innerOrElseF extension methods to F[Option[A]]
kevin-lee added a commit that referenced this issue Mar 11, 2023
…FOptionA

Close #360 - [`extras-cats`] Add `innerFilter`, `innerExists`, `innerContains`, `innerForall`, `innerCollect`, `innerOrElse` and `innerOrElseF` extension methods to `F[Option[A]]`
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment