问题描述
我发现了一种有趣的语法内容.它被称为中缀类型
.
I've found one interesting syntax stuff. It's called Infix type
.
示例:
class M[T, U]
new (Int M String)
现在我正在从一些流行的框架或库中寻找这种类型的示例.我在哪里可以找到它们?有什么建议吗?
And now I'm looking for examples of this type from some popular frameworks or libraries. Where can I find them? Any suggestions?
推荐答案
shapeless library
有一堆
shapeless library
has bunch of them
Set ~> Option
很喜欢
Set[A] => Option[A] forAny {type A}
HLlists
Int :: String :: Double :: HNil
就像一个超灵活的
(Int, (String, (Double, ())))
副产品
Int :+: String :+: Double :+: CNil
就像
Either[Int, Either[String, Either[Double, Nothing]]]
类型标签
Int @@ NonNegative
是 Int
的零成本运行时模拟,在标签类型中记住一些信息
Is zero-cost runtime analog of Int
with some information remembered in tag type
正如 Archeg 提到的那样,还有更多
as Archeg mentioned has even more of them
String \/ Long
scala 的 Either[String,Long]
是更酷的版本,请在这里阅读更多
Is cooler version of scala's Either[String,Long]
, read more here
Boolean \&/ Long
是
Either[(Boolean, Long), Either[Boolean, Long]]
地图
String ==>> Double
是
collection.immutable.TreeMap[String, Double]
Monoid Coproduct
String :+: Float
是事物的交替列表,其中聚合相似的事物(添加、连接、选择的最大值等)而不是排序
is alternated list of things, where similar things are aggregated (added, concatenated, choosed max, etc.) instead of sequencing
这篇关于Scala 中缀类型的真实例子的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!