Wed, 29 Aug 2001 16:16:39 +0100
> (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=20
> -3 ^ 2 translates to 0 - 3 ^ 2=20
Slight correction: '-e' is in fact replaced by 'negate e', after fixity
resolution, where negate is a method in class Num. The default
definition of negate is 'negate x =3D 0 - x', but there's no requirement
that it means this in general.
The above example parses as '-(3^2)' because ^ has a higher precedence
than unary '-' (8 vs. 7). Translation turns the expression into 'negate
(3^2)'. Someone else will have to comment on *why* the precedences are
ordered this way, though.