Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Rename EitherT.liftT to EitherT.liftF #1947

Merged
merged 6 commits into from
Oct 10, 2017
Merged
Show file tree
Hide file tree
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion core/src/main/scala/cats/ApplicativeError.scala
Original file line number Diff line number Diff line change
Expand Up @@ -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]
Expand Down
7 changes: 5 additions & 2 deletions core/src/main/scala/cats/data/EitherT.scala
Original file line number Diff line number Diff line change
Expand Up @@ -339,12 +339,15 @@ 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 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")
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should this version be "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`.
Expand Down
2 changes: 1 addition & 1 deletion docs/src/main/tut/datatypes/eithert.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 2 additions & 0 deletions scalafix/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
15 changes: 15 additions & 0 deletions scalafix/input/src/main/scala/fix/v1_0_0/RenameEitherTLiftT.scala
Original file line number Diff line number Diff line change
@@ -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)
}
12 changes: 12 additions & 0 deletions scalafix/output/src/main/scala/fix/v1_0_0/RenameEitherTLiftT.scala
Original file line number Diff line number Diff line change
@@ -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)
}
11 changes: 11 additions & 0 deletions scalafix/rules/src/main/scala/fix/Cats_v1_0_0.scala
Original file line number Diff line number Diff line change
Expand Up @@ -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"
)

}