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

implicitly[Recursive[Fix[Option]]] ambiguity between recursiveTRecursive and birecursiveTBirecursive #58

Open
klaeufer opened this issue Jan 22, 2017 · 4 comments

Comments

@klaeufer
Copy link

klaeufer commented Jan 22, 2017

Symptoms

cata and other recursion patterns unavailable for Fix and related types.

scalaVersion := "2.11.8"
"com.slamdata"  %% "matryoshka-core" % "0.16.4",

Causes

Ambiguity between recursiveTRecursive and birecursiveTBirecursive, apparently in top-level package object.

How to reproduce

import matryoshka._
import matryoshka.implicits._
import matryoshka.data.Fix
implicitly[Recursive[Fix[Option]]]

<console>:19: error: ambiguous implicit values:
 both method recursiveTRecursive in package matryoshka of type [T[_[_]], F[_]](implicit evidence$81: matryoshka.RecursiveT[T])matryoshka.Recursive.Aux[T[F],F]
 and method birecursiveTBirecursive in package matryoshka of type [T[_[_]], F[_]](implicit evidence$83: matryoshka.BirecursiveT[T])matryoshka.Birecursive.Aux[T[F],F]
 match expected type matryoshka.Recursive[matryoshka.data.Fix[Option]]
       implicitly[Recursive[Fix[Option]]]
                 ^

Same problem for Mu and Nu.

Workaround

def r(implicit r: BirecursiveT[Fix]) = matryoshka.birecursiveTBirecursive(r)
@sellout
Copy link
Contributor

sellout commented Jan 22, 2017

Thanks, @klaeufer. Currently, this isn’t much of a problem in practice, because it’s rare that you can actually resolve Recursive[T], usually you need Recursive.Aux[T, F], and (unfortunately) you can’t get there from Birecursive.

This is still a problem, though, and will be worse once we get the type class hierarchy working as intended. Prioritizing the implicits should fix it. I’ll do that soon.

@klaeufer
Copy link
Author

Thanks, @sellout, I'll keep using the workaround until the prioritized implicits are in place.

@klaeufer
Copy link
Author

@sellout This problem went away after I upgraded to Scala 2.12.1 and enabled -Ypartial-unification.

@sellout
Copy link
Contributor

sellout commented Apr 26, 2017

I just ran into this, which reminded me of this issue, and so I’ll actually fix it now 😆 (Although I hope it’s not gotten in your way in the mean time.)

@sellout sellout self-assigned this Apr 26, 2017
@alissapajer alissapajer added this to the milestone-test milestone Dec 2, 2017
@alissapajer alissapajer removed this from the milestone-test milestone Dec 2, 2017
@alissapajer alissapajer added this to the milestone-test milestone Dec 2, 2017
@alissapajer alissapajer removed this from the milestone-test milestone Dec 2, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants