Skip to content
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

Use simulacrum for typeclass boilerplate #806

Merged
merged 53 commits into from
Jan 29, 2016

Conversation

rklaehn
Copy link
Contributor

@rklaehn rklaehn commented Jan 14, 2016

This PR hides the simulacrum dependency from the pom and uses the typeclass annotation on all typeclasses. It also removes some manually added code that is now generated by simulacrum.

Review by @mpilquist or @milessabin if possible. It would be good if @johnynek could look at the generated code with an eye on algebra/algebird compatibility.

aryairani and others added 30 commits January 5, 2016 15:07
This may provide the following benefits:

1) It should be a bit more efficient.
2) It removes the need to `import cats.std.function._` for some
operations, which may make it a bit more newcomer friendly.
3) We are already using Eval for things like foldRight, so it seems more
consistent to use it for `State`.
4) I think it's a bit easier to explain `Eval` than `Trampoline`, since
it's hard to explain the latter without first explaining `Free`. So
again, this may be a bit more newcomer friendly.
Also add the missing `coproduct` syntax `object`.
Use Eval instead of Trampoline for State
- Also remove unused type parameter in sequence_
factor out a static inner method from typelevel#769 for better GC
Fix order of effects in FreeApplicative.foldMap
Add ScalaDoc for MonadCombine unite syntax
Add ScalaDoc examples for Coproduct syntax
Add ScalaDoc example for foldK syntax
Question: is the apply method generated by simulacrum also @inline marked?
@rklaehn
Copy link
Contributor Author

rklaehn commented Jan 16, 2016

@mpilquist I did as you suggested, and sbt validate runs locally. So let's see if travis agrees.

@rklaehn
Copy link
Contributor Author

rklaehn commented Jan 16, 2016

Here is the POM:

<?xml version='1.0' encoding='UTF-8'?>
<project xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://maven.apache.org/POM/4.0.0">
    <modelVersion>4.0.0</modelVersion>
    <groupId>org.spire-math</groupId>
    <artifactId>cats-kernel_2.11</artifactId>
    <packaging>jar</packaging>
    <description>kernel</description>
    <url>https://github.com/non/cats</url>
    <version>0.4.0-SNAPSHOT</version>
    <licenses>
        <license>
            <name>MIT</name>
            <url>http://opensource.org/licenses/MIT</url>
            <distribution>repo</distribution>
        </license>
    </licenses>
    <name>kernel</name>
    <organization>
        <name>org.spire-math</name>
        <url>https://github.com/non/cats</url>
    </organization>
    <scm>
        <url>https://github.com/non/cats</url>
        <connection>scm:git:git@github.com:non/cats.git</connection>
    </scm>
    <developers>
        <developer>
            <id>non</id>
            <name>Erik Osheim</name>
            <url>http://github.com/non/</url>
        </developer>
    </developers>
    <properties>
        <info.apiURL>https://non.github.io/cats/api/</info.apiURL>
    </properties>
    <dependencies>
        <dependency>
            <groupId>org.scala-lang</groupId>
            <artifactId>scala-library</artifactId>
            <version>2.11.7</version>
        </dependency>
        <dependency>
            <groupId>org.scoverage</groupId>
            <artifactId>scalac-scoverage-runtime_2.11</artifactId>
            <version>1.1.0</version>
            <scope>provided</scope>
        </dependency>
        <dependency>
            <groupId>org.scoverage</groupId>
            <artifactId>scalac-scoverage-plugin_2.11</artifactId>
            <version>1.1.0</version>
            <scope>provided</scope>
        </dependency>
        <dependency>
            <groupId>com.github.mpilquist</groupId>
            <artifactId>simulacrum_2.11</artifactId>
            <version>0.5.0</version>
            <scope>provided</scope>
        </dependency>
    </dependencies>
</project>

@mpilquist
Copy link
Member

OK cool. We can remove the reference from the POM by using the pomPostProcess setting. I'm away from a computer now but I can post an example later. Alternatively, take a look at the build settings class in scodec-build.

On Jan 16, 2016, at 12:05 PM, Rüdiger Klaehn notifications@github.com wrote:

Here is the POM:

