Skip to content

Commit

Permalink
Use unit from Applicative (#2246)
Browse files Browse the repository at this point in the history
  • Loading branch information
johnynek authored and kailuowang committed May 5, 2018
1 parent eba9a59 commit b163e77
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 3 deletions.
2 changes: 1 addition & 1 deletion core/src/main/scala/cats/Alternative.scala
Expand Up @@ -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] {
Expand Down
4 changes: 2 additions & 2 deletions core/src/main/scala/cats/Applicative.scala
Expand Up @@ -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,
Expand All @@ -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

}

Expand Down

0 comments on commit b163e77

Please sign in to comment.