Skip to content

Commit eb7edd9

Browse files
author
Jacob Barber
committed
Update deprecations, method name
1 parent 37cd5cf commit eb7edd9

8 files changed

Lines changed: 51 additions & 50 deletions

File tree

core/src/main/scala/cats/Apply.scala

Lines changed: 15 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -18,42 +18,43 @@ trait Apply[F[_]] extends Functor[F] with Semigroupal[F] with ApplyArityFunction
1818
def ap[A, B](ff: F[A => B])(fa: F[A]): F[B]
1919

2020
/** Compose two actions, discarding any value produced by the first. */
21-
def apR[A, B](fa: F[A])(fb: F[B]): F[B] =
21+
def productR[A, B](fa: F[A])(fb: F[B]): F[B] =
2222
map2(fa, fb)((_, b) => b)
2323

2424
/** Compose two actions, discarding any value produced by the second. */
25-
def apL[A, B](fa: F[A])(fb: F[B]): F[A] =
25+
def productL[A, B](fa: F[A])(fb: F[B]): F[A] =
2626
map2(fa, fb)((a, _) => a)
2727

2828
override def product[A, B](fa: F[A], fb: F[B]): F[(A, B)] =
29-
ap(map(fa)(a => (b: B) => (a, b)))(fb)
29+
map2(fa, fb)((_, _))
3030

3131
/** Alias for [[ap]]. */
3232
@inline final def <*>[A, B](ff: F[A => B])(fa: F[A]): F[B] =
3333
ap(ff)(fa)
3434

35-
/** Alias for [[apR]]. */
35+
/** Alias for [[productR]]. */
3636
@inline final def *>[A, B](fa: F[A])(fb: F[B]): F[B] =
37-
apR(fa)(fb)
37+
productR(fa)(fb)
3838

39-
/** Alias for [[apL]]. */
39+
/** Alias for [[productL]]. */
4040
@inline final def <*[A, B](fa: F[A])(fb: F[B]): F[A] =
41-
apL(fa)(fb)
41+
productL(fa)(fb)
4242

43-
/** Alias for [[apR]]. */
44-
@deprecated("Use *> or apR instead.", "1.0.0")
43+
/** Alias for [[productR]]. */
44+
@deprecated("Use *> or apR instead.", "1.0.0-RC2")
4545
@noop @inline final def followedBy[A, B](fa: F[A])(fb: F[B]): F[B] =
46-
apR(fa)(fb)
46+
productR(fa)(fb)
4747

48-
/** Alias for [[apL]]. */
49-
@deprecated("Use <* or apL instead.", "1.0.0")
48+
/** Alias for [[productL]]. */
49+
@deprecated("Use <* or apL instead.", "1.0.0-RC2")
5050
@noop @inline final def forEffect[A, B](fa: F[A])(fb: F[B]): F[A] =
51-
apL(fa)(fb)
51+
productL(fa)(fb)
5252

5353
/**
5454
* ap2 is a binary version of ap, defined in terms of ap.
5555
*/
5656
def ap2[A, B, Z](ff: F[(A, B) => Z])(fa: F[A], fb: F[B]): F[Z] =
57+
5758
map(product(fa, product(fb, ff))) { case (a, (b, f)) => f(a, b) }
5859

5960
/**
@@ -62,7 +63,7 @@ trait Apply[F[_]] extends Functor[F] with Semigroupal[F] with ApplyArityFunction
6263
* map2 can be seen as a binary version of [[cats.Functor]]#map.
6364
*/
6465
def map2[A, B, Z](fa: F[A], fb: F[B])(f: (A, B) => Z): F[Z] =
65-
map(product(fa, fb)) { case (a, b) => f(a, b) }
66+
ap(map(fa)(a => (b: B) => f(a, b)))(fb)
6667

6768
/**
6869
* Similar to [[map2]] but uses [[Eval]] to allow for laziness in the `F[B]`

core/src/main/scala/cats/FlatMap.scala

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -44,28 +44,28 @@ import simulacrum.noop
4444

4545
/**
4646
* Sequentially compose two actions, discarding any value produced by the first. This variant of
47-
* [[apR]] also lets you define the evaluation strategy of the second action. For instance
47+
* [[productR]] also lets you define the evaluation strategy of the second action. For instance
4848
* you can evaluate it only ''after'' the first action has finished:
4949
*
5050
* {{{
5151
* scala> import cats.Eval
5252
* scala> import cats.implicits._
5353
* scala> val fa: Option[Int] = Some(3)
5454
* scala> def fb: Option[String] = Some("foo")
55-
* scala> fa.apREval(Eval.later(fb))
55+
* scala> fa.productREval(Eval.later(fb))
5656
* res0: Option[String] = Some(foo)
5757
* }}}
5858
*/
59-
def apREval[A, B](fa: F[A])(fb: Eval[F[B]]): F[B] = flatMap(fa)(_ => fb.value)
59+
def productREval[A, B](fa: F[A])(fb: Eval[F[B]]): F[B] = flatMap(fa)(_ => fb.value)
6060

