在学习Haskell时,我发现这个问题的答案非常有用,因为它将概念与运算符联系起来:Are there pronounceable names for common Haskell operators?
是否有scalaz的等效词典?或者有人可以帮助提供有关他们如何发出自己的scalaz代码的建议吗?
答案 0 :(得分:23)
Scalaz恰好有一个用于Intellij兼容性的模板生成器,它具有很多scalaz运算符的运算符和通用名称,你只需要查看一下代码(并且可能翻译一些unicode): https://github.com/scalaz/scalaz/blob/release/6.0.4/etc/intellij/livetemplate/generate-live-templates.scala
来自档案:
method("map", "∘", Param("f")),
method("map2", "∘∘", Param("f")),
method("o", "∘", Param("f")),
method("oo", "∘∘", Param("f")),
method("|->", "↦", Param("f")),
method("bind", "∗", Param("f")),
method("plus", "⊹", Param("a")),
method("appendpure", "\u279C:", Param("a")),
method("pluspure", "\u279D:", Param("a")),
method("sum", "∑"),
method("suml", "∑"),
method("exists", "∃", Param("f")),
method("forall", "∀", Param("f")),
method("traversemonoid", "↣", Param("f")),
method("join", "μ"),
method("contramap", "∙", Param("f")),
method("pure", "η"),
function("kleisli", "☆", Param("f")),
function("cokleisli", "★", Param("f")),
method("dual", "σ"),
method("equal", "≟", Param("a")),
method("notequal", "≠", Param("a")),
method(">>>", "⋙", Param("a")),
method("<<<", "⋘", Param("a")),
function("undefined", "⊥"),
method("^", "∧", Param("a")),
method("conjunction", "∧", Param("a")),
method("disjunction", "∨", Param("a")),
method("v", "∨", Param("a")),
method("<==", "\u21D0", Param("a")),
method("zipstream", "\u0290"),
method("mult", "\u220f"),
function("zero", "∅"),
function("x", "×"),
function("=>", "\u21D2"),
method("3", "∋", Param("a")),
method("contains", "∋", Param("a")),
method("memberof", "∈:", Param("a"))
答案 1 :(得分:11)
对我来说最常用的一些:
∘
和∙
分别是map
和contramap
的别名。但是,我只对函数Functor
的{{1}}实例使用这些别名,因此我将它们称为compose。((->) a)
和↦
- traverse |->
(来自scalaz 6) - 底部⊥
和⊹
- 加上,mappend |+|
- 零∅
- bind >>=
- fish >=>
和===
) - 只等于/不等于/==
(来自scalaz 6) - 双σ
- 阅读recent post by Tony Morris后,将其称为“星舰运营商”答案 2 :(得分:6)
|@|
是Applicative Builder运算符:
scala> (some(3) |@| some(4)) { _ + _ }
res1: Option[Int] = Some(7)
我喜欢把它想象成“切尔西包子操作员”(它们是带有方形边缘和螺旋形中间的糕点)。
它有一个Unicode变体⊛
,我通常会避免使用它,因为它在较小的字体大小时呈现为模糊不清的斑点。