diff --git a/core/src/main/scala/cats/Monad.scala b/core/src/main/scala/cats/Monad.scala index c694f854e3..9a07f68aef 100644 --- a/core/src/main/scala/cats/Monad.scala +++ b/core/src/main/scala/cats/Monad.scala @@ -162,6 +162,12 @@ trait Monad[F[_]] extends FlatMap[F] with Applicative[F] { tailRecM(branches.toList)(step) } + def whenM[A](cond: F[Boolean])(f: => F[A]): F[Unit] = + ifM(cond)(ifTrue = void(f), ifFalse = unit) + + def unlessM[A](cond: F[Boolean])(f: => F[A]): F[Unit] = + ifM(cond)(ifTrue = unit, ifFalse = void(f)) + /** * Modifies the `A` value in `F[A]` with the supplied function, if the function is defined for the value. * Example: