On 07/07/2010 10:09, Christian Maeder wrote:
Christian Maeder schrieb:
http://www.haskell.org/~simonmar/haskell-2010-draft-report-2/haskellch10.html#x17-17300010

"Fixity resolution also applies to Haskell patterns, but patterns are a
subset of expressions so in what follows we consider only expressions
for simplicity."

I suggest to change "also applies to Haskell patterns" to

"also applies to Haskell patterns and left hand sides of infix function
bindings"

The string "1 * - 1" is legal as pattern, but rejected as expression!

Further points:

1. "- 1 * 1" is accepted as legal pattern, but differently resolved for
expressions! Should one not reject these (rare) patterns, too?

That's the GHC bug, right?

2. I would rather allow "1 * - 1" and "1 + - 1" to be legal as
expressions (with its unambiguous interpretation).

Yes, me too, but that's a matter for a new proposal.

3. Associativity should not matter for the non-binary "-"!

So the following resolutions are possible:

"1 + - 2 + 3" ~~~>  "(1 + -2) + 3"
"1 + - 2 * 3" ~~~>  "1 + -(2 * 3)"

infix 6 ##  -- same precedence like "+" but different associativity

"- 1 ## 2" ~~~>  "(-1) ## 2"

Yes, again I agree. The current fixity resolution is more strict than it needs to be. The intention in Haskell 2010 was not to change the way fixity resolution worked, but rather to avoid the problems caused by having it as part of the grammar.

If you make a proposal to change this, then I would probably support it.

Cheers,
        Simon


An infix-expression following an unary minus is resolved independently
first. If the top-level operator has a strictly higher precedence than
"-" its resolved as minus term, otherwise the same procedure is applied
to the left argument of the infix expression. (If the left argument is
no infix expression, we are done by plain prefix application of minus.)


Furthermore fixity resolution does not distinguish between constructors
and other operators as it should according to the grammar:

pat      →      lpat qconop pat          (infix constructor)
        |       lpat


funlhs   →      var apat { apat }
        |       pat varop pat

add a description:
        |       pat varop pat           (infix binding)

        |       ( funlhs ) apat { apat }


"a : b * c : d = undefined" is currently rejected with:

A similar example is given in 4.4.3.1  Function bindings. It should be
referenced in 10.6  Fixity Resolution

Cheers Christian


"cannot mix `:' [infixr 5] and `Main.*' [infixl 9] in the same infix
expression"

but should be fine by the given grammar (rule "pat varop pat").

Cheers Christian

P.S. like in my proposal for infixexp I would change pat to:

pat      →      pat qconop pat           (infix constructor)
        |       lpat

for the sake of a better presentation only.
_______________________________________________
Haskell-prime mailing list
Haskell-prime@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-prime

_______________________________________________
Haskell-prime mailing list
Haskell-prime@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-prime

Reply via email to