From aee6b392402832fcfc674bd52d79492c416b5514 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bj=C3=B8rn=20Madsen?= Date: Tue, 3 Oct 2017 19:04:13 +0200 Subject: [PATCH 1/6] Rename EitherT.liftT to EitherT.liftF To be consistent with OptionT.liftF. --- core/src/main/scala/cats/ApplicativeError.scala | 2 +- core/src/main/scala/cats/data/EitherT.scala | 6 +++--- docs/src/main/tut/datatypes/eithert.md | 2 +- 3 files changed, 5 insertions(+), 5 deletions(-) diff --git a/core/src/main/scala/cats/ApplicativeError.scala b/core/src/main/scala/cats/ApplicativeError.scala index ff2fd40a46..7e2b9171b8 100644 --- a/core/src/main/scala/cats/ApplicativeError.scala +++ b/core/src/main/scala/cats/ApplicativeError.scala @@ -93,7 +93,7 @@ trait ApplicativeError[F[_], E] extends Applicative[F] { * scala> type F[A] = EitherT[State[String, ?], Err, A] * * scala> val action: PartialFunction[Err, F[Unit]] = { - * | case Err("one") => EitherT.liftT(State.set("one")) + * | case Err("one") => EitherT.liftF(State.set("one")) * | } * * scala> val prog1: F[Int] = (Err("one")).raiseError[F, Int] diff --git a/core/src/main/scala/cats/data/EitherT.scala b/core/src/main/scala/cats/data/EitherT.scala index 1e77edadf2..0bb84de5cd 100644 --- a/core/src/main/scala/cats/data/EitherT.scala +++ b/core/src/main/scala/cats/data/EitherT.scala @@ -339,13 +339,13 @@ object EitherT extends EitherTInstances { * scala> import cats.implicits._ * scala> val o: Option[Int] = Some(3) * scala> val n: Option[Int] = None - * scala> EitherT.liftT(o) + * scala> EitherT.liftF(o) * res0: cats.data.EitherT[Option,Nothing,Int] = EitherT(Some(Right(3))) - * scala> EitherT.liftT(n) + * scala> EitherT.liftF(n) * res1: cats.data.EitherT[Option,Nothing,Int] = EitherT(None) * }}} */ - final def liftT[F[_], A, B](fb: F[B])(implicit F: Functor[F]): EitherT[F, A, B] = right(fb) + final def liftF[F[_], A, B](fb: F[B])(implicit F: Functor[F]): EitherT[F, A, B] = right(fb) /** Transforms an `Either` into an `EitherT`, lifted into the specified `Applicative`. * diff --git a/docs/src/main/tut/datatypes/eithert.md b/docs/src/main/tut/datatypes/eithert.md index 7d2af23966..ed750e9aae 100644 --- a/docs/src/main/tut/datatypes/eithert.md +++ b/docs/src/main/tut/datatypes/eithert.md @@ -105,7 +105,7 @@ val error: EitherT[Option, String, Int] = EitherT.leftT("Not a number") ## From `F[A]` or `F[B]` to `EitherT[F, A, B]` Similary, use `EitherT.left` and `EitherT.right` to convert an `F[A]` or an `F[B]` -into an `EitherT`. It is also possible to use `EitherT.liftT` as an alias for +into an `EitherT`. It is also possible to use `EitherT.liftF` as an alias for `EitherT.right`. ```tut:silent From 8b5df3f8b4f4e74820b3dd720e089ee7017dce8d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bj=C3=B8rn=20Madsen?= Date: Tue, 3 Oct 2017 19:04:13 +0200 Subject: [PATCH 2/6] Re-add liftT with a @deprecated notice --- core/src/main/scala/cats/data/EitherT.scala | 3 +++ 1 file changed, 3 insertions(+) diff --git a/core/src/main/scala/cats/data/EitherT.scala b/core/src/main/scala/cats/data/EitherT.scala index 0bb84de5cd..f10c6c214c 100644 --- a/core/src/main/scala/cats/data/EitherT.scala +++ b/core/src/main/scala/cats/data/EitherT.scala @@ -347,6 +347,9 @@ object EitherT extends EitherTInstances { */ final def liftF[F[_], A, B](fb: F[B])(implicit F: Functor[F]): EitherT[F, A, B] = right(fb) + @deprecated("Use EitherT.liftF.", "1.0.0-MF") + final def liftT[F[_], A, B](fb: F[B])(implicit F: Functor[F]): EitherT[F, A, B] = right(fb) + /** Transforms an `Either` into an `EitherT`, lifted into the specified `Applicative`. * * Note: The return type is a FromEitherPartiallyApplied[F], which has an apply method From 6395fdcd77b8b6455c7887c1cea0fd2dd37ab73a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bj=C3=B8rn=20Madsen?= Date: Tue, 3 Oct 2017 19:04:13 +0200 Subject: [PATCH 3/6] Add scalafix rule for renaming EitherT.liftT --- scalafix/README.md | 2 ++ .../scala/fix/v1_0_0/RenameEitherTLiftT.scala | 15 +++++++++++++++ .../scala/fix/v1_0_0/RenameEitherTLiftT.scala | 12 ++++++++++++ .../rules/src/main/scala/fix/Cats_v1_0_0.scala | 11 +++++++++++ 4 files changed, 40 insertions(+) create mode 100644 scalafix/input/src/main/scala/fix/v1_0_0/RenameEitherTLiftT.scala create mode 100644 scalafix/output/src/main/scala/fix/v1_0_0/RenameEitherTLiftT.scala diff --git a/scalafix/README.md b/scalafix/README.md index 744d657a71..eb67618294 100644 --- a/scalafix/README.md +++ b/scalafix/README.md @@ -20,6 +20,8 @@ sbt scalafix github:typelevel/cats/v1.0.0 - [x] The creation methods (left, right, apply, pure, etc.) in EitherT were improved to take less type arguments. +- [x] EitherT.liftT was renamed to EitherT.liftF + - [x] CartesianBuilder (i.e. |@|) syntax is deprecated, use the apply syntax on tuples instead. E.g. (x |@| y |@| z).map(...) should be replaced by (x, y, z).mapN(...) - [x] Free.suspend is renamed to Free.defer for consistency. diff --git a/scalafix/input/src/main/scala/fix/v1_0_0/RenameEitherTLiftT.scala b/scalafix/input/src/main/scala/fix/v1_0_0/RenameEitherTLiftT.scala new file mode 100644 index 0000000000..f4417bcf6c --- /dev/null +++ b/scalafix/input/src/main/scala/fix/v1_0_0/RenameEitherTLiftT.scala @@ -0,0 +1,15 @@ +/* +rule = "scala:fix.v1_0_0.RenameEitherTLiftT" + */ +package fix +package to1_0_0 + +object RenameEitherTLiftTTests { + import cats.instances.option._ + import cats.data._ + import cats.data.EitherT._ + + val fa: Option[Int] = Some(42) + val et1: EitherT[Option, Nothing, Int] = EitherT.liftT(fa) + val et2: EitherT[Option, Nothing, Int] = liftT(fa) +} \ No newline at end of file diff --git a/scalafix/output/src/main/scala/fix/v1_0_0/RenameEitherTLiftT.scala b/scalafix/output/src/main/scala/fix/v1_0_0/RenameEitherTLiftT.scala new file mode 100644 index 0000000000..1d165a8723 --- /dev/null +++ b/scalafix/output/src/main/scala/fix/v1_0_0/RenameEitherTLiftT.scala @@ -0,0 +1,12 @@ +package fix +package to1_0_0 + +object RenameEitherTLiftTTests { + import cats.instances.option._ + import cats.data._ + import cats.data.EitherT._ + + val fa: Option[Int] = Some(42) + val et1: EitherT[Option, Nothing, Int] = EitherT.liftF(fa) + val et2: EitherT[Option, Nothing, Int] = liftF(fa) +} \ No newline at end of file diff --git a/scalafix/rules/src/main/scala/fix/Cats_v1_0_0.scala b/scalafix/rules/src/main/scala/fix/Cats_v1_0_0.scala index 8cc86d5aef..f6ec28bcb1 100644 --- a/scalafix/rules/src/main/scala/fix/Cats_v1_0_0.scala +++ b/scalafix/rules/src/main/scala/fix/Cats_v1_0_0.scala @@ -197,3 +197,14 @@ case class RemoveSplit(index: SemanticdbIndex) } } + +// ref: https://github.com/typelevel/cats/pull/1947 +case class RenameEitherTLiftT(index: SemanticdbIndex) + extends SemanticRule(index, "RenameEitherTLiftT") { + + override def fix(ctx: RuleCtx): Patch = + ctx.replaceSymbols( + "_root_.cats.data.EitherTFunctions.liftT." -> "liftF" + ) + +} \ No newline at end of file From 6a5f81f591691bed4d96ddf9ae90940ace0c10c2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bj=C3=B8rn=20Madsen?= Date: Wed, 4 Oct 2017 12:28:14 +0200 Subject: [PATCH 4/6] Set deprecated since to 1.0.0-RC1 --- core/src/main/scala/cats/data/EitherT.scala | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/core/src/main/scala/cats/data/EitherT.scala b/core/src/main/scala/cats/data/EitherT.scala index f10c6c214c..b0f8094eb0 100644 --- a/core/src/main/scala/cats/data/EitherT.scala +++ b/core/src/main/scala/cats/data/EitherT.scala @@ -347,7 +347,7 @@ object EitherT extends EitherTInstances { */ final def liftF[F[_], A, B](fb: F[B])(implicit F: Functor[F]): EitherT[F, A, B] = right(fb) - @deprecated("Use EitherT.liftF.", "1.0.0-MF") + @deprecated("Use EitherT.liftF.", "1.0.0-RC1") final def liftT[F[_], A, B](fb: F[B])(implicit F: Functor[F]): EitherT[F, A, B] = right(fb) /** Transforms an `Either` into an `EitherT`, lifted into the specified `Applicative`. From e248c156f3ad6fdbc6ef1dab2ca93fdb94d5141d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bj=C3=B8rn=20Madsen?= Date: Wed, 4 Oct 2017 13:13:39 +0200 Subject: [PATCH 5/6] Update scalafix readme --- scalafix/README.md | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/scalafix/README.md b/scalafix/README.md index eb67618294..e357000b2a 100644 --- a/scalafix/README.md +++ b/scalafix/README.md @@ -14,6 +14,14 @@ run sbt scalafix github:typelevel/cats/v1.0.0 ``` +to run all rules that apply to version `1.0.0`. + +If you only want to run the rules that apply to version `1.0.0-MF` run + +```sh +sbt scalafix github:typelevel/cats/v1.0.0?sha=c131fe4 +``` + ## Available rules - [x] All Unapply enabled methods, e.g. sequenceU, traverseU, etc. are removed. Unapply enabled syntax ops are also removed. Please use the partial unification SI-2712 fix instead. The easiest way might be this sbt-plugin. From fa520d7f60ea3d1d5b15fe994fe30d517106f635 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bj=C3=B8rn=20Madsen?= Date: Wed, 4 Oct 2017 16:50:57 +0200 Subject: [PATCH 6/6] Update scalafix readme --- scalafix/README.md | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) diff --git a/scalafix/README.md b/scalafix/README.md index e357000b2a..32a70de462 100644 --- a/scalafix/README.md +++ b/scalafix/README.md @@ -8,18 +8,16 @@ Install the scalafix sbt plugin (globally or in a specific project): addSbtPlugin("ch.epfl.scala" % "sbt-scalafix" % "0.5.0-RC2") ``` -run +to run all rules that apply to version `1.0.0-MF` run ```sh -sbt scalafix github:typelevel/cats/v1.0.0 +sbt scalafix github:typelevel/cats/v1.0.0?sha=c131fe4 ``` -to run all rules that apply to version `1.0.0`. - -If you only want to run the rules that apply to version `1.0.0-MF` run +to run all rules that apply to the current `1.0.0-SNAPSHOT` run ```sh -sbt scalafix github:typelevel/cats/v1.0.0?sha=c131fe4 +sbt scalafix github:typelevel/cats/v1.0.0 ``` ## Available rules