Prefix negation

Bjorn Lisper lisper@it.kth.se
Wed, 29 Aug 2001 17:00:48 +0200 (MET DST)


John Peterson:
>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

Hmm, any reason not to parse -x as (0-x) rather than 0-x? Then, -3 ^ 2 would
translate to (0-3) ^ 2.

Björn Lisper