Kind compiler plugin λ not found

烈酒焚心 提交于 2019-12-02 03:57:45

问题


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

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!