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

[draft] whenA alternative #4590

Closed
wants to merge 1 commit into from

Conversation

a-khakimov
Copy link

Comment on lines +266 to +267
def elseA[A](cond: Boolean)(f: => F[A])(other: => F[A]): F[A] =
if (cond) f else other
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This method does not seem doing anything with F[_] itself, so it looks like an implementation of a ternary operator, e.g.:

def x: F[A] = ???
def y: F[A] = ???

elseA(cond)(x)(y) <-> if (cond) x else y

In other words, this implementation does not seem related to Applicative (or any other typeclass in cats).

Besides, there's a convenience syntax in mouse:

import mouse.boolean.*

cond.fold(x, y)

@a-khakimov a-khakimov marked this pull request as draft April 21, 2024 05:49
@a-khakimov a-khakimov closed this Apr 21, 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

Successfully merging this pull request may close these issues.

2 participants