Skip to content

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