# Changes between Version 1 and Version 2 of PrefixMinusResolution

Show
Ignore:
Timestamp:
07/13/10 08:25:56 (3 years ago)
Comment:

corrections and refs

Unmodified
Removed
Modified
• ## PrefixMinusResolution

v1 v2
1616== Summary ==
1717
18 Resolve more prefix minus application unambiguously.
18Resolve more prefix minus application unambiguously by:
1919
20 As described in NegationBindsTightly ghc rejects same terms
201. Considering only operators to the right of prefix negation.
21
222. Leave prefix minus bind less tight than multiplication.
23
243. Do not consider associativity of prefix minus or (alternative formulation) let prefix minus bind a bit stronger than infix minus.
25
26== Description ==
27
28As described in NegationBindsTightly ghc rejects some terms
2129that are accepted by Hugs and Helium and should not be rejected in general.
2230However, making negation bind more tightly is not the proposed solution here, because

2735This condition ensures that "4 * -5" is not rejected (as ghc does).
2836
29 2. Prefix minus should bind less tight than multiplication but (slightly) stronger than addition and subtraction.
372. Prefix minus should bind less tight than multiplication but ...
38
393. .. (slightly) stronger than addition and subtraction.
3040
3141The latter condition ensures that "- x # ..." is resolved as "(- x) # ..." for any operator # with lower precedence than multiplication.

3848{{{
3949infix # 6
40 (#) = undefined
41 x7 = -4 # 5
42 x8 = 4 # -5
50(#) = (-)
51x7 = - 4 # 5
4352}}}
4453
45 x7 and x8 should be accepted, too. They are currently rejected by Hugs and ghc.
54x7 are currently rejected by Hugs and ghc. Two solutions are possible. Since "-" should just bind weaker than multiplication the possibility "-(4 # 5)" cannot be justified, thus "(-4) # 5" should be the unique solution.
4655
47 As an option it is possible to support multiple prefix minus application. ("4 * - - 5" can be resolved in the same way as
56Surely, one can always disallow "confusing" resolutions, but if we reject "- 4 # 5", we can also reject "- 4 - 5" or "`- 4 ^ 5`".
57Associativity seems wrong to consider for the unary minus function. (But it is an option to simple use the way of Hugs for ghc, too.)
58
59As a further option it is possible to support multiple prefix minus application. ("4 * - - 5" can be resolved in the same way as
4860"4 * - 5" is).
61
62== References ==
4963
5064For other examples see