-
-
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-jvm and cats-js. #507
Conversation
This commit does a bunch of things: * Adds a cats.macros.Platform object * Converts cats-macros to shared/jvm/js. * Converts other Cats modules to CrossType.Pure. * Moves JVM-specific code into cats-jvm. * Supports limited platform checking in laws/tests. The new Platform object provides .isJvm and .isJs. These are notable for being macros: they will be expanded at compile-time to be either true or false. This allows scalac to eliminate the "other" branch at compile-time, which will be useful to us in laws/tests. Moving forward, the goal is to only admit platform-specific code (e.g. using java.io.*, or thread-blocking) into cats-jvm and cats-js (which will not be required to provide the same APIs). Other modules should be of CrossType.Pure (that is, they should not have JVM- or JS-specific code in them). The platform checking using .isJvm and .isJs should only be used in cats-laws and cats-tests (although of course users of the Cats library may use them however they like).
As I hinted in the commit message, I think we should allow a limited amount of platform-specific code in laws/tests. The reason is that splitting those projects into shared/jvm/js feels really cumbersome, and IMO using things like |
Current coverage is
|
@@ -251,7 +267,7 @@ lazy val commonScalacOptions = Seq( | |||
"-language:implicitConversions", | |||
"-language:experimental.macros", | |||
"-unchecked", | |||
"-Xfatal-warnings", | |||
//"-Xfatal-warnings", |
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.
Is something necessitating this?
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.
Yes, this is necessary for now for cats-macros
due to differences between 2.10 and 2.11. I think I can fix this though so I'll re-enable it when I do.
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.
If you won't be fixing it in this PR, what about omitting this option from only the macros module?
Just a comment about turning off |
Just to be clear -- I think the builds have already stabilized as far as JVM/JS split is concerned (the real culprits continue to be Travis flakiness and broken code). This is about trying to structure the project to encourage cross-platform support in a way that is easier to get right. As a case study, consider the (This also means that if we can get this merged, I'd like to rework the /cc @stew |
To expand on it a bit more -- in practice it seems like we haven't done a great job of dealing with projects whose code is split between This might not be flexible enough (for example, if |
Just re-enabled fatal warnings in everything except macros. The "right" thing to do would be to split macros on 2.10/2.11 as well as JVM/JS, to remove the warnings. But that's a bit too fiddly to supress 2 warnings IMO. Once @milessabin finishes |
I agree that it would be overkill to split macros on 2.10/2.11 to get rid of 2 warnings. I do worry a bit about how complicated our project build/structure has gotten. It seems like it could be tough for potential contributors to jump in. This looks good to me though (with the disclaimer that I'm no expert on these matters). 👍 |
macro-compat-1.0.0 is good to go ... have at it :-) |
This commit adds a dependency (currently a snapshot) on scala-bricks, specifically bricks-platform. This means that all of Cats's cross-projects are now pure, which is quite nice. We shouldn't merge a snapshot dependency. Once there is a versioned scala-bricks release, we can add another commit to change to that version.
Hey folks, due to extensive work since this PR was created, there were conflicts that had to be updated. I also pushed our scala-bricks dependency forward to the stable I'd like to get this merged (or hear objections) relatively soon, since this PR is likely to conflict with any other changes to laws/tests that we want to make. To sum up the changes:
What do you all think? |
Looks like there is some merge conflicts, but to quote Cody, "This looks good to me though (with the disclaimer that I'm no expert on these matters)" 👍 I do like the idea of the |
Thanks! This most recent commit should resolve the conflicts. If Travis goes green I'll merge it. 🐈 |
This commit does a bunch of things:
The new Platform object provides .isJvm and .isJs. These are
notable for being macros: they will be expanded at compile-time
to be either true or false. This allows scalac to eliminate
the "other" branch at compile-time, which will be useful to
us in laws/tests.
Moving forward, the goal is to only admit platform-specific code
(e.g. using java.io.*, or thread-blocking) into cats-jvm and
cats-js (which will not be required to provide the same APIs).
Other modules should be of CrossType.Pure (that is, they should
not have JVM- or JS-specific code in them).
The platform checking using .isJvm and .isJs should only be
used in cats-laws and cats-tests (although of course users of
the Cats library may use them however they like).