[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Left hand sides and priorities.
Original-Via: uk.ac.ukc; Wed, 6 Mar 91 17:38:44 GMT
From: Kent Karlsson <kent@se.chalmers.cs>
Date: Wed, 6 Mar 91 18:29:11 +0100
To: haskell@cs.glasgow.ac.uk
Subject: Left hand sides and priorities.
Original-Sender: kent%se.chalmers.cs@sunic.sunet.se
Sender: haskell-request@cs.glasgow.ac.uk
LEFT HAND SIDES and PRIORITIES
==============================
On p. 32 the Haskell report says:
lhs -> ...
| apat1 varop apat2
| ( apat1 varop apat2 ) apat3 ... apatk (k >= 3)
Why must the argument patterns be "apat"s? In expressions and patterns
the priority (and associativity) of operators is used, why not in "lhs"s?
I.e. why not:
lhs -> ...
| pat1 varop pat2
| ( pat1 varop pat2 ) apat3 ... apatk (k >= 3)
Another priority issue, why is -2^2 equal to 4 while 0-2^2 is -4 ?
I find this rather surprising, as would any neophyte programmer... :-)
I think unary minus should have the *same* priority as binary minus. From
the point of view of the Haskell report: change exp -> - aexp
to exp -> - exp and state that unary and binary minus have the
same priority. (I.e. the parenthesis in -(e op e) can be dropped
if the priority of op is > 6; and in (-e) op e if the priority of
right or non-assoc op is < 6, or for a left assoc op its priority
is <= 6; and in e op (-e) if op has priority < 6.)
/kent k