简体   繁体   中英

Kind compiler plugin λ not found

I have enabled the kind compiler plugin addCompilerPlugin("org.spire-math" % "kind-projector" % "0.9.6") and I can now use the ? symbol eg 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?

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

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.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM