diff --git a/core/src/main/scala/cats/FlatMap.scala b/core/src/main/scala/cats/FlatMap.scala index 511c1186f2..94c0c2fe3c 100644 --- a/core/src/main/scala/cats/FlatMap.scala +++ b/core/src/main/scala/cats/FlatMap.scala @@ -117,6 +117,7 @@ import simulacrum.noop /** * `if` lifted into monad. */ + @noop def ifM[B](fa: F[Boolean])(ifTrue: => F[B], ifFalse: => F[B]): F[B] = flatMap(fa)(if (_) ifTrue else ifFalse) diff --git a/core/src/main/scala/cats/Functor.scala b/core/src/main/scala/cats/Functor.scala index cbc3feb559..ea5f34a4f9 100644 --- a/core/src/main/scala/cats/Functor.scala +++ b/core/src/main/scala/cats/Functor.scala @@ -173,6 +173,7 @@ import simulacrum.{noop, typeclass} * res0: List[Int] = List(1, 0, 0) * }}} */ + @noop def ifF[A](fb: F[Boolean])(ifTrue: => A, ifFalse: => A): F[A] = map(fb)(x => if (x) ifTrue else ifFalse) def compose[G[_]: Functor]: Functor[λ[α => F[G[α]]]] = diff --git a/core/src/main/scala/cats/Monad.scala b/core/src/main/scala/cats/Monad.scala index 84832e84fa..c18ff015f7 100644 --- a/core/src/main/scala/cats/Monad.scala +++ b/core/src/main/scala/cats/Monad.scala @@ -1,6 +1,6 @@ package cats -import simulacrum.typeclass +import simulacrum.{noop, typeclass} /** * Monad. @@ -22,6 +22,7 @@ import simulacrum.typeclass * This implementation uses append on each evaluation result, * so avoid data structures with non-constant append performance, e.g. `List`. */ + @noop def whileM[G[_], A](p: F[Boolean])(body: => F[A])(implicit G: Alternative[G]): F[G[A]] = { val b = Eval.later(body) tailRecM[G[A], G[A]](G.empty)(xs => @@ -41,6 +42,7 @@ import simulacrum.typeclass * returns `true`. The condition is evaluated before the loop body. * Discards results. */ + @noop def whileM_[A](p: F[Boolean])(body: => F[A]): F[Unit] = { val continue: Either[Unit, Unit] = Left(()) val stop: F[Either[Unit, Unit]] = pure(Right(()))