Implicit resolution of lambda types seems to be broken. Apparently, the compiler first decrypts the type, and then does not agree with the number of type parameters.
A "simplified" example:
Definition of a monad and two signs. One is like Either . Two is similar to EitherT
trait Monad[F[_]] trait One[A, B] object One { implicit def m[A]: Monad[({ type T[x] = One[A, x] })
Defining an alias of type and class case to partially use One with String as the first parameter. The case class version can be used as a workaround.
type OneX[A] = One[String, A] case class OneY[A](value: OneX[A]) object OneY { implicit def m(implicit ev: Monad[OneX]): Monad[OneY] = ??? }
Implicit resolution of all "simple" types works.
implicitly[Monad[OneX]] implicitly[Monad[({ type T[x] = One[String, x] })
Defining Multiple Type Aliases Partially Used by Two
type TwoX[A] = Two[OneX, A] type TwoY[A] = Two[({ type T[x] = One[String, x] })
Here we see that one that uses the lambda type fails.
implicitly[Monad[TwoX]] implicitly[Monad[TwoY]]
Here we see that all lambda types that use a type alias fail. Only one that actually refers to a stable type with a single parameter succeeds.
implicitly[Monad[({ type T[x] = Two[OneX, x] })
My knowledge of the compiler is quite limited, and this may be due to the error @TravisBrown points to.
Eecolor
source share