Prefix negation

John Peterson peterson-john@cs.yale.edu
Wed, 29 Aug 2001 10:37:27 -0400


(Moved to haskell-cafe)

Syntacticly, -x parses as 0-x.  That is, there is only one -
operator and the "0" is filled in when it is encountered in a unary
position.  Thus 

  -3 ^ 2 translates to 0 - 3 ^ 2 

There were many arguments on either side of this debate but I would
have to dig deep into the archives to remember what they were.  This is
certainly a potential source of confusion!

Anyway, experienced Haskellers always add parens around unary minus to
avoid any ambiguity: (-3) ^ 2

  John