Тип лямбды нарушают неявное разрешение - PullRequest
0 голосов
/ 08 декабря 2018

Может ли кто-нибудь объяснить это поведение и предоставить обходной путь?Scala 2.12.7, kind-проектор 0.9.8, scalacOptions + = "-Ypartial-unification"

package tictactoe

import shapeless.{::, HList, HNil}
import tictactoe.ListOps.HasF

sealed trait LowPrio {
  implicit def ifTail[F[_], H, X <: HList](implicit ev: HasF[F, X]): HasF[F, H :: X] = null
}

object ListOps extends LowPrio {

  //Checks that property F[A] holds for at least one element of X
  sealed trait HasF[F[_], X <: HList]

  implicit def ifhead[F[_], H, X <: HList](implicit ev: F[H]): HasF[F, H :: X] = null
}

object Runner {
  type IsString[A] = =:=[A, String]

  //Works
  implicitly[HasF[IsString, String :: Int :: HNil]]

  /*
  Doesn't work
  could not find implicit value for parameter e: tictactoe.ListOps.HasF[[A]A =:= String,String :: Int :: shapeless.HNil]
  implicitly[HasF[Lambda[A => =:=[A, String]], String :: Int :: HNil]]
   */
  implicitly[HasF[Lambda[A => =:=[A, String]], String :: Int :: HNil]]

  /*
  Doesn't work
  could not find implicit value for parameter e: tictactoe.ListOps.HasF[[α$0$]α$0$ =:= String,String :: Int :: shapeless.HNil]
  implicitly[HasF[=:=[?, String], String :: Int :: HNil]]
   */
  implicitly[HasF[=:=[?, String], String :: Int :: HNil]]
}
...