I'm sure I'm missing something, but I'm having difficulty parsing or
reconciling Note 1 and Note 2 of Section 10.3 ("Layout") of the Haskell 2010
Language Report.
http://www.haskell.org/onlinereport/haskell2010/haskellch10.html#x17-17800010.3
Can somebody point me in the right direction?
To be clear, I'm not concerned with GHC behavior or best programming practices
here, only with the specification of the language given in the Report.
Note 1 says, "A nested context must be further indented than the enclosing
context ('n' > 'm'). If not, 'L' fails, and the compiler should indicate a
layout error."
Note 2 says, "If the first token after a 'where' (say) is not indented more
than the enclosing layout context, then the block must be empty, so empty
braces are inserted."
It seems that, in Note 2, the "first token" necessarily refers to a lexeme
other than '{' (else it would not make sense), in which case a '{n}' token will
have been inserted after 'where' (in the example given in the note), yielding a
nested context which is "not indented more than the enclosing layout context",
and thus failing the test in the first sentence of Note 1.
So, in the places where Note 2 would apply, it seems Note 1 would yield a
"layout error".
For example, in the following code (replace '.' with space),
f x = let
......g y = 2 * y
..........where
..g x
it seems that Note 1 would "layout error", yet this seems precisely the case
addressed by Note 2 wherein "{}" would be inserted after the 'where' yielding
syntactically correct (albeit strange) code.
Any insight would be appreciated.
Thanks,
Seth
_______________________________________________
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe