Haskell Precedence: Lambda and operator

前端 未结 2 1489
后悔当初
后悔当初 2021-02-05 08:53

I found precedence and associativity is a big obstacle for me to understand what the grammar is trying to express at first glance to haskell code.

For example,



        
2条回答
  •  孤独总比滥情好
    2021-02-05 09:27

    The rule for lambdas is pretty simple: the body of the lambda extends as far to the right as possible without hitting an unbalanced parenthesis.

    f (\x -> foo (bar baz) *** quux >>= quuxbar)
             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
                           body
    

提交回复
热议问题