scala中的类型参数定义

paw*_*icz 7 scala scalaz

可能重复:
Scala中什么是lambda类型,它们有什么好处?

  1. 如何解决这种类型的定义:Pure[({type ?[a]=(R, a)})#?]

  2. 使用这种结构的原因是什么?

Snipped来自scalaz库:

trait Pure[P[_]] {
  def pure[A](a: => A): P[A]
}

object Pure {
  import Scalaz._
//...
  implicit def Tuple2Pure[R: Zero]: Pure[({type ?[a]=(R, a)})#?] = new Pure[({type ?[a]=(R, a)})#?] {
  def pure[A](a: => A) = (Ø, a)
  }

//...
}
Run Code Online (Sandbox Code Playgroud)