# H98 Report: expression syntax glitch

**Malcolm Wallace
**
Malcolm.Wallace@cs.york.ac.uk

*Mon, 25 Feb 2002 16:30:24 +0000*

>* Yes, but it reports type errors for the variants
*>* f x = (\x -> x*x .)
*>* g x = (if x then 1 else 2 +)
*>* and it accepts
*>* h = (let op x y = y in 3 `op`)
*>* so I suspect it's misparsing these as
*>* f x = (\x -> (x*x .))
*>* g x = (if x then 1 else (2 +))
*>* h = (let op x y = y in (3 `op`))
*
But I would claim that nhc98 is parsing these correctly, at least
according to section 3 of the Report.
" The grammar is ambiguous regarding the extent of lambda
abstractions, let expressions, and conditionals. The ambiguity is
resolved by the meta-rule that each of these constructs extends
as far to the right as possible. As a consequence, each of these
constructs has two precedences, one to its left, which is the
precedence used in the grammar; and one to its right, which is
obtained via the meta-rule. "
In the table of precedence in the original Report (now deleted in
the revised Report), it makes it clear that a rightward-extending
let, if, or lambda has a lower precedence than an infix operator,
so for instance the parse
h = (let op x y = y in (3 `op`))
is correct and
h = ((let op x y = y in 3) `op`)
is not.
Regards,
Malcolm