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

Issue #934 - Make Eval covariant #937

Merged
merged 1 commit into from
May 30, 2016
Merged

Issue #934 - Make Eval covariant #937

merged 1 commit into from
May 30, 2016

Conversation

alexandru
Copy link
Member

The reason is that Eval should be a drop-in replacement for by-name parameters. Noticed that changing it wouldn't break anything within Cats.

@codecov-io
Copy link

Current coverage is 88.93%

Merging #937 into master will not affect coverage as of dc51483

@@            master    #937   diff @@
======================================
  Files          179     179       
  Stmts         2132    2132       
  Branches        42      42       
  Methods          0       0       
======================================
  Hit           1896    1896       
  Partial          0       0       
  Missed         236     236       

Review entire Coverage Diff as of dc51483

Powered by Codecov. Updated on successful CI builds.

@@ -350,7 +350,7 @@ trait EvalMonoid[A] extends Monoid[Eval[A]] with EvalSemigroup[A] {
trait EvalGroup[A] extends Group[Eval[A]] with EvalMonoid[A] {
implicit def algebra: Group[A]
def inverse(lx: Eval[A]): Eval[A] =
lx.map(_.inverse)
lx.map(_.inverse())
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why is this needed?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@adelbertc it isn't needed, but the definition of that function in cats.syntax.GroupOps is:

def inverse(): A = macro Ops.unop[A]

Not sure why that's the definition, but when you've got a parens pair like that in your def, then you have tools like IntelliJ IDEA complaining about you not using the parens at the call site. Which I personally find cool because those parens usually indicate side-effects. Maybe we should change the def inverse() definition?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I tried removing the parens from def inverse() and got this:

[error] /Users/cody/code/cats/core/src/main/scala/cats/syntax/group.scala:15: macro implementation has incompatible shape:
[error]  required: (c: scala.reflect.macros.whitebox.Context): c.Expr[A]
[error]  or      : (c: scala.reflect.macros.whitebox.Context): c.Tree
[error]  found   : (c: reflect.macros.Context)(): c.Expr[R]
[error] number of parameter sections differ
[error]   def inverse: A = macro Ops.unop[A]

Paging @non, our macro optimization wizard.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You would also need to remove the parens from the corresponding macro defn.

@ceedubs
Copy link
Contributor

ceedubs commented Apr 3, 2016

It's been over 2 weeks since #934 (comment) and nobody has spoken up against this. 👍 from me.

@non
Copy link
Contributor

non commented May 30, 2016

I agree with the rationale. Let's do it! 👍

@non non merged commit 9e41d8f into typelevel:master May 30, 2016
yanns added a commit to yanns/cats that referenced this pull request Jul 4, 2024
yanns added a commit to yanns/cats that referenced this pull request Sep 2, 2024
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.

6 participants