Skip to content

Commit

Permalink
Separate free package into its own module
Browse files Browse the repository at this point in the history
It's quite possible that people are going to throw tomatoes at me for
proposing this change. There has been much discussion about
modularization in the past, and in fact free used to have its own
module, which was removed in typelevel#760/typelevel#765.

One significant change that has happened since then is that `State` has
started to use `Eval` instead of `Trampoline` for trampolining. At this
point, nothing outside of the `free` package in `cats-core` depends on
`free` (which is why this PR was so easy to create). To me that makes it
a fairly convenient border for modularization.

There was a [brief
discussion](https://gitter.im/typelevel/cats?at=5716322b548df1be102e3f3c) about this on Gitter in which @sellout supported this change on the basis that they prefer to use fixpoint types (such as `Mu`) for free structures. Putting `free` into a separate module may be better for people who want to use different variations of these structures.

Of course in addition to these more recent updates, there are the usual
arguments for modularization and decreased jar size (which I believe is
especially important for `catsJS` users).
  • Loading branch information
ceedubs committed Apr 23, 2016
1 parent d8917df commit 3604e72
Show file tree
Hide file tree
Showing 13 changed files with 27 additions and 17 deletions.
24 changes: 17 additions & 7 deletions build.sbt
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,7 @@ def noDocProjects(sv: String): Seq[ProjectReference] = CrossVersion.partialVersi
lazy val docSettings = Seq(
autoAPIMappings := true,
unidocProjectFilter in (ScalaUnidoc, unidoc) :=
inProjects(coreJVM) -- inProjects(noDocProjects(scalaVersion.value): _*),
inProjects(coreJVM, freeJVM) -- inProjects(noDocProjects(scalaVersion.value): _*),
site.addMappingsToSiteDir(mappings in (ScalaUnidoc, packageDoc), "api"),
site.addMappingsToSiteDir(tut, "_tut"),
ghpagesNoJekyll := false,
Expand All @@ -123,7 +123,7 @@ lazy val docs = project
.settings(tutSettings)
.settings(tutScalacOptions ~= (_.filterNot(Set("-Ywarn-unused-import", "-Ywarn-dead-code"))))
.settings(commonJvmSettings)
.dependsOn(coreJVM)
.dependsOn(coreJVM, freeJVM)

lazy val cats = project.in(file("."))
.settings(moduleName := "root")
Expand All @@ -136,15 +136,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, coreJVM, lawsJVM, freeJVM, testsJVM, jvm, docs, bench)
.dependsOn(macrosJVM, coreJVM, lawsJVM, freeJVM, 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, coreJS, lawsJS, freeJS, testsJS, js)
.dependsOn(macrosJS, coreJS, lawsJS, freeJS, testsJS % "test-internal -> test", js)
.enablePlugins(ScalaJSPlugin)


Expand Down Expand Up @@ -187,6 +187,16 @@ lazy val laws = crossProject.crossType(CrossType.Pure)
lazy val lawsJVM = laws.jvm
lazy val lawsJS = laws.js

lazy val free = crossProject.crossType(CrossType.Pure)
.dependsOn(macros, core, tests % "test-internal -> test")
.settings(moduleName := "cats-free")
.settings(catsSettings:_*)
.jsSettings(commonJsSettings:_*)
.jvmSettings(commonJvmSettings:_*)

lazy val freeJVM = free.jvm
lazy val freeJS = free.js

lazy val tests = crossProject.crossType(CrossType.Pure)
.dependsOn(macros, core, laws)
.settings(moduleName := "cats-tests")
Expand All @@ -210,7 +220,7 @@ lazy val jvm = project
.settings(commonJvmSettings:_*)

// bench is currently JVM-only
lazy val bench = project.dependsOn(macrosJVM, coreJVM, lawsJVM)
lazy val bench = project.dependsOn(macrosJVM, coreJVM, freeJVM, lawsJVM)
.settings(moduleName := "cats-bench")
.settings(catsSettings)
.settings(noPublishSettings)
Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
package cats
package tests
package free

import cats.tests.CatsSuite
import cats.arrow.NaturalTransformation
import cats.free.Coyoneda
import cats.laws.discipline.{FunctorTests, SerializableTests}

import org.scalacheck.Arbitrary
Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
package cats
package tests
package free

import cats.tests.CatsSuite
import cats.arrow.NaturalTransformation
import cats.free.FreeApplicative
import cats.laws.discipline.{CartesianTests, ApplicativeTests, SerializableTests}
import cats.laws.discipline.eq.{tuple3Eq, tuple2Eq}
import cats.data.State
Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
package cats
package tests
package free

import cats.tests.CatsSuite
import cats.arrow.NaturalTransformation
import cats.free.{Free, Trampoline}
import cats.laws.discipline.{CartesianTests, MonadTests, SerializableTests}
import cats.laws.discipline.eq._
import cats.laws.discipline.arbitrary.function0Arbitrary
Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
package cats
package tests
package free

import cats.tests.CatsSuite
import cats.data.{Xor, Coproduct}
import cats.free.{Free, Inject,:<:}
import org.scalacheck._

class InjectTests extends CatsSuite {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
package cats
package tests
package free

import cats.free.Yoneda
import cats.tests.CatsSuite
import cats.laws.discipline.{FunctorTests, SerializableTests}

import org.scalacheck.Arbitrary
Expand Down

0 comments on commit 3604e72

Please sign in to comment.