-
-
Notifications
You must be signed in to change notification settings - Fork 1.2k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add RenameTupleApplySyntax Scalafix rewrite
- Loading branch information
Showing
4 changed files
with
85 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
31 changes: 31 additions & 0 deletions
31
scalafix/input/src/main/scala/fix/v1_0_0/RenameTupleApplySyntax.scala
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
/* | ||
rewrite = "scala:fix.v1_0_0.RenameTupleApplySyntax" | ||
*/ | ||
package fix | ||
package to1_0_0 | ||
|
||
object RenameTupleApplySyntaxTests { | ||
import cats.{Eq, Semigroup} | ||
import cats.instances.all._ | ||
import cats.syntax.tuple._ | ||
|
||
(Option(1), Option(2)).map2(_ + _) | ||
(Option(1), Option(2), Option(3)).map3(_ + _ + _) | ||
(Option(1), Option(2), Option(3), Option(4)).map4(_ + _ + _ + _) | ||
|
||
case class Foo2(a: Int, b: Int) | ||
case class Foo3(a: Int, b: Int, c: Int) | ||
case class Foo4(a: Int, b: Int, c: Int, d: Int) | ||
|
||
(Eq[Int], Eq[Int]).contramap2((f: Foo2) => (f.a, f.b)) | ||
(Eq[Int], Eq[Int], Eq[Int]).contramap3((f: Foo3) => (f.a, f.b, f.c)) | ||
(Eq[Int], Eq[Int], Eq[Int], Eq[Int]).contramap4((f: Foo4) => | ||
(f.a, f.b, f.c, f.d)) | ||
|
||
(Semigroup[Int], Semigroup[Int]) | ||
.imap2(Foo2.apply)(Function.unlift(Foo2.unapply)) | ||
(Semigroup[Int], Semigroup[Int], Semigroup[Int]) | ||
.imap3(Foo3.apply)(Function.unlift(Foo3.unapply)) | ||
(Semigroup[Int], Semigroup[Int], Semigroup[Int], Semigroup[Int]) | ||
.imap4(Foo4.apply)(Function.unlift(Foo4.unapply)) | ||
} |
28 changes: 28 additions & 0 deletions
28
scalafix/output/src/main/scala/fix/v1_0_0/RenameTupleApplySyntax.scala
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
package fix | ||
package to1_0_0 | ||
|
||
object RenameTupleApplySyntaxTests { | ||
import cats.{Eq, Semigroup} | ||
import cats.instances.all._ | ||
import cats.syntax.apply._ | ||
|
||
(Option(1), Option(2)).mapN(_ + _) | ||
(Option(1), Option(2), Option(3)).mapN(_ + _ + _) | ||
(Option(1), Option(2), Option(3), Option(4)).mapN(_ + _ + _ + _) | ||
|
||
case class Foo2(a: Int, b: Int) | ||
case class Foo3(a: Int, b: Int, c: Int) | ||
case class Foo4(a: Int, b: Int, c: Int, d: Int) | ||
|
||
(Eq[Int], Eq[Int]).contramapN((f: Foo2) => (f.a, f.b)) | ||
(Eq[Int], Eq[Int], Eq[Int]).contramapN((f: Foo3) => (f.a, f.b, f.c)) | ||
(Eq[Int], Eq[Int], Eq[Int], Eq[Int]).contramapN((f: Foo4) => | ||
(f.a, f.b, f.c, f.d)) | ||
|
||
(Semigroup[Int], Semigroup[Int]) | ||
.imapN(Foo2.apply)(Function.unlift(Foo2.unapply)) | ||
(Semigroup[Int], Semigroup[Int], Semigroup[Int]) | ||
.imapN(Foo3.apply)(Function.unlift(Foo3.unapply)) | ||
(Semigroup[Int], Semigroup[Int], Semigroup[Int], Semigroup[Int]) | ||
.imapN(Foo4.apply)(Function.unlift(Foo4.unapply)) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters