4 ms·
Haskell also inserts semicolons, but it has a different rule, which I think is a bit interesting. If the current line starts on the same line that the previous
by trealira 2y ago
Haskell also inserts semicolons, but it has a different rule, which I think is a bit interesting.
If the current line starts on the same line that the previous expression started on, then a semicolon is inserted at the beginning of the current line. There are also some messy rules about opening and closing braces being inserted.
So, this:
do expr1
expr2
do expr3
expr4
Ends up being parsed as though it were written like this:
do { expr1
; expr2
do { expr3
; expr4
}
}
If the next line is indented, it's just taken as a continuation of the previous line's expression, so nothing needs to happen.
[0]: https://amelia.how/posts/parsing-layout.html https://amelia.how/posts/parsing-layout.html