-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Setup case class derivation compatibility sandbox
- Loading branch information
1 parent
7a276bb
commit 0ab5302
Showing
9 changed files
with
71 additions
and
0 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
.bsp | ||
.metals | ||
.vscode | ||
target/ |
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,2 @@ | ||
version = "3.6.1" | ||
runner.dialect = scala213 |
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,8 @@ | ||
import cats.syntax.all._ | ||
import PersonSemigroup._ | ||
|
||
object App { | ||
def main(args: Array[String]): Unit = { | ||
println(Person("foo", 2) |+| Person("bar", 3)) | ||
} | ||
} |
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,21 @@ | ||
ThisBuild / scalaVersion := "3.2.2" | ||
ThisBuild / crossScalaVersions := Seq("2.13.10", "3.2.2") | ||
|
||
lazy val personOld = project | ||
lazy val personNew = project.settings( | ||
mimaPreviousClassfiles := Map( | ||
projectID.value -> (personOld / Compile / classDirectory).value | ||
), | ||
mimaReportBinaryIssues := | ||
mimaReportBinaryIssues | ||
.dependsOn(personOld / Compile / compile) | ||
.value | ||
) | ||
|
||
lazy val lib = project | ||
.settings( | ||
libraryDependencies += "org.typelevel" %% "kittens" % "3.0.0" | ||
) | ||
.dependsOn(personOld % Provided) | ||
|
||
val app = project.dependsOn(lib, personNew) |
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,6 @@ | ||
import cats._ | ||
import cats.derived._ | ||
|
||
object PersonSemigroup { | ||
implicit def instance: Semigroup[Person] = semiauto.semigroup | ||
} |
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,17 @@ | ||
case class Person private (name: String, age: Int) { | ||
def this(name: String) = this(name, -1) | ||
|
||
def withName(name: String): Person = copy(name = name) | ||
def withAge(age: Int): Person = copy(age = age) | ||
|
||
private def copy(name: String = this.name, age: Int = this.age): Person = | ||
new Person(name, age) | ||
} | ||
|
||
object Person { | ||
def apply(name: String, age: Int): Person = new Person(name, age) | ||
|
||
def apply(name: String): Person = new Person(name) | ||
|
||
private def unapply(person: Person): Some[Person] = Some(person) | ||
} |
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,11 @@ | ||
case class Person private (name: String) { | ||
def withName(name: String): Person = copy(name = name) | ||
|
||
private def copy(name: String = this.name): Person = | ||
new Person(name) | ||
} | ||
|
||
object Person { | ||
def apply(name: String): Person = new Person(name) | ||
private def unapply(person: Person): Some[Person] = Some(person) | ||
} |
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 @@ | ||
sbt.version=1.8.2 |
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 @@ | ||
addSbtPlugin("com.typesafe" % "sbt-mima-plugin" % "1.1.2") |