Opened 13 years ago

Last modified 3 years ago

#50 new removal

get rid of unary '-' operator

Reported by: ijones Owned by:
Priority: normal Milestone:
Version: Keywords:
Cc: Meta Owner:
State: discussion Section: N/A or multiple
Related Tickets:


Change History (6)

comment:1 Changed 13 years ago by


  • Removes an embarrassing special case from the grammar.
  • Makes the section (- x) work as expected.
  • Expressions such as -123 would not require parentheses (foo (-1) could be written simply as foo -1)
  • Expressions such as -1 would be permitted in k-patterns even if n+k patterns end up being thrown out.
  • You can say negate $ 1 + 2 if you don't like parentheses.
  • Some may argue that it is a bad idea to give lexical significance to the space between - and its argument lexically, that is, to give (- 1) and (-1) a different meaning. However, the precedent for reusing an infix operator symbol as a part of a symbol has already been made in two places in the Haskell 98 standard, namely in the cases of . operator (which is also used to separate module components) and +/- in the floating point notation (1E-5). Further, arguably expressions such as - 123 (with a space) seldom appear in real-life code.
  • Other extensions (unboxed types) already append an operator symbol to identifiers: giving (- 1) and (-1) different meanings is no more confusing than having different meanings for (Int#) and (Int #)


  • Expressions of the form -x (where x is not a constant) need to be rewritten as negate x, although the later is arguably much more cleaner, especially since, more often than not, x is a complex paranthesized expression rather than a simple variable name.
  • Possible confusion to the beginners (we can write -1 but not -x.) However, I think that the strange behaviour of sections and the need for parentheses around -1 is already confusing enough to beginners, and therefore this change would actually make Haskell easier to learn, not harder. negate x looks so much more like ordinary Haskell code!

comment:2 Changed 13 years ago by ijones@…

topic: Syntax

comment:3 Changed 13 years ago by ijones

topic: SyntaxLexical Syntax

comment:4 Changed 3 years ago by Herbert Valerio Riedel


moving non-milestoned many year old legacy tickets out of the way

comment:5 Changed 3 years ago by Herbert Valerio Riedel

Priority: majornormal

Set default priority (as this confuses Trac otherwise)

comment:6 Changed 3 years ago by Herbert Valerio Riedel

Owner: john@… deleted

remove owners from legacy tickets

Note: See TracTickets for help on using tickets.