You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
This repository has been archived by the owner on Oct 18, 2021. It is now read-only.
Within the pre-parse/context system, we should warn in various circumstances if the indentation is a little wobbly. We already have such a warning for silly ins:
let x =()in x
(* ^ Produces a warning, as the in should be aligned with the let *)
However, there are other forms we could also warn on:
Misaligned and
let a =()and b =2(* ^ Produce a warning here *)in x
One thing to be aware of here, is that we shouldn't warn when one has multiple ands on one line: only the first one for each line should be considered.
Misaligned |
Similar to above, but for matches and functions - all |s should be aligned, unless they are on the same line. One thing to be aware of is that they do not have to align with the parent expression (though obviously it's prettier if they do).
Offside expressions
We should warn when an expression appears to the left of one parent's offside location. Some examples:
let()=let x = (
2(* Offside compared with x, but won't be picked up as it's inside a parenthesis. ) in x
let()=letx=function
| _ -> ()(* Similar to above *)
I think the cleanest rule here is just "should not occur to the far left of the line which started the parent context". This is a bit verbose, but probably is the most flexible while still resulting in sane code.
Automatic correction
One awesome thing to try would be proving a way to automatically fix indentation warnings in the source code. However, I suspect we'd have to look into providing some sort of framework for transforming code while still preserving formatting, which is a long way away.
The text was updated successfully, but these errors were encountered:
Within the pre-parse/context system, we should warn in various circumstances if the indentation is a little wobbly. We already have such a warning for silly
in
s:However, there are other forms we could also warn on:
Misaligned
and
One thing to be aware of here, is that we shouldn't warn when one has multiple
and
s on one line: only the first one for each line should be considered.Misaligned
|
Similar to above, but for
match
es andfunction
s - all|
s should be aligned, unless they are on the same line. One thing to be aware of is that they do not have to align with the parent expression (though obviously it's prettier if they do).Offside expressions
We should warn when an expression appears to the left of one parent's offside location. Some examples:
I think the cleanest rule here is just "should not occur to the far left of the line which started the parent context". This is a bit verbose, but probably is the most flexible while still resulting in sane code.
Automatic correction
One awesome thing to try would be proving a way to automatically fix indentation warnings in the source code. However, I suspect we'd have to look into providing some sort of framework for transforming code while still preserving formatting, which is a long way away.
The text was updated successfully, but these errors were encountered: