|
|
|
# Proposal: NegationBindsTightly
|
|
|
|
|
|
|
|
<table><tr><th> Ticket </th>
|
|
|
|
<th>\#999</th></tr>
|
|
|
|
<tr><th> Dependencies </th>
|
|
|
|
<th> names of other proposals on which this one depends
|
|
|
|
</th></tr>
|
|
|
|
<tr><th> Related </th>
|
|
|
|
<th>[NegativeSyntax](negative-syntax)</th></tr></table>
|
|
|
|
|
|
|
|
## Compiler support
|
|
|
|
|
|
|
|
|
|
|
|
None at present
|
|
|
|
|
|
|
|
## Summary
|
|
|
|
|
|
|
|
|
|
|
|
Which of these definitions are correct Haskell?
|
|
|
|
|
|
|
|
```wiki
|
|
|
|
x1 = 4 + -5
|
|
|
|
x2 = -4 + 5
|
|
|
|
x3 = 4 - -5
|
|
|
|
x4 = -4 - 5
|
|
|
|
x5 = 4 * -5
|
|
|
|
x6 = -4 * 5
|
|
|
|
```
|
|
|
|
|
|
|
|
|
|
|
|
Ghc accepts x2, x4, x6 and rejects the others with a message like
|
|
|
|
|
|
|
|
```wiki
|
|
|
|
Foo.hs:4:7:
|
|
|
|
Precedence parsing error
|
|
|
|
cannot mix `+' [infixl 6] and prefix `-' [infixl 6] in the same infix expression
|
|
|
|
```
|
|
|
|
|
|
|
|
|
|
|
|
Hugs and Helium accept them all. I think that Hugs is right here. After all, there is no ambiguity in any of these expressions. And an application-domain user found this behaviour very surprising.
|
|
|
|
|
|
|
|
## Description
|
|
|
|
|
|
|
|
|
|
|
|
Make unary minus bind more tightly than any other operator. But not more tightly than function application.
|
|
|
|
|
|
|
|
## References
|
|
|
|
|
|
|
|
|
|
|
|
External references, papers, articles, support in other languages.
|
|
|
|
|
|
|
|
## Report Delta
|
|
|
|
|
|
|
|
|
|
|
|
Something like deleting
|
|
|
|
|
|
|
|
```wiki
|
|
|
|
lexp6 -> - exp7
|
|
|
|
```
|
|
|
|
|
|
|
|
|
|
|
|
and adding the production
|
|
|
|
|
|
|
|
```wiki
|
|
|
|
exp10 -> - fexp
|
|
|
|
```
|
|
|
|
|
|
|
|
|
|
|
|
but this relates to Haskell 98 rather than Haskell 2010, so the exact change will differ. |