61-
@deprecated("Use apREval instead.", "1.0.0")
62-
@noop def followedByEval[A, B](fa: F[A])(fb: Eval[F[B]]): F[B] = apREval(fa)(fb)
61+
@deprecated("Use apREval instead.", "1.0.0-RC2")
62+
@noop def followedByEval[A, B](fa: F[A])(fb: Eval[F[B]]): F[B] = productREval(fa)(fb)
6363

6464

6565

6666
/**
6767
* Sequentially compose two actions, discarding any value produced by the second. This variant of
68-
* [[apL]] also lets you define the evaluation strategy of the second action. For instance
68+
* [[productL]] also lets you define the evaluation strategy of the second action. For instance
6969
* you can evaluate it only ''after'' the first action has finished:
7070
*
7171
* {{{
@@ -74,18 +74,18 @@ import simulacrum.noop
7474
* scala> var count = 0
7575
* scala> val fa: Option[Int] = Some(3)
7676
* scala> def fb: Option[Unit] = Some(count += 1)
77-
* scala> fa.apLEval(Eval.later(fb))
77+
* scala> fa.productLEval(Eval.later(fb))
7878
* res0: Option[Int] = Some(3)
7979
* scala> assert(count == 1)
80-
* scala> none[Int].apLEval(Eval.later(fb))
80+
* scala> none[Int].productLEval(Eval.later(fb))
8181
* res1: Option[Int] = None
8282
* scala> assert(count == 1)
8383
* }}}
8484
*/
85-
def apLEval[A, B](fa: F[A])(fb: Eval[F[B]]): F[A] = flatMap(fa)(a => map(fb.value)(_ => a))
85+
def productLEval[A, B](fa: F[A])(fb: Eval[F[B]]): F[A] = flatMap(fa)(a => map(fb.value)(_ => a))
8686

87-
@deprecated("Use apLEval instead.", "1.0.0")
88-
@noop def forEffectEval[A, B](fa: F[A])(fb: Eval[F[B]]): F[A] = apLEval(fa)(fb)
87+
@deprecated("Use apLEval instead.", "1.0.0-RC2")
88+
@noop def forEffectEval[A, B](fa: F[A])(fb: Eval[F[B]]): F[A] = productLEval(fa)(fb)
8989

9090
override def ap[A, B](ff: F[A => B])(fa: F[A]): F[B] =
9191
flatMap(ff)(f => map(fa)(f))

core/src/main/scala/cats/Parallel.scala

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -29,25 +29,25 @@ trait NonEmptyParallel[M[_], F[_]] extends Serializable {
2929

3030

3131
/**
32-
* Like `Apply[F].apR`, but uses the apply instance
32+
* Like [[Apply.productR]], but uses the apply instance
3333
* corresponding to the Parallel instance instead.
3434
*/
35-
def parApR[A, B](ma: M[A])(mb: M[B]): M[B] =
35+
def parProductR[A, B](ma: M[A])(mb: M[B]): M[B] =
3636
Parallel.parMap2(ma, mb)((_, b) => b)(this)
3737

38-
@deprecated("Use parApR instead.", "1.0.0")
39-
@inline def parFollowedBy[A, B](ma: M[A])(mb: M[B]): M[B] = parApR(ma)(mb)
38+
@deprecated("Use parApR instead.", "1.0.0-RC2")
39+
@inline def parFollowedBy[A, B](ma: M[A])(mb: M[B]): M[B] = parProductR(ma)(mb)
4040

4141

4242
/**
43-
* Like `Apply[F].apL`, but uses the apply instance
43+
* Like [[Apply.productL]], but uses the apply instance
4444
* corresponding to the Parallel instance instead.
4545
*/
46-
def parApL[A, B](ma: M[A])(mb: M[B]): M[A] =
46+
def parProductL[A, B](ma: M[A])(mb: M[B]): M[A] =
4747
Parallel.parMap2(ma, mb)((a, _) => a)(this)
4848

49-
@deprecated("Use parApR instead.", "1.0.0")
50-
@inline def parForEffect[A, B](ma: M[A])(mb: M[B]): M[A] = parApL(ma)(mb)
49+
@deprecated("Use parApR instead.", "1.0.0-RC2")
50+
@inline def parForEffect[A, B](ma: M[A])(mb: M[B]): M[A] = parProductL(ma)(mb)
5151

5252
}
5353

