kind-projector

What is a kind projector

好久不见. 提交于 2020-06-22 12:16:08
问题 I've been digging into FP and everything that surrounds it, and I found the concept of kind projector written somewhere, without details nor explanations. The only thing I found was this github project, and I'm starting to think if it was referring to this particular project, or to some generic concept in FP? So, what is a kind projector? Why is it useful? (if possible, can you provide examples, resources, etc?) 回答1: This is indeed just a slightly awkward name for the specific plugin for the

Scalaz Functor typeclass special symbols

为君一笑 提交于 2019-12-19 10:29:20
问题 Recently I have come across this Scalaz code (e.g. https://github.com/scalaz/scalaz/blob/series/7.2.x/core/src/main/scala/scalaz/Functor.scala): def compose[G[_]](implicit G0: Functor[G]): Functor[λ[α => F[G[α]]]] = new CompositionFunctor[F, G] { implicit def F = self implicit def G = G0 } What is the meaning/purpose of the type expression inside the "Functor", i.e. λ[α => F[G[α]]]? Sofar, I have seen just type aliases like e.g. in http://like-a-boss.net/2014/09/27/type-lambda-in-scala.html

scala generic function `not found: type ?`

百般思念 提交于 2019-12-12 14:23:24
问题 When I use scala to create a function like this,It told me that not found: type ? scala def save[ K: SpatialComponent: TypeTag, V <: CellGrid: TypeTag: ? => TileMergeMethods[V]: ? => TilePrototypeMethods[V] ](id: LayerId, rdd: RDD[(K, V)] with Metadata[TileLayerMetadata[K]], method: KeyIndexMethod[K]) Can somebody told me how to resolve this? 回答1: I got it,must add this code to build.sbt. resolvers += Resolver.sonatypeRepo("releases") addCompilerPlugin("org.spire-math" % "kind-projector" % "0

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

Kind compiler plugin λ not found

|▌冷眼眸甩不掉的悲伤 提交于 2019-12-02 01:39:15
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? 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

Scalaz Functor typeclass special symbols

落花浮王杯 提交于 2019-12-01 11:13:04
Recently I have come across this Scalaz code (e.g. https://github.com/scalaz/scalaz/blob/series/7.2.x/core/src/main/scala/scalaz/Functor.scala ): def compose[G[_]](implicit G0: Functor[G]): Functor[λ[α => F[G[α]]]] = new CompositionFunctor[F, G] { implicit def F = self implicit def G = G0 } What is the meaning/purpose of the type expression inside the "Functor", i.e. λ[α => F[G[α]]]? Sofar, I have seen just type aliases like e.g. in http://like-a-boss.net/2014/09/27/type-lambda-in-scala.html new Functor[A, ({ type Alias[A] = Tuple2[X, A]})#Alias] Also, Intellij Idea (14.0.3) cannot resolve the

Functor Instance for Type Constructor with Two Parameters in Scala

让人想犯罪 __ 提交于 2019-11-30 14:44:47
I have a class Foo with two parameters, and I am trying to write a Functor instance for Foo with the first parameter fixed, as follows: object Scratchpad { trait Functor[F[_]] { def fmap[A, B](f: A => B): F[A] => F[B] } case class Foo[X, Y](value: Y) implicit def fooInstances[X]: Functor[Foo[X, _]] = new Functor[Foo[X, _]] { def fmap[A, B](f: A => B): Foo[X, A] => Foo[X, B] = foo => Foo[X, B](f(foo.value)) } } But the above code fails to compile, generating the following error: Error:(9, 41) Scratchpad.Foo[X, _] takes no type parameters, expected: one implicit def fooInstances[X]: Functor[Foo

Is it possible to “curry” higher-kinded types in Scala?

谁都会走 提交于 2019-11-30 11:58:41
问题 Let's suppose I have a trait with two type parameters, e.g. trait Qux[A, B] and another trait with a higher-kinded type parameter, e.g. trait Turkle[C[_]] I'd like to be able to substitute a fixed value for one of the type parameters for Qux , so that it can be used to parametrize Turkle . Here's an example (of code that doesn't make sense in Scala!): trait Baz[A] extends Turkle[Qux[A, _]] Anyone have any ideas how to achieve this effect? 回答1: Jason Zaugg came up with the most succinct way to

Functor Instance for Type Constructor with Two Parameters in Scala

主宰稳场 提交于 2019-11-29 21:01:41
问题 I have a class Foo with two parameters, and I am trying to write a Functor instance for Foo with the first parameter fixed, as follows: object Scratchpad { trait Functor[F[_]] { def fmap[A, B](f: A => B): F[A] => F[B] } case class Foo[X, Y](value: Y) implicit def fooInstances[X]: Functor[Foo[X, _]] = new Functor[Foo[X, _]] { def fmap[A, B](f: A => B): Foo[X, A] => Foo[X, B] = foo => Foo[X, B](f(foo.value)) } } But the above code fails to compile, generating the following error: Error:(9, 41)