Skip to content

Commit 3e8eaba

Browse files
committed
Try to be clever, replicateA doesn't need by-name
1 parent f47d50d commit 3e8eaba

File tree

1 file changed

+9
-7
lines changed

1 file changed

+9
-7
lines changed

core/src/main/scala/cats/syntax/applicative.scala

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -25,26 +25,28 @@ package syntax
2525
trait ApplicativeSyntax {
2626
implicit final def catsSyntaxApplicativeId[A](a: A): ApplicativeIdOps[A] =
2727
new ApplicativeIdOps[A](a)
28+
implicit final def catsSyntaxApplicative[F[_], A](fa: F[A]): ApplicativeOps[F, A] =
29+
new ApplicativeOps[F, A](fa)
2830
implicit final def catsSyntaxApplicativeByName[F[_], A](fa: => F[A]): ApplicativeByNameOps[F, A] =
2931
new ApplicativeByNameOps[F, A](() => fa)
30-
@deprecated("Use by-name version", "2.8.0")
31-
final def catsSyntaxApplicative[F[_], A](fa: F[A]): ApplicativeOps[F, A] =
32-
new ApplicativeOps[F, A](fa)
3332
}
3433

3534
final class ApplicativeIdOps[A](private val a: A) extends AnyVal {
3635
def pure[F[_]](implicit F: Applicative[F]): F[A] = F.pure(a)
3736
}
3837

39-
@deprecated("Use by-name version", "2.8.0")
4038
final class ApplicativeOps[F[_], A](private val fa: F[A]) extends AnyVal {
4139
def replicateA(n: Int)(implicit F: Applicative[F]): F[List[A]] = F.replicateA(n, fa)
42-
def unlessA(cond: Boolean)(implicit F: Applicative[F]): F[Unit] = F.unlessA(cond)(fa)
43-
def whenA(cond: Boolean)(implicit F: Applicative[F]): F[Unit] = F.whenA(cond)(fa)
40+
}
41+
42+
object ApplicativeOps {
43+
@deprecated("Use by-name version", "2.8.0")
44+
def unlessA$extension[F[_], A](fa: F[A], cond: Boolean, F: Applicative[F]): F[Unit] = F.unlessA(cond)(fa)
45+
@deprecated("Use by-name version", "2.8.0")
46+
def whenA$extension[F[_], A](fa: F[A], cond: Boolean, F: Applicative[F]): F[Unit] = F.whenA(cond)(fa)
4447
}
4548

4649
final class ApplicativeByNameOps[F[_], A](private val fa: () => F[A]) extends AnyVal {
47-
def replicateA(n: Int)(implicit F: Applicative[F]): F[List[A]] = F.replicateA(n, fa())
4850
def unlessA(cond: Boolean)(implicit F: Applicative[F]): F[Unit] = F.unlessA(cond)(fa())
4951
def whenA(cond: Boolean)(implicit F: Applicative[F]): F[Unit] = F.whenA(cond)(fa())
5052
}

0 commit comments

Comments
 (0)