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

whenM #4626

Draft
wants to merge 3 commits into
base: main
Choose a base branch
from
Draft

whenM #4626

wants to merge 3 commits into from

Conversation

nikiforo
Copy link
Contributor

No description provided.

@nikiforo nikiforo changed the title whenM DRAFT: whenM Jun 18, 2024
@nikiforo nikiforo marked this pull request as draft June 18, 2024 11:12
@nikiforo nikiforo changed the title DRAFT: whenM whenM Jun 18, 2024
@nikiforo
Copy link
Contributor Author

whenM should have call-by-name argument F[A] as in whenA(#4207). Otherwise, it might lead to memory leaks typelevel/fs2#2412

Comment on lines +176 to +177
def whenM[A](f: F[A])(cond: F[Boolean]): F[Unit] =
flatMap(cond)(bool => if (bool) void(f) else unit)
Copy link
Member

Choose a reason for hiding this comment

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

Just to promote Mouse, you may be interested to glance at this syntax
https://github.com/typelevel/mouse/blob/main/shared/src/main/scala/mouse/boolean.scala#L73
It covers whenA and unlessA for boolean values.

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