, , , "rank-k polymorphism". wikipedia. k = 2. :
f[X](x : X) : X = ...
, f "forall X.X → X"
, z, "(forall Z.Z → Z) → Unit". . wikipedia, 2- , 1. , . ( "" , ).
alexy_r, Scala, , , / parens. , , , :
//
object TypeExample {
def main(args: Array[String]):Unit = {
def f[X](x:X):X = x
def v(f:Int=>Int):Unit = { }
v(f)
v(f[Int])
def w[Z](f:Z=>Z,g:Double=>Double):Unit = {}
w(f[Int],f[Double])
//
trait ForAll {
def g[X](x : X) : X
}
def z(forall : ForAll) = w(forall.g[Int], forall.g[Double])
z(new ForAll{def g[X](x : X) = f(x)})
}
}