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

Adjust implicit priorities in OneAnd. #538

Merged
merged 1 commit into from
Sep 23, 2015
Merged

Adjust implicit priorities in OneAnd. #538

merged 1 commit into from
Sep 23, 2015

Conversation

paulp
Copy link
Contributor

@paulp paulp commented Sep 22, 2015

scala> implicitly[Functor[NonEmptyList]]
<console>:27: error: ambiguous implicit values:
 both method oneAndFunctor in trait OneAndInstances ...
 and method oneAndMonad in trait OneAndInstances ...
 match expected type cats.Functor[cats.data.NonEmptyList]

There were two bugs: one is that the Monad implicit
conflicts with the Functor implicit. The other is that
this construction doesn't work:

object OneAnd extends OneAndInstances with OneAndLowPriority

If it DID work, this ordering would give priority to the
implicits found in OneAndLowPriority, so it's reversed - but
more to the point, implicit priority isn't based on linearization.
One of the traits has to be a subtrait of the other to have
higher priority, and as written they had no relationship.

scala> implicitly[Functor[NonEmptyList]]
<console>:27: error: ambiguous implicit values:
 both method oneAndFunctor in trait OneAndInstances ...
 and method oneAndMonad in trait OneAndInstances ...
 match expected type cats.Functor[cats.data.NonEmptyList]

There were two bugs: one is that the Monad implicit
conflicts with the Functor implicit. The other is that
this construction doesn't work:

  object OneAnd extends OneAndInstances with OneAndLowPriority

If it DID work, this ordering would give priority to the
implicits found in OneAndLowPriority, so it's reversed - but
more to the point, implicit priority isn't based on linearization.
One of the traits has to be a subtrait of the other to have
higher priority, and as written they had no relationship.
@adelbertc
Copy link
Contributor

👍 once Travis is green

@codecov-io
Copy link

Current coverage is 75.42%

Merging #538 into master will increase coverage by +10.30% as of 85d03e6

@@            master    #538   diff @@
======================================
  Files          156     152     -4
  Stmts         2429    2055   -374
  Branches        68      68       
  Methods          0       0       
======================================
- Hit           1582    1550    -32
  Partial          0       0       
+ Missed         847     505   -342

Review entire Coverage Diff as of 85d03e6

Powered by Codecov. Updated on successful CI builds.

@non
Copy link
Contributor

non commented Sep 23, 2015

👍

Great catch, thanks Paul!

non added a commit that referenced this pull request Sep 23, 2015
Adjust implicit priorities in OneAnd.
@non non merged commit 9393a2d into typelevel:master Sep 23, 2015
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.

4 participants