【问题标题】:Incomprehensible syntax in ScalaScala 中难以理解的语法
【发布时间】:2013-04-10 21:07:50
【问题描述】:

我在这篇文章中找到了以下代码 (http://hseeberger.wordpress.com/2010/11/25/introduction-to-category-theory-in-scala/)。

trait GenericCategory[->>[_, _]] {
  def id[A]: A ->> A
  def compose[A, B, C](g: B ->> C, f: A ->> B): A ->> C
}

我不知道特征名称旁边的语法

[->>[_,_]]

【问题讨论】:

  • 与单个参数的方法一样,两个参数的泛型类型/类型构造函数可以以中缀形式使用。这可能会让这个名字更合理一些,因为它大概就是这样使用的。

标签: scala syntax


【解决方案1】:

这是一个higher-kinded type,在this introduction 和这个research paper 中有很好的描述。

您可能会感到困惑的原因是,->> 是高级类型的名称——它也可能被称为 Arrow

【讨论】:

  • 很好的参考资料,您介意将相同的答案添加到@om-nom-nom 所指的original question 吗?
猜你喜欢
  • 2021-02-03
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2013-06-22
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多