is there a formal grammar written out for Roc? If not, can someone give me a quick overview of how newlines function in the grammar? E.g. it seems newlines are an important part of backpassing.
Can you provide the specific example that's not working?
I don't have a problem with something not working, I'm more asking from a language design point of view, I'm interested to know what role newlines play in the grammar. I guess i can just keep playing with the language and find out, but I imagine that it's been thought through and wondered if someone could share some insight or explanation. E.g. (these are me working it out otoh so forgive mistakes) for D
you can say "newlines play no role in the grammar beyond being whitespace, with the exception of // comments
and shebangs. For ANSI C
you can say "after pre-processing, newlines play no role in the grammar beyond being whitespace". That sort of thing
we don't have a formal grammar...off the top of my head, the places where newlines are currently significant is:
=
) at the same indentation level is applied to that def (same as in Elm and Haskell)when
branches, backpassing, type alias declarations, and opaque type declarations must all begin after a newline (optionally indented)I think that's it, but there might be more I'm not thinking of. Also we've talked about introducing a simplifying/unifying concept of "blocks" based on indentation level, which wouldn't affect any current code I've seen written in practice, but which might simplify explaining the rules (among other potential benefits)
Last updated: Jul 06 2025 at 12:14 UTC