我在这个博客中看到了这个代码:Scala中的类型级编程:
// define the abstract types and bounds
trait Recurse {
type Next <: Recurse
// this is the recursive function definition
type X[R <: Recurse] <: Int
}
// implementation
trait RecurseA extends Recurse {
type Next = RecurseA
// this is the implementation
type X[R <: Recurse] = R#X[R#Next]
}
object Recurse {
// infinite loop
type C = RecurseA#X[RecurseA]
}
Run Code Online (Sandbox Code Playgroud)
#代码中有一个R#X[R#Next]我从未见过的运算符.由于难以搜索(被搜索引擎忽略),谁能告诉我它是什么意思?
我一直在深入研究FP及其周围的一切,我发现了某种类型的投影仪的概念,没有细节也没有解释.
我发现的唯一一件事是这个github项目,我开始考虑它是指这个特定项目,还是FP中的一些通用概念?
那么,什么是投影仪?为什么有用?(如果可能的话,你能提供例子,资源等吗?)
functional-programming scala lambda-calculus higher-kinded-types kind-projector