使用括号来消除像 `liftM b ap c` 这样的表达式的歧义

Use parentheses to disambiguate an expression like `liftM b ap c`

在 Haskell 中,以下工作:

> (+) `liftM` (Just 3) `ap` (Just 5)
Just 8

Frege 提示使用括号:

frege> (+) `liftM` (Just 3) `ap` (Just 5)
E <console>.fr:12: invalid expression, none-associative operator liftM
    found on same level as none-associative operator ap
H <console>.fr:12: Use parentheses to disambiguate an expression like a
    liftM b ap c

我在 Haskell report 中找到了这个部分:

Expressions involving infix operators are disambiguated by the operator's fixity (see Section 4.4.2). Consecutive unparenthesized operators with the same precedence must both be either left or right associative to avoid a syntax error. Given an unparenthesized expression "x qop(a,i) y qop(b,j) z", parentheses must be added around either "x qop(a,i) y" or "y qop(b,j) z" when i=j unless a=b=l or a=b=r.

在上面的代码中,"operators" 都没有关联性并且具有相同的默认优先级,因此 Frege 的行为似乎与 Haskell 报告一致。

我理解的对吗?为什么 Frege 在这种情况下需要括号,而 Haskell 能够消除歧义?或者 Haskell 在这种情况下如何消除歧义?

嗯,这是因为,就目前而言,`foo` 在 Frege 中默认为 non-associativity,而在 Haskell 中是左结合性。

这应该在 Frege 编译器中更正,以使其更 Haskell 兼容。