From b163e77075e618ca9b70153ed0a7804fdac757dc Mon Sep 17 00:00:00 2001 From: "P. Oscar Boykin" Date: Sat, 5 May 2018 11:29:40 -1000 Subject: [PATCH] Use unit from Applicative (#2246) --- core/src/main/scala/cats/Alternative.scala | 2 +- core/src/main/scala/cats/Applicative.scala | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/core/src/main/scala/cats/Alternative.scala b/core/src/main/scala/cats/Alternative.scala index 4531153299..126436115d 100644 --- a/core/src/main/scala/cats/Alternative.scala +++ b/core/src/main/scala/cats/Alternative.scala @@ -54,7 +54,7 @@ import simulacrum.typeclass * }}} */ def guard(condition: Boolean): F[Unit] = - if (condition) pure(()) else empty + if (condition) unit else empty override def compose[G[_]: Applicative]: Alternative[λ[α => F[G[α]]]] = new ComposedAlternative[F, G] { diff --git a/core/src/main/scala/cats/Applicative.scala b/core/src/main/scala/cats/Applicative.scala index 0a6a3fa937..fd9d0c6b0c 100644 --- a/core/src/main/scala/cats/Applicative.scala +++ b/core/src/main/scala/cats/Applicative.scala @@ -161,7 +161,7 @@ import simulacrum.typeclass * }}} */ def unlessA[A](cond: Boolean)(f: => F[A]): F[Unit] = - if (cond) pure(()) else void(f) + if (cond) unit else void(f) /** * Returns the given argument (mapped to Unit) if `cond` is `true`, otherwise, @@ -185,7 +185,7 @@ import simulacrum.typeclass * }}} */ def whenA[A](cond: Boolean)(f: => F[A]): F[Unit] = - if (cond) void(f) else pure(()) + if (cond) void(f) else unit }