4.0.0 org.spire-math cats-kernel_2.11 jar kernel https://github.com/non/cats 0.4.0-SNAPSHOT MIT http://opensource.org/licenses/MIT repo kernel org.spire-math https://github.com/non/cats https://github.com/non/cats scm:git:git@github.com:non/cats.git non Erik Osheim http://github.com/non/ https://non.github.io/cats/api/ org.scala-lang scala-library 2.11.7 org.scoverage scalac-scoverage-runtime_2.11 1.1.0 provided org.scoverage scalac-scoverage-plugin_2.11 1.1.0 provided com.github.mpilquist simulacrum_2.11 0.5.0 provided — Reply to this email directly or view it on GitHub.

This gets rid of the simulacrum dependency, as well as the strange and
definitely unneeded scoverage dependencies, resulting in a nice and clean
.pom

Code taken from scodec-build. Thanks @mpilquist
@rklaehn
Copy link
Contributor Author

rklaehn commented Jan 16, 2016

The .pom after removing all provided deps (including the very weird scoverage deps). @johnynek does this look OK to you? I think once we switch over to typeclassic there will be one additional dependency.

<?xml version='1.0' encoding='UTF-8'?>
<project xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://maven.apache.org/POM/4.0.0">
    <modelVersion>4.0.0</modelVersion>
    <groupId>org.spire-math</groupId>
    <artifactId>cats-kernel_2.11</artifactId>
    <packaging>jar</packaging>
    <description>kernel</description>
    <url>https://github.com/non/cats</url>
    <version>0.4.0-SNAPSHOT</version>
    <licenses>
        <license>
            <name>MIT</name>
            <url>http://opensource.org/licenses/MIT</url>
            <distribution>repo</distribution>
        </license>
    </licenses>
    <name>kernel</name>
    <organization>
        <name>org.spire-math</name>
        <url>https://github.com/non/cats</url>
    </organization>
    <scm>
        <url>https://github.com/non/cats</url>
        <connection>scm:git:git@github.com:non/cats.git</connection>
    </scm>
    <developers>
        <developer>
            <id>non</id>
            <name>Erik Osheim</name>
            <url>http://github.com/non/</url>
        </developer>
    </developers>
    <properties>
        <info.apiURL>https://non.github.io/cats/api/</info.apiURL>
    </properties>
    <dependencies>
        <dependency>
            <groupId>org.scala-lang</groupId>
            <artifactId>scala-library</artifactId>
            <version>2.11.7</version>
        </dependency>
    </dependencies>
</project>

@ceedubs
Copy link
Contributor

ceedubs commented Jan 26, 2016

@rklaehn thanks a bunch for this work!

What's the current status of this? @mpilquist, @johnynek, @milessabin does it look good to you?

@mpilquist
Copy link
Member

👍

@johnynek
Copy link
Contributor

👍 I guess. This PR is huge and I am not confident that I see all that is going on,

To be clear: I'm happy to use simulacrum here as long as consumers of the library see 0 additions deps to use the code. I understand the provided here was a phantom, and not actually needed at runtime. Is that right?

@rklaehn
Copy link
Contributor Author

rklaehn commented Jan 27, 2016

@johnynek yes, the provided dependency on simulacrum is not needed at runtime. That is why it is removed from the .pom.

@ceedubs
Copy link
Contributor

ceedubs commented Jan 28, 2016

👍

@rklaehn sorry there are merge conflicts. If you fix them and leave a comment that you have updated the PR, I'll try to merge before more conflicts pop up.

@johnynek
Copy link
Contributor

@rklaehn Thanks for the work on this!

The removal of provided artefacts is done inline because it is used in only
one place.
@rklaehn
Copy link
Contributor Author

rklaehn commented Jan 29, 2016

@ceedubs the merge conflict was because mima was configured on topic/kernel. It should be fixed now.

I am doing a talk about spire and the typelevel ecosystem at my local scala user group in munich on 2016-03-08. It would be great if algebra and spire on master would depend on cats-kernel at that time, so I could report something positive... :-)

ceedubs added a commit that referenced this pull request Jan 29, 2016
Use simulacrum for typeclass boilerplate
@ceedubs ceedubs merged commit 82c436f into typelevel:topic/kernel Jan 29, 2016
@ceedubs
Copy link
Contributor

ceedubs commented Jan 29, 2016

Thanks @rklaehn!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.