-
-
Notifications
You must be signed in to change notification settings - Fork 1.2k
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
Introduce cats-kernel and remove algebra dependency #1001
Changes from 9 commits
03aad13
38a3dc8
157710f
ceb94cc
673d045
d19a098
3378af3
34e206a
041a06a
f8e3910
e6bd8fe
4b8b789
ada6b75
de8a2fc
fc0acf2
5f408e1
d2dcb23
8fe8938
aac4652
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -24,6 +24,17 @@ lazy val catsDoctestSettings = Seq( | |
doctestWithDependencies := false | ||
) ++ doctestSettings | ||
|
||
lazy val kernelSettings = Seq( | ||
scalacOptions ++= commonScalacOptions, | ||
resolvers ++= Seq( | ||
"bintray/non" at "http://dl.bintray.com/non/maven", | ||
Resolver.sonatypeRepo("releases"), | ||
Resolver.sonatypeRepo("snapshots") | ||
), | ||
parallelExecution in Test := false, | ||
scalacOptions in (Compile, doc) := (scalacOptions in (Compile, doc)).value.filter(_ != "-Xfatal-warnings") | ||
) ++ warnUnusedImport | ||
|
||
lazy val commonSettings = Seq( | ||
scalacOptions ++= commonScalacOptions, | ||
resolvers ++= Seq( | ||
|
@@ -33,8 +44,6 @@ lazy val commonSettings = Seq( | |
), | ||
libraryDependencies ++= Seq( | ||
"com.github.mpilquist" %%% "simulacrum" % "0.7.0", | ||
"org.spire-math" %%% "algebra" % "0.3.1", | ||
"org.spire-math" %%% "algebra-std" % "0.3.1", | ||
"org.typelevel" %%% "machinist" % "0.4.1", | ||
compilerPlugin("org.scalamacros" %% "paradise" % "2.1.0" cross CrossVersion.full), | ||
compilerPlugin("org.spire-math" %% "kind-projector" % "0.6.3") | ||
|
@@ -80,8 +89,12 @@ lazy val scalacheckVersion = "1.12.5" | |
|
||
lazy val disciplineDependencies = Seq( | ||
libraryDependencies += "org.scalacheck" %%% "scalacheck" % scalacheckVersion, | ||
libraryDependencies += "org.typelevel" %%% "discipline" % "0.4" | ||
) | ||
libraryDependencies += "org.typelevel" %%% "discipline" % "0.4") | ||
|
||
lazy val testingDependencies = Seq( | ||
libraryDependencies += "org.typelevel" %%% "catalysts-platform" % "0.0.2", | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Should There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I think not, since we are checking the platform in the law testing code that we are publishing. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Ah I didn't realize this was only being included in laws/tests. 👍 |
||
libraryDependencies += "org.typelevel" %%% "catalysts-macros" % "0.0.2" % "test", | ||
libraryDependencies += "org.scalatest" %%% "scalatest" % "3.0.0-M7" % "test") | ||
|
||
/** | ||
* Remove 2.10 projects from doc generation, as the macros used in the projects | ||
|
@@ -136,15 +149,15 @@ lazy val catsJVM = project.in(file(".catsJVM")) | |
.settings(moduleName := "cats") | ||
.settings(catsSettings) | ||
.settings(commonJvmSettings) | ||
.aggregate(macrosJVM, coreJVM, lawsJVM, testsJVM, jvm, docs, bench) | ||
.dependsOn(macrosJVM, coreJVM, lawsJVM, testsJVM % "test-internal -> test", jvm, bench % "compile-internal;test-internal -> test") | ||
.aggregate(macrosJVM, kernelJVM, kernelLawsJVM, coreJVM, lawsJVM, testsJVM, jvm, docs, bench) | ||
.dependsOn(macrosJVM, kernelJVM, kernelLawsJVM, coreJVM, lawsJVM, testsJVM % "test-internal -> test", jvm, bench % "compile-internal;test-internal -> test") | ||
|
||
lazy val catsJS = project.in(file(".catsJS")) | ||
.settings(moduleName := "cats") | ||
.settings(catsSettings) | ||
.settings(commonJsSettings) | ||
.aggregate(macrosJS, coreJS, lawsJS, testsJS, js) | ||
.dependsOn(macrosJS, coreJS, lawsJS, testsJS % "test-internal -> test", js) | ||
.aggregate(macrosJS, kernelJS, kernelLawsJS, coreJS, lawsJS, testsJS, js) | ||
.dependsOn(macrosJS, kernelJS, kernelLawsJS, coreJS, lawsJS, testsJS % "test-internal -> test", js) | ||
.enablePlugins(ScalaJSPlugin) | ||
|
||
|
||
|
@@ -158,14 +171,41 @@ lazy val macros = crossProject.crossType(CrossType.Pure) | |
lazy val macrosJVM = macros.jvm | ||
lazy val macrosJS = macros.js | ||
|
||
lazy val kernel = crossProject.crossType(CrossType.Pure) | ||
.in(file("kernel")) | ||
.settings(moduleName := "cats-kernel") | ||
.settings(kernelSettings: _*) | ||
.settings(buildSettings: _*) | ||
.settings(publishSettings: _*) | ||
.settings(scoverageSettings: _*) | ||
.settings(sourceGenerators in Compile <+= (sourceManaged in Compile).map(KernelBoiler.gen)) | ||
.jsSettings(commonJsSettings:_*) | ||
.jvmSettings(commonJvmSettings:_*) | ||
|
||
lazy val kernelJVM = kernel.jvm | ||
lazy val kernelJS = kernel.js | ||
|
||
lazy val kernelLaws = crossProject.crossType(CrossType.Pure) | ||
.in(file("kernel-laws")) | ||
.settings(moduleName := "cats-kernel-laws") | ||
.settings(kernelSettings: _*) | ||
.settings(buildSettings: _*) | ||
.settings(publishSettings: _*) | ||
.settings(scoverageSettings: _*) | ||
.settings(disciplineDependencies: _*) | ||
.settings(testingDependencies: _*) | ||
.jsSettings(commonJsSettings:_*) | ||
.jvmSettings(commonJvmSettings:_*) | ||
.dependsOn(kernel) | ||
|
||
lazy val kernelLawsJVM = kernelLaws.jvm | ||
lazy val kernelLawsJS = kernelLaws.js | ||
|
||
lazy val core = crossProject.crossType(CrossType.Pure) | ||
.dependsOn(macros) | ||
.dependsOn(macros, kernel) | ||
.settings(moduleName := "cats-core") | ||
.settings(catsSettings:_*) | ||
.settings( | ||
sourceGenerators in Compile <+= (sourceManaged in Compile).map(Boilerplate.gen) | ||
) | ||
.settings(sourceGenerators in Compile <+= (sourceManaged in Compile).map(Boilerplate.gen)) | ||
.settings(libraryDependencies += "org.scalacheck" %%% "scalacheck" % scalacheckVersion % "test") | ||
.jsSettings(commonJsSettings:_*) | ||
.jvmSettings(commonJvmSettings:_*) | ||
|
@@ -174,7 +214,7 @@ lazy val coreJVM = core.jvm | |
lazy val coreJS = core.js | ||
|
||
lazy val laws = crossProject.crossType(CrossType.Pure) | ||
.dependsOn(macros, core) | ||
.dependsOn(macros, kernel, core, kernelLaws) | ||
.settings(moduleName := "cats-laws") | ||
.settings(catsSettings:_*) | ||
.settings(disciplineDependencies:_*) | ||
|
@@ -193,9 +233,7 @@ lazy val tests = crossProject.crossType(CrossType.Pure) | |
.settings(catsSettings:_*) | ||
.settings(disciplineDependencies:_*) | ||
.settings(noPublishSettings:_*) | ||
.settings(libraryDependencies ++= Seq( | ||
"org.scalatest" %%% "scalatest" % "3.0.0-M7" % "test", | ||
"org.typelevel" %%% "catalysts-platform" % "0.0.2" % "test")) | ||
.settings(testingDependencies: _*) | ||
.jsSettings(commonJsSettings:_*) | ||
.jvmSettings(commonJvmSettings:_*) | ||
|
||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,8 +1,7 @@ | ||
package cats | ||
package std | ||
|
||
import algebra.CommutativeGroup | ||
import algebra.ring.AdditiveCommutativeGroup | ||
import cats.kernel.CommutativeGroup | ||
|
||
trait AnyValInstances | ||
extends IntInstances | ||
|
@@ -15,129 +14,103 @@ trait AnyValInstances | |
with BooleanInstances | ||
with UnitInstances | ||
|
||
trait IntInstances extends algebra.std.IntInstances { | ||
trait IntInstances extends cats.kernel.std.IntInstances { | ||
|
||
implicit val intShow: Show[Int] = | ||
Show.fromToString[Int] | ||
|
||
implicit val intGroup: CommutativeGroup[Int] = | ||
AdditiveCommutativeGroup[Int].additive | ||
|
||
new CommutativeGroup[Int] { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. should this not be in There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I was going to ask you about that -- we didn't have generic semigroups for numbers in Algebra. If everyone agrees that we want those I can move them in this PR. |
||
def combine(x: Int, y: Int): Int = x + y | ||
def empty: Int = 0 | ||
def inverse(x: Int): Int = -x | ||
override def remove(x: Int, y: Int): Int = x - y | ||
} | ||
} | ||
|
||
trait ByteInstances /* missing algebra type classes */ { | ||
trait ByteInstances extends cats.kernel.std.ByteInstances { | ||
|
||
implicit val byteShow: Show[Byte] = | ||
Show.fromToString[Byte] | ||
|
||
// TODO: replace this minimal algebra with one from the algebra project | ||
implicit val byteAlgebra: CommutativeGroup[Byte] with Order[Byte] = | ||
new CommutativeGroup[Byte] with Order[Byte] { | ||
implicit val byteGroup: CommutativeGroup[Byte] = | ||
new CommutativeGroup[Byte] { | ||
def combine(x: Byte, y: Byte): Byte = (x + y).toByte | ||
def empty: Byte = 0 | ||
def inverse(x: Byte): Byte = (-x).toByte | ||
def compare(x: Byte, y: Byte): Int = | ||
if (x < y) -1 else if (y < x) 1 else 0 | ||
override def remove(x: Byte, y: Byte): Byte = (x - y).toByte | ||
} | ||
} | ||
|
||
trait CharInstances /* missing algebra type classes */ { | ||
|
||
trait CharInstances extends cats.kernel.std.CharInstances { | ||
implicit val charShow: Show[Char] = | ||
Show.fromToString[Char] | ||
|
||
implicit val charOrder: Order[Char] = | ||
new Order[Char] { | ||
def compare(x: Char, y: Char): Int = | ||
if (x < y) -1 else if (y < x) 1 else 0 | ||
} | ||
} | ||
|
||
trait ShortInstances /* missing algebra type classes */ { | ||
trait ShortInstances extends cats.kernel.std.ShortInstances { | ||
|
||
implicit val shortShow: Show[Short] = | ||
Show.fromToString[Short] | ||
|
||
// TODO: replace this minimal algebra with one from the algebra project | ||
implicit val shortAlgebra: CommutativeGroup[Short] with Order[Short] = | ||
new CommutativeGroup[Short] with Order[Short] { | ||
implicit val shortGroup: CommutativeGroup[Short] = | ||
new CommutativeGroup[Short] { | ||
def combine(x: Short, y: Short): Short = (x + y).toShort | ||
def empty: Short = 0 | ||
def inverse(x: Short): Short = (-x).toShort | ||
def compare(x: Short, y: Short): Int = | ||
if (x < y) -1 else if (y < x) 1 else 0 | ||
override def remove(x: Short, y: Short): Short = (x - y).toShort | ||
} | ||
|
||
} | ||
|
||
trait LongInstances /* missing algebra type classes */ { | ||
trait LongInstances extends cats.kernel.std.LongInstances { | ||
|
||
implicit val longShow: Show[Long] = | ||
Show.fromToString[Long] | ||
|
||
// TODO: replace this minimal algebra with one from the algebra project | ||
implicit val longAlgebra: CommutativeGroup[Long] with Order[Long] = | ||
new CommutativeGroup[Long] with Order[Long] { | ||
implicit val longGroup: CommutativeGroup[Long] = | ||
new CommutativeGroup[Long] { | ||
def combine(x: Long, y: Long): Long = x + y | ||
def empty: Long = 0L | ||
def inverse(x: Long): Long = -x | ||
def compare(x: Long, y: Long): Int = | ||
if (x < y) -1 else if (y < x) 1 else 0 | ||
override def remove(x: Long, y: Long): Long = x - y | ||
} | ||
} | ||
|
||
trait FloatInstances /* missing algebra type classes */ { | ||
trait FloatInstances extends cats.kernel.std.FloatInstances { | ||
|
||
implicit val floatShow: Show[Float] = | ||
Show.fromToString[Float] | ||
|
||
// TODO: replace this minimal algebra with one from the algebra project | ||
implicit val floatAlgebra: CommutativeGroup[Float] with Order[Float] = | ||
new CommutativeGroup[Float] with Order[Float] { | ||
implicit val floatGroup: CommutativeGroup[Float] = | ||
new CommutativeGroup[Float] { | ||
def combine(x: Float, y: Float): Float = x + y | ||
def empty: Float = 0F | ||
def inverse(x: Float): Float = -x | ||
def compare(x: Float, y: Float): Int = | ||
java.lang.Float.compare(x, y) | ||
override def remove(x: Float, y: Float): Float = x - y | ||
} | ||
|
||
} | ||
|
||
trait DoubleInstances /* missing algebra type classes */ { | ||
trait DoubleInstances extends cats.kernel.std.DoubleInstances { | ||
|
||
implicit val doubleShow: Show[Double] = | ||
Show.fromToString[Double] | ||
|
||
// TODO: replace this minimal algebra with one from the algebra project | ||
implicit val doubleAlgebra: CommutativeGroup[Double] with Order[Double] = | ||
new CommutativeGroup[Double] with Order[Double] { | ||
implicit val doubleGroup: CommutativeGroup[Double] = | ||
new CommutativeGroup[Double] { | ||
def combine(x: Double, y: Double): Double = x + y | ||
def empty: Double = 0D | ||
def inverse(x: Double): Double = -x | ||
def compare(x: Double, y: Double): Int = | ||
java.lang.Double.compare(x, y) | ||
override def remove(x: Double, y: Double): Double = x - y | ||
} | ||
|
||
} | ||
|
||
trait BooleanInstances extends algebra.std.BooleanInstances { | ||
trait BooleanInstances extends cats.kernel.std.BooleanInstances { | ||
|
||
implicit val booleanShow: Show[Boolean] = | ||
Show.fromToString[Boolean] | ||
|
||
} | ||
|
||
trait UnitInstances /* missing algebra type classes */ { | ||
trait UnitInstances extends cats.kernel.std.UnitInstances { | ||
|
||
implicit val unitShow: Show[Unit] = | ||
Show.fromToString[Unit] | ||
|
||
implicit val unitAlgebra: CommutativeGroup[Unit] with Order[Unit] = | ||
new CommutativeGroup[Unit] with Order[Unit] { | ||
def combine(x: Unit, y: Unit): Unit = () | ||
def empty: Unit = () | ||
def inverse(x: Unit): Unit = () | ||
def compare(x: Unit, y: Unit): Int = 0 | ||
} | ||
|
||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,7 +1,7 @@ | ||
package cats | ||
package std | ||
|
||
trait BigIntInstances extends algebra.std.BigIntInstances { | ||
trait BigIntInstances extends cats.kernel.std.BigIntInstances { | ||
implicit val bigIntShow: Show[BigInt] = | ||
Show.fromToString[BigInt] | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What is this used for?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
That may not be necessary -- I'm not sure what we're using it for. I'll try removing it.