[Haskell-cafe] Layout rule (was Re: PrefixMap: code reviewrequest)
Daniel Fischer
daniel.is.fischer at web.de
Mon Mar 6 10:26:42 EST 2006
Am Montag, 6. März 2006 12:30 schrieb Malcolm Wallace:
> Brian Hulley wrote:
> > However I think there is an error in the description of this in
> > section 2.7 of the Haskell98 report, which states:
> >
> > "If the indentation of the non-brace lexeme immediately following a
> > where, let, do or of is less than or equal to the current indentation
> > level, then instead of starting a layout, an empty list "{}" is
> > inserted, and layout processing occurs for the current level ..."
> >
> > I dispute the "or equal" in the above statement, since it seems to be
> > clearly in contradiction to what is actually being done.
>
> Section 2.7 does say that it is an informal description, so although it
> is correct, it is not complete. In the case of the module header, the
> question is really "what is the current indentation level?" (that we
> must be strictly greater than). The answer can be found in the formal
> definition of the layout rule in section 9.3. At the beginning of the
> module, there is _no_ current indentation level - thus the fourth
> equation of L applies.
>
> Regards,
> Malcolm
I think, the third from last equation of L applies, since
"If the first lexeme of a module is _not_ { or module, then it is preceded by
{n} where n is the indentation of the lexeme.", so we start L with
L ('module':ts) [].
Another thing that irritates me:
in section 9.5, we have the production
body -> { impdecls; topdecls }
| { impdecls }
| { topdecls }
The first line seems to suggest that import declaraions were admissible also
after topdecls, but any attempt to place an impdecl after a topdecl leads
--fortunately-- to a parse error in hugs and ghc, shouldn't the production be
body -> { impdecls }; { topdecls } ?
Cheers,
Daniel
--
"In My Egotistical Opinion, most people's C programs should be
indented six feet downward and covered with dirt."
-- Blair P. Houghton
More information about the Haskell-Cafe
mailing list