1
25
你是对的。此规则是Haskell语法定义的一部分。
Haskell Report
. 特别地,请注意第3节中的表达式,即函数应用程序的参数(AN)
在
我不得不承认,我从来没有考虑过这个问题,事实上,我必须在报告中查一下,看看为什么操作员会有他们所做的行为。 |
2
35
Firstly, application (whitespace) is the highest precedence "operator". 其次,在haskell中,运算符和函数之间实际上没有区别,除了默认情况下运算符是中缀,而函数不是。您可以使用反勾号将函数转换为中缀
So, your question is a bit confused.
Showing both precedence and associativity. |
3
15
In addition to the information provided by other answers already, note that different operators can have different precedences over other operators, as well as being left-/right- or non-associative.
You can find these properties for the
+--------+----------------------+-----------------------+-------------------+ | Prec- | Left associative | Non-associative | Right associative | | edence | operators | operators | operators | +--------+----------------------+-----------------------+-------------------+ | 9 | !! | | . | | 8 | | | ^, ^^, ** | | 7 | *, /, `div`, | | | | | `mod`, `rem`, `quot` | | | | 6 | +, - | | | | 5 | | | :, ++ | | 4 | | ==, /=, <, <=, >, >=, | | | | | `elem`, `notElem` | | | 3 | | | && | | 2 | | | || | | 1 | >>, >>= | | | | 0 | | | $, $!, `seq` | +--------+----------------------+-----------------------+-------------------+
记住,函数应用具有最高优先级(考虑优先级)
|
4
11
The difference is that infix operators get placed between their arguments, so this
can be rewritten in prefix form as
which, by the definition of the $ operator, is simply
|
5
9
Operators can be passed as function arguments if you surround them with parenthesis (i.e.
Also note that the syntax
|