
Simon Marlow schrieb:
On 07/07/10 16:56, Christian Maeder wrote:
Simon Marlow schrieb:
prefix negation should move to lexp to be consistent with lpat
prefix negation should not move to lexp, because this would rule out "- 1 ^ 2" as negated infix expression "- (1 ^ 2)",
It wouldn't - remember the grammar just parses infix expressions as a list, they get rearranged by fixity resolution.
I'm arguing that the current grammar is halfway between two consistent positions: one in which prefix negation is lexp, the other is your proposal to make the grammar ambiguous. So we should do one or the other.
How about a rule like: infixexp -> [-] lexp { qop [-] lexp } to stress the sequence of tokens for fixity resolution and to avoid the impressions of wrong trees (as moving "-" into lexp would).
whereas a negated infix pattern is impossible. Unary minus is no constructor and cannot be defined. The latter should be (or is already?) mentioned somewhere.
It should be mentioned in the report that the strongly binding prefix minus in patterns can be rejected by fixity resolution! Otherwise it is not clear if accepting "-1 * -2" (as pattern) is a (ghc) bug or an accidental (language) feature. Cheers Christian
You could move prefix negation to lexp, if you allow the fixity resolution to construct negated infix expression that are not covered by the grammar (as currently happens anyway).
Right, that's what I'm saying. No change needed to fixity resolution, just move prefix negation into lexp.
Moving prefix negation from lpat to pat to be consistent with infixexp would be overkill, though.
Yes.
Cheers, Simon