Skip to content

Instantly share code, notes, and snippets.

@sellout
Created November 30, 2016 18:12
Show Gist options
  • Save sellout/3bec3b9d3b6de2fd224daee5cf859ed6 to your computer and use it in GitHub Desktop.
Save sellout/3bec3b9d3b6de2fd224daee5cf859ed6 to your computer and use it in GitHub Desktop.
trait A[T] {
type F[_]
}
trait B1[T] extends A[T]
object B1 {
type Aux[T, Fʹ[_]] = B1[T] { type F[A] = Fʹ[A] }
}
trait B2[T] extends A[T]
object B2 {
type Aux[T, Fʹ[_]] = B2[T] { type F[A] = Fʹ[A] }
}
trait C[T] extends B1[T] with B2[T]
object C {
type Aux[T, Fʹ[_]] = C[T] { type F[A] = Fʹ[A] }
}
object Test {
def b1[T, F[_]](implicit ev: B1.Aux[T, F]): Unit = ()
def b2[T, F[_]](implicit ev: B2.Aux[T, F]): Unit = ()
def c[T, F[_]](implicit ev: C.Aux[T, F]): (Unit, Unit) = (b1, b2)
}
// [error] abstractTypeClass.scala:28: could not find implicit value for parameter ev: B1.Aux[T,F]
// [error] def c[T, F[_]](implicit ev: C.Aux[T, F]): (Unit, Unit) = (b1, b1)
// [error] ^
// [error] abstractTypeClass.scala:28: could not find implicit value for parameter ev: B2.Aux[T,F]
// [error] def c[T, F[_]](implicit ev: C.Aux[T, F]): (Unit, Unit) = (b1, b2)
// [error] ^
@sellout
Copy link
Author

sellout commented Nov 30, 2016

If I try to pass ev explicitly, I get the following:

[error] /Users/greg/Documents/SlamData/quasar/frontend/src/main/scala/quasar/abstractTypeClass.scala:46: inferred kinds of the type arguments (T,this.F[A]) do not conform to the expected kinds of the type parameters (type T,type F).
[error] this.F[A]'s type parameters do not match type F's expected parameters:
[error] type F has one type parameter, but type F has one
[error]   def c[T, F[_]](implicit ev: C.Aux[T, F]): (Unit, Unit) = (b1(ev), b2(ev))
[error]                                                             ^

“type F has one type parameter, but type F has one” is an interesting error …

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment