fixity resolution
Christian Maeder
Christian.Maeder at dfki.de
Wed Jul 7 13:03:09 EDT 2010
Simon Marlow schrieb:
[...]
>> 1. "- 1 * 1" is accepted as legal pattern, but differently resolved for
>> expressions! Should one not reject these (rare) patterns, too?
>
> That's the GHC bug, right?
Yes!
>> 2. I would rather allow "1 * - 1" and "1 + - 1" to be legal as
>> expressions (with its unambiguous interpretation).
>
> Yes, me too, but that's a matter for a new proposal.
>
>> 3. Associativity should not matter for the non-binary "-"!
>>
>> So the following resolutions are possible:
>>
>> "1 + - 2 + 3" ~~~> "(1 + -2) + 3"
>> "1 + - 2 * 3" ~~~> "1 + -(2 * 3)"
>>
>> infix 6 ## -- same precedence like "+" but different associativity
>>
>> "- 1 ## 2" ~~~> "(-1) ## 2"
>
> Yes, again I agree. The current fixity resolution is more strict than
> it needs to be. The intention in Haskell 2010 was not to change the way
> fixity resolution worked, but rather to avoid the problems caused by
> having it as part of the grammar.
The grammar (in particular an ambiguous one) describes a superset of the
language and need not change with a changed fixity resolution (or type
analysis).
>
> If you make a proposal to change this, then I would probably support it.
A larger case would be "1 * - 2 * 3",
that I would resolve to "1 * - (2 * 3)" by resolving everything after
"-" first. This is sort of an arbitrary choice, but probably ok and in
the same spirit than resolving "- 2 * 3" to "- (2 * 3)".
C.
More information about the Haskell-prime
mailing list