On Mon, 2009-11-30 at 09:16 +0000, Simon Marlow wrote:
> On 29/11/2009 19:40, Duncan Coutts wrote:

> > Here's the main one it cannot cope with that bothers me:
> >
> > foo x = case bar x of
> >    Pattern1 ->  ...
> >    Pattern1 ->  ...
> >
> >    where
> >      baz = ...
> >
> > The new layout requires it to be:
> >
> > foo x = case bar x of
> >      Pattern1 ->  ...
> >      Pattern1 ->  ...
> >    where
> >      baz = ...
> 
> Right.  That one isn't fixable, because there's no way for the algorithm 
> to know that the 'where' should close the layout context introduced by 
> the 'case', without knowing more about the syntax.

Hmm, 'where' is a keyword though, so can't that be done at the lexical
level without having to tangle it with the parsing?

> If we were to keep extending the new layout rule to handle more of
> these cases by adding more knowledge about the Haskell grammar,
> eventually it would be the same as the current layout rule.

I wouldn't mind that, the behaviour of the current layout rule seems
fine from my point of view :-)

> The new code isn't really that much simpler, in that it's full of 
> special cases.  It is conceptually simpler in the sense that it is an 
> independent pass, rather than a collaboration between the parser and lexer.

I appreciate you want to be able to separate the lexer from the parser.
If we can do that without uglifying normal cases and only mess up a
couple very rarely used corner cases then I think that's fine.

Duncan

_______________________________________________
Cvs-ghc mailing list
[email protected]
http://www.haskell.org/mailman/listinfo/cvs-ghc

Reply via email to