问题
I have enabled the kind compiler plugin addCompilerPlugin("org.spire-math" % "kind-projector" % "0.9.6")
and I can now use the ?
symbol e.g. Map[String, ?]
however Lambda and λ are not resolved.
val f: Id ~> Future = λ[Id ~> Future](...)
produces Error: not found: value λ
. Is λ still supported by the kind compiler?
回答1:
Firstly, just a reminder that one should add
addCompilerPlugin("org.spire-math" %% "kind-projector" % "0.9.6")
to build.sbt
and not for example to plugins.sbt
.
Then, for example, for
import scala.language.higherKinds
trait MyTrait[F[_]]
declaration with type lambda
class MyClass extends MyTrait[({ type l[A] = Map[String, A] })#l]
can be replaced with
class MyClass extends MyTrait[Map[String, ?]]
or
class MyClass extends MyTrait[λ[A => Map[String, A]]]
or
class MyClass extends MyTrait[Lambda[A => Map[String, A]]]
I'm not sure if
val f: Id ~> Future = λ[Id ~> Future](???)
is a valid syntax.
~>
is usually used for natural transformations like in
import cats.{Id, ~>}
import scala.concurrent.Future
import scala.concurrent.ExecutionContext.Implicits.global
val f: Id ~> Future = new (Id ~> Future) {
override def apply[A](fa: A): Future[A] = Future(fa)
}
and not for type lambdas.
Update. Ok, it's polymorphic lambda https://github.com/typelevel/kind-projector#polymorphic-lambda-values
回答2:
I've just solved this exact problem (and not for the first time, it feels) by doing a quick rm -rf ./target
and restarting everything.
I also deleted my ensime project cache, just to make sure - presumably doing the same for IntelliJ would be a good idea too.
来源:https://stackoverflow.com/questions/48767385/kind-compiler-plugin-%ce%bb-not-found