core/src/main/scala/cats/instances/tuple.scala

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -123,10 +123,10 @@ private[instances] class FlatMapTuple2[X](s: Semigroup[X]) extends FlatMap[(X, ?
123123
(x, xb._2)
124124
}
125125

126-
override def apR[A, B](a: (X, A))(b: (X, B)): (X, B) =
126+
override def productR[A, B](a: (X, A))(b: (X, B)): (X, B) =
127127
(s.combine(a._1, b._1), b._2)
128128

129-
override def apL[A, B](a: (X, A))(b: (X, B)): (X, A) =
129+
override def productL[A, B](a: (X, A))(b: (X, B)): (X, A) =
130130
(s.combine(a._1, b._1), a._2)
131131

132132
override def mproduct[A, B](fa: (X, A))(f: A => (X, B)): (X, (A, B)) = {

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

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -15,13 +15,13 @@ trait ApplySyntax extends TupleSemigroupalSyntax {
1515
}
1616

1717
final class ApplyOps[F[_], A](val fa: F[A]) extends AnyVal {
18-
/** Alias for [[Apply.apR]]. */
19-
@deprecated("Use *> or apR instead.", "1.0.0")
18+
/** Alias for [[Apply.productR]]. */
19+
@deprecated("Use *> or apR instead.", "1.0.0-RC2")
2020
@inline def followedBy[B](fb: F[B])(implicit F: Apply[F]): F[B] =
21-
F.apR(fa)(fb)
21+
F.productR(fa)(fb)
2222

23-
/** Alias for [[Apply.apL]]. */
24-
@deprecated("Use <* or apL instead.", "1.0.0")
23+
/** Alias for [[Apply.productL]]. */
24+
@deprecated("Use <* or apL instead.", "1.0.0-RC2")
2525
@inline def forEffect[B](fb: F[B])(implicit F: Apply[F]): F[A] =
26-
F.apL(fa)(fb)
26+
F.productL(fa)(fb)
2727
}

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

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -33,16 +33,16 @@ final class FlatMapOps[F[_], A](val fa: F[A]) extends AnyVal {
3333
def >>[B](fb: => F[B])(implicit F: FlatMap[F]): F[B] = F.flatMap(fa)(_ => fb)
3434

3535
@deprecated("Use <* instead", "1.0.0-RC1")
36-
def <<[B](fb: F[B])(implicit F: FlatMap[F]): F[A] = F.apL(fa)(fb)
36+
def <<[B](fb: F[B])(implicit F: FlatMap[F]): F[A] = F.productL(fa)(fb)
3737

3838

39-
@deprecated("Use apREval instead.", "1.0.0")
39+
@deprecated("Use productREval instead.", "1.0.0-RC2")
4040
def followedByEval[B](fb: Eval[F[B]])(implicit F: FlatMap[F]): F[B] =
41-
F.apREval(fa)(fb)
41+
F.productREval(fa)(fb)
4242

43-
@deprecated("Use apLEval instead.", "1.0.0")
43+
@deprecated("Use productLEval instead.", "1.0.0-RC2")
4444
def forEffectEval[B](fb: Eval[F[B]])(implicit F: FlatMap[F]): F[A] =
45-
F.apLEval(fa)(fb)
45+
F.productLEval(fa)(fb)
4646
}
4747

4848
final class FlattenOps[F[_], A](val ffa: F[F[A]]) extends AnyVal {

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -32,9 +32,9 @@ final class ParallelSequenceOps[T[_], M[_], A](val tma: T[M[A]]) extends AnyVal
3232
final class ParallelApOps[M[_], A](val ma: M[A]) extends AnyVal {
3333

3434
def &>[F[_], B](mb: M[B])(implicit P: Parallel[M, F]): M[B] =
35-
P.parApR(ma)(mb)
35+
P.parProductR(ma)(mb)
3636

3737
def <&[F[_], B](mb: M[B])(implicit P: Parallel[M, F]): M[A] =
38-
P.parApL(ma)(mb)
38+
P.parProductL(ma)(mb)
3939

4040
}

laws/src/main/scala/cats/laws/ApplyLaws.scala

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,10 +22,10 @@ trait ApplyLaws[F[_]] extends FunctorLaws[F] with SemigroupalLaws[F] {
2222
F.map2(fa, fb)(f) <-> F.map2Eval(fa, Eval.now(fb))(f).value
2323

2424
def apRConsistency[A, B](fa: F[A], fb: F[B]): IsEq[F[B]] =
25-
F.apR(fa)(fb) <-> F.map2(fa, fb)((_, b) => b)
25+
F.productR(fa)(fb) <-> F.map2(fa, fb)((_, b) => b)
2626

2727
def apLConsistency[A, B](fa: F[A], fb: F[B]): IsEq[F[A]] =
28-
F.apL(fa)(fb) <-> F.map2(fa, fb)((a, _) => a)
28+
F.productL(fa)(fb) <-> F.map2(fa, fb)((a, _) => a)
2929
}
3030

3131
object ApplyLaws {

0 commit comments

Comments
 (0)