Where is the source for: “Function application has higher precedence than infix operators” [Haskell]

匆匆过客 提交于 2020-01-04 07:26:45

问题


I'm learning about operator precedence in Haskell. Several places across the web mention that function application has higher precedence than operators, but I couldn't find a definitive source for that.

Here is one such mention from A Gentle Introduction To Haskell:

Function application has higher precedence than any infix operator

There is a section in the Haskell 98 Report that alludes to it:

normal constructor application has higher precedence than infix constructor application

Where is a definitive source? I would expect it to be included in the Haskell 98 Report, perhaps I'm not reading it correctly.


回答1:


You can find it here in the EBNF:

exp^10 -> ...
        | fexp

fexp -> [fexp] aexp

which basically means that function application has precedence 10, higher than any you are allowed to give to an operator.




回答2:


The Haskell Report is itself a definitive reference, so the quote you found is sufficient.

You can also find the same information in the grammar.

fexp -> [fexp] aexp
exp_10 -> ... | fexp

You can see that function application has precedence "10" whereas all the infix / prefix operators are 9 or lower.



来源:https://stackoverflow.com/questions/39750651/where-is-the-source-for-function-application-has-higher-precedence-than-infix

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!