Scala 类型参数中“::”的含义?
查看Travis Brown关于的优秀博客文章,我看到了以下方法:Scala 类型参数中“::”的含义?,scala,shapeless,Scala,Shapeless,查看Travis Brown关于的优秀博客文章,我看到了以下方法: implicit def hconsParser[H: Parser, T <: HList: Parser]: Parser[H :: T] = new Parser[H :: T] { def apply(s: String): Option[H :: T] = s.split(",").toList match { case cell +: rest => f
implicit def hconsParser[H: Parser, T <: HList: Parser]: Parser[H :: T] =
new Parser[H :: T] {
def apply(s: String): Option[H :: T] = s.split(",").toList match {
case cell +: rest => for {
head <- implicitly[Parser[H]].apply(cell)
tail <- implicitly[Parser[T]].apply(rest.mkString(","))
} yield head :: tail
}
}
implicit def-hconsParser[H:Parser,T代表{
headH::T
是类型:[H,T]
的中缀形式,它是一个HList
,头为H
,尾为T
scala> trait infix[A, B]
scala> def test[A, B](ab: A infix B) = ???
test: [A, B](ab: infix[A,B])Nothing