On 10/5/12 7:11 AM, Johannes Waldmann wrote:
I was really surprised at the following:
*Main> 1 + 2 * 3
7
*Main> ( \ (+) (*) -> 1 + 2 * 3 ) (+) (*)
9
because I was somehow assuming that either
a) the Prelude fixities of the operators are kept
After dealing with how Coq handles infix operators, I'm profoundly glad
that Haskell doesn't do this. The fixity of an operator is a property of
the operator itself, not of the notation used to display the operator.
There's no reason for my (+) operator to have the same fixity as your
(+) operator, regardless of whether we happen to use the same notation
or not.
b) or they are undefined, so the parser rejects.
but the Haskell standard says "Any operator lacking a fixity declaration
is assumed to be infixl 9". This really should be "infix 9"?
Yep, default fixity. As Roman Cheplyaka mentioned, this is especially
helpful for ad hoc uses of backticks. (For non-adhoc uses, it's best to
give an explicit fixity just like for other infix operators.)
As for whether the default should be "infix 9" instead of "infixl 9", I
dunno...
--
Live well,
~wren
_______________________________________________
Haskell-Cafe mailing list
[email protected]
http://www.haskell.org/mailman/listinfo/haskell-cafe