Second draft of the Haskell 2010 report available

Simon Marlow marlowsd at
Wed Jul 7 11:29:33 EDT 2010

On 07/07/2010 15:47, Christian Maeder wrote:
> Simon Marlow schrieb:
>> On 06/07/2010 13:17, Christian Maeder wrote:
>>> infixexp →     lexp qop infixexp (infix operator application)
>>>      |     - infixexp           (prefix negation)
>>>      |     lexp
>>> This grammar rule describes a right associative nesting of (any) infix
>>> operators "qop" and prefix negation as binding weaker than any infix.
>>> Thus a parser would create from "- 1 /= 1&&   a" the tree
>>>    "- (1 /= (1&&   a))".
>> The grammar is non-ambiguous and all you have to do is flatten the
>> result to apply fixity resolution.  I don't really see how generalising
>> the grammar would help - the tree still has to be flattened to apply
>> fixity resolution, and the parser would have to make an arbitrary choice
>> from one of the possible parses.  Or perhaps I'm missing something here?
> An ambiguous grammar (as abstract syntax for expressions) would cover
> the tree after fixity resolution, too.
> The non-ambiguous grammar only describes a temporarily wrong tree for
> fixity resolution.

Yes it does, intentionally.  But I see your point, and arguably the 
current grammar is inconsistent; prefix negation should move to lexp to 
be consistent with lpat (and to avoid the strange parse you point out 

I suppose my concern is that if we generalised the grammar, then we 
would have to also explain why the grammar was ambiguous and that a 
parser should pick a suitable parse before applying fixity resolution. 
As you say, it's a presentational point, I'm not against changing it.


More information about the Haskell-prime mailing list