反引号操作符的固定性? [英] Fixity of backtick operators?

查看:182
本文介绍了反引号操作符的固定性?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

反引号操作符的固定性是什么? 例如,在 code> ghci的> (1+)`fmap` [1,2,3] ++ [4,5,6]
[2,3,4,4,5,6]

显而易见,反向操作符`fmap` 的固定性高于 ++ ,但没有任何由GHCi提供 Haskell报告指出:
$ b blockquote>

任何缺乏固定声明的操作符都被认为是infixl 9


任何运算符都包含反引号中的正常函数名称。



您的示例显示<因为 ++ `fmap` 确实比 ++ c>作用于 fmap 的结果。


What is the fixity of backtick operators?

For instance in this code from Real World Haskell:

ghci> (1+) `fmap` [1,2,3] ++ [4,5,6]
[2,3,4,4,5,6]

It's evident the backtick operator `fmap` has a higher fixity than ++, but none is given by GHCi.

解决方案

§4.4.2 of the Haskell Report states that

Any operator lacking a fixity declaration is assumed to be infixl 9

"Any operator" includes normal function names in backticks.

Your example shows that `fmap` does have higher fixity than ++, because ++ acts on the result of the fmap.

这篇关于反引号操作符的固定性?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