On 4/4/21 1:52 PM, Iavor Diatchki wrote:
Hi Alexis,

I wasn't sure what the "alternative layout" is either and did some googling, and it appears that it is something that was never really documented properly.   The following link contains pointers to the commit that introduced it (in 2009!) (not the main ticket but some of the comments)

Thanks, that’s a helpful pointer, though of course it still doesn’t explain very much. I’m still interested in understanding what the purpose of “alternative layout” is and how it operates, if anyone else has any idea.

Overall, I do think that Haskell's layout rule is more complicated than it needs to be, and this is mostly because of the rule that requires the insertion of a "virtual close curly" on a parse error.

Yes, this does seem to be by far the trickiest bit. But I’d be sad not to have it, as without it, even simple things like

   let x = 3 in e

would not be grammatically valid.

My feeling is that it'd be pretty tricky to do layout in the parser with grammar rules, but you may be able to do something with the parser state.

Yes, I have some vague ideas, but none of them are particularly fleshed out. It’s entirely possible that I just don’t understand the relationship between the lexer and the parser (which seems somewhat obscured by the “alternative layout” stuff), and the ideas I have are what’s already implemented today. I’ll have to study the implementation more closely.

In any case, thank you for your response! The ALR-related pointer certainly clarifies at least a little.

Alexis

_______________________________________________
ghc-devs mailing list
ghc-devs@haskell.org
http://mail.haskell.org/cgi-bin/mailman/listinfo/ghc-devs

Reply via email to