-
-
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
Consistency for ops classes #1456
Consistency for ops classes #1456
Conversation
5bee74f
to
06a1dce
Compare
Codecov Report
@@ Coverage Diff @@
## master #1456 +/- ##
=======================================
Coverage 93.08% 93.08%
=======================================
Files 250 250
Lines 3989 3989
Branches 135 136 +1
=======================================
Hits 3713 3713
Misses 276 276
Continue to review full report at Codecov.
|
Can we add these style rules to a doc somewhere? Ideally, we could tool something like wart-remover to check them. |
In spirit, I like this, but I do hope sooner or later we get serious about preserving some binary compatibility. This has a large binary incompatibility cross-section. |
@edmundnoble thanks very much for this! Sorry about raising the val in Ops class issue which probably wasted quite some time of yours. I suspected that 2.10 might be the cause for not making those private at the first place but didn't get the chance to verify. |
957317b
to
874c331
Compare
I added a lil something in this PR for the ops classes guidelines, while I was fixing the merge conflict. If it's better somewhere else I can take it right back out. |
LGTM, 👍 Thanks again |
I added breaking change to this since it breaks binary compatibility (not source in most cases). I think that is appropriate. |
Given that we are merging other binary-incompatible changes, I think that I give this a 👍. Notably this is different than Simulacrum, which doesn't use value classes (if I recall correctly). @mpilquist do you think that value classes are appropriate in these cases? @johnynek are you okay with us merging the binary-incompatible change? I've been MIA for a while, so to be honest I don't really know what current plans are on Cats releases/compatibility. |
874c331
to
5e57e35
Compare
Rebased. |
Two things:
|
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.
looks good. Noted a couple of untested methods this trips over (and thus the diff has lower coverage than our current average).
|
||
def <*[B](fb: F[B])(implicit F: Functor[F]): F[A] = F.map(typeClassInstance.product(self, fb)) { case (a, b) => a } | ||
final def <*[B](fb: F[B])(implicit F: Functor[F]): F[A] = F.map(typeClassInstance.product(self, fb)) { case (a, b) => a } |
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.
codecov says this method is untested.
final class MonoidOps[A: Monoid](lhs: A) { | ||
def isEmpty(implicit eq: Eq[A]): Boolean = Monoid[A].isEmpty(lhs)(eq) | ||
final class MonoidOps[A](val lhs: A) extends AnyVal { | ||
def isEmpty(implicit A: Monoid[A], eq: Eq[A]): Boolean = A.isEmpty(lhs)(eq) |
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.
this method is untested.
5e57e35
to
5296069
Compare
@edmundnoble would you like to resolve conflicts and merge (it has two sign-offs)? |
Gotcha. Will do today. |
1. Extend AnyVal when possible, unless there are macro ops 1a. Don't take implicit params in the ops class param list, again unless there are macro ops. 2. Make all conversions to ops classes final. They are all declared in traits, so users with their own syntax hierarchy have no chance of inlining unless they are marked final. Plus, it's consistent. 3. Make all ops class constructor fields private by default, to avoid polluting the namespace of the type. Remove private val part, because scala 2.10 doesn't support it Ops class guidelines Add CartesianTest
5296069
to
22d15ea
Compare
1a. Don't take implicit params in the ops class param list, again unless
there are macro ops, or they can't extend AnyVal.
(there is one exception to this and a comment explaining it; it's
EqSyntax
)traits, so users with their own syntax hierarchy have no chance of
inlining unless they are marked final. Plus, it's consistent.
polluting the namespace of the type.
Edit: 3 is not possible for Scala 2.10, so it was removed from this PR.