| ... | ... | @@ -126,7 +126,25 @@ Python's power operator binds more tightly than unary operators on its left, [ h |
|
|
|
**
|
|
|
|
|
|
|
|
|
|
|
|
My point 3. is backed by the fact that "in case of doubt" prefix application should bind stronger than infix application.
|
|
|
|
My point 3 above is backed by the fact that "in case of doubt" prefix application should bind stronger than infix application.
|
|
|
|
|
|
|
|
## Remarks
|
|
|
|
|
|
|
|
1. haskellch4.html\#x10-820004.4.2 "4.4.2 Fixity Declarations" states:
|
|
|
|
|
|
|
|
|
|
|
|
"Any operator lacking a fixity declaration is assumed to be infixl 9"
|
|
|
|
|
|
|
|
|
|
|
|
This (surprisingly) makes "`- a `f` b`" resolve as "`- (a `f` b)`" for any f without fixity declaration (independent of this proposal). This contradicts [NegationBindsTightly](negation-binds-tightly).
|
|
|
|
|
|
|
|
1. A pattern like "`- 1 `f` b`" must be rejected for ``f`` with higher precedence (than 6), because prefix minus is only allowed as part of a constant (see [ http://hackage.haskell.org/trac/ghc/ticket/4176](http://hackage.haskell.org/trac/ghc/ticket/4176))
|
|
|
|
|
|
|
|
1. As a compromise it is also an option to simple reject terms where prefix minus would not bind tightly (enough), which makes sense for `-a ^ b` and would force us to write `-(a ^ b)` or `(-a) ^ b` explicitly.
|
|
|
|
|
|
|
|
1. One would not want to reject "-a \* b", no matter how it is resolved, but it would make a difference for ``mod``, i.e. `- 1 `mod` 4`!
|
|
|
|
|
|
|
|
1. An incompatible fix for remark 1 would be to choose a different default precedence, i.e. 6. But since (in my eyes) ``mod`` is resolved the wrong way currently and we make incompatible changes anyway, it would make sense to increase the precedence of prefix minus to be just higher than multiplication (but still lower than exponentiation) and set the default precedence to 7 (like for multiplication).
|
|
|
|
|
|
|
|
## Report Delta
|
|
|
|
|
| ... | ... | @@ -159,21 +177,3 @@ The operator to the left of prefix -, if there is one, is irrelevant for resolut |
|
|
|
|
|
|
|
|
|
|
|
(Use the algorithm from [ http://hackage.haskell.org/trac/ghc/ticket/4180](http://hackage.haskell.org/trac/ghc/ticket/4180)) |
|
|
|
|
|
|
|
### Remarks
|
|
|
|
|
|
|
|
1. haskellch4.html\#x10-820004.4.2 "4.4.2 Fixity Declarations" states:
|
|
|
|
|
|
|
|
|
|
|
|
"Any operator lacking a fixity declaration is assumed to be infixl 9"
|
|
|
|
|
|
|
|
|
|
|
|
This (surprisingly) makes "`- a `f` b`" resolve as "`- (a `f` b)`" for any f without fixity declaration (independent of this proposal). This contradicts [NegationBindsTightly](negation-binds-tightly).
|
|
|
|
|
|
|
|
1. A pattern like "`- 1 `f` b`" must be rejected for ``f`` with higher precedence (than 6), because prefix minus is only allowed as part of a constant (see [ http://hackage.haskell.org/trac/ghc/ticket/4176](http://hackage.haskell.org/trac/ghc/ticket/4176))
|
|
|
|
|
|
|
|
1. As a compromise it is also an option to simple reject terms where prefix minus would not bind tightly (enough), which makes sense for `-a ^ b` and would force us to write `-(a ^ b)` or `(-a) ^ b` explicitly.
|
|
|
|
|
|
|
|
1. One would not want to reject "-a \* b", no matter how it is resolved, but it would make a difference for ``mod``, i.e. `- 1 `mod` 4`!
|
|
|
|
|
|
|
|
1. An incompatible fix for remark 1 would be to choose a different default precedence, i.e. 6. But since (in my eyes) ``mod`` is resolved the wrong way currently and we make incompatible changes anyway, it would make sense to increase the precedence of prefix minus to be just higher than multiplication (but still lower than exponentiation) and set the default precedence to 7 (like for multiplication). |