问题描述
最近我遇到了这个Scalaz代码(例如):
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
}
Functor中类型表达式的含义/目的是什么,即λ[α=> F [G] α]]]? Sofar,我看到只是输入类似别名,例如在
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]
此外, Intellij Idea(14.0.3)无法解析符号。 Scalaz由Intellij外部的sbt构建,然后导入Intellij。知道可能是什么情况吗?
Also, Intellij Idea (14.0.3) cannot resolve the symbol. Scalaz built by sbt outside Intellij and then imported into Intellij. Any idea what can be the case?
推荐答案
此语法由 kind-projector
Scala插件。它允许以更简洁的方式编写类型lambda:
This syntax is enabled by the kind-projector
Scala plugin. It allows to write type lambdas in more concise way:
Functor[λ[α => F[G[α]]]]
没有插件,它看起来像:
Without the plugin it would look like:
Functor[({type λ[x] = G[F[x]]})#λ]
这篇关于Scalaz Functor类型类特殊符号的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!