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

Adding an alternative version of the method whenA with a different signature #4589

Closed
a-khakimov opened this issue Apr 19, 2024 · 0 comments
Closed

Comments

@a-khakimov
Copy link

Currently, the cats has a syntax whenA with the signature:

def whenA(cond: Boolean)(implicit F: Applicative[F]): F[Unit]

However, it would be beneficial to add an alternative version of this syntax to allow returning a result of type F[A] if the condition is true, and otherwise returning a default value.

Proposed Signature:

def whenA[A](cond: Boolean)(default: F[A])(implicit F: Applicative[F]): F[A]

It is possible with a different name.

This syntax will provide more flexibility in using conditional expressions

a-khakimov pushed a commit to a-khakimov/cats that referenced this issue Apr 19, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant