[EMAIL PROTECTED] (Kevin Hammond) writes:
> Isn't it rather that the report doesn't need to say this explicitly,
> since it's covered by the general rule noted below (i.e., the
> '(' below the case introduces a '}' and a ';', and the case is thus illegal
> [or odd!] according to the report). The expanded parse is
>
> do { case a of {}; (Just x,_) -> return x; _ -> error "hey"; }
I don't think this is right: the original expression was
f a
= do
case a of
(Just x, _) -> return x
_ -> error "hey"
The '(' *doesn't* insert a '}', because it is setting the indentation
for the scope. A subsequent line with a smaller indentation will
insert two '}''s.
Lennart points out that the report doesn't require the enclosing scope
to suspend during the inner scope: quite right, but it doesn't make
any sense unless you require that scopes are strictly increasing
indentation-wise. eg. the parse would be
do { case a of { ; (Just x, _) -> return x; ; _-> error "hey" }}
with the extra semicolons being inserted due to the 'do' scope.
There are two options: either
a) only the inner scope can generate tokens, or
b) a new scope must be more indented than the previous one
obviously b) implies a). I implemented a) in the Happy Haskell Parser.
> >> f a
> >> = do
> >> if x then
> >> y
> >> else
> >> z
This seems useful, it could probably be implemented by suspending
layout processing until the 'else' had been parsed. Anyone know how
Hugs parses layout?
Cheers,
Simon
--
Simon Marlow [EMAIL PROTECTED]
University of Glasgow http://www.dcs.gla.ac.uk/~simonm/
finger for PGP public key