Changes between Version 1 and Version 2 of PrefixMinusResolution
 Timestamp:
 Jul 13, 2010 3:25:56 PM (5 years ago)
Legend:
 Unmodified
 Added
 Removed
 Modified

PrefixMinusResolution
v1 v2 16 16 == Summary == 17 17 18 Resolve more prefix minus application unambiguously .18 Resolve more prefix minus application unambiguously by: 19 19 20 As described in NegationBindsTightly ghc rejects same terms 20 1. Considering only operators to the right of prefix negation. 21 22 2. Leave prefix minus bind less tight than multiplication. 23 24 3. Do not consider associativity of prefix minus or (alternative formulation) let prefix minus bind a bit stronger than infix minus. 25 26 == Description == 27 28 As described in NegationBindsTightly ghc rejects some terms 21 29 that are accepted by Hugs and Helium and should not be rejected in general. 22 30 However, making negation bind more tightly is not the proposed solution here, because … … 27 35 This condition ensures that "4 * 5" is not rejected (as ghc does). 28 36 29 2. Prefix minus should bind less tight than multiplication but (slightly) stronger than addition and subtraction. 37 2. Prefix minus should bind less tight than multiplication but ... 38 39 3. .. (slightly) stronger than addition and subtraction. 30 40 31 41 The latter condition ensures that " x # ..." is resolved as "( x) # ..." for any operator # with lower precedence than multiplication. … … 38 48 {{{ 39 49 infix # 6 40 (#) = undefined 41 x7 = 4 # 5 42 x8 = 4 # 5 50 (#) = () 51 x7 =  4 # 5 43 52 }}} 44 53 45 x7 a nd x8 should be accepted, too. They are currently rejected by Hugs and ghc.54 x7 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. 46 55 47 As an option it is possible to support multiple prefix minus application. ("4 *   5" can be resolved in the same way as 56 Surely, one can always disallow "confusing" resolutions, but if we reject " 4 # 5", we can also reject " 4  5" or "` 4 ^ 5`". 57 Associativity 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 59 As a further option it is possible to support multiple prefix minus application. ("4 *   5" can be resolved in the same way as 48 60 "4 *  5" is). 61 62 == References == 49 63 50 64 For other examples see 51 65 http://www.haskell.org/pipermail/haskellprime/2010July/003229.html 52 66 67 Mixfix analysis [Aasa95] usually only considers the toplevel operators of argument terms. 68 This backs my point 1. above: Do not look to the left of prefix minus, because there is no argument of prefix minus. 53 69 54 == Description == 70 Also Isabelle (http://isabelle.in.tum.de/) allows prefix operators to have lower precedence than infix operators. 71 Other specification languages (like HasCASL) do so, too. For instance the logical prefix negation binds stronger than logical connectives but weaker than infix equality or other comparisons. (This does not apply to the "not" in Haskell, because "not" is a plain function, no operator). 55 72 56 57 == References == 73 My point 3. is backed by the fact that "in case of doubt" prefix application should bind stronger than infix application. 58 74 59 75