Currently, this is produced by the autoformatter:
val _ =
f x + case g x of
nil => 0
| x :: xs => x + List.length xs
I'm not sure if it should change, though.
One principle I'm thinking we might want to adopt is:
Modifying code should not move independent code.
This would help modification to formatted code maintain a diff primarily relevant to the code which was actually modified.
Using the current style, modifying the expression f x (e.g., turning it into (f x * 2), or separately renaming f to fLongerName) would move the entire case expression forward, which seems somewhat undesirable since the case branches haven't changed at all.
One idea would be to have the style be
which may be grouped if possible; this is consistent with how other infix operators are used (such as |>), and it makes sure the infix operator doesn't get lost at the end of a line.
One downside to this style is that renaming the infix operator itself could move blocks of code; not sure if there's a good fix to this aside from
which seems a bit verbose.
Currently, this is produced by the autoformatter:
I'm not sure if it should change, though.
One principle I'm thinking we might want to adopt is:
This would help modification to formatted code maintain a diff primarily relevant to the code which was actually modified.
Using the current style, modifying the expression
f x(e.g., turning it into(f x * 2), or separately renamingftofLongerName) would move the entirecaseexpression forward, which seems somewhat undesirable since the case branches haven't changed at all.One idea would be to have the style be
which may be grouped if possible; this is consistent with how other infix operators are used (such as
|>), and it makes sure the infix operator doesn't get lost at the end of a line.One downside to this style is that renaming the infix operator itself could move blocks of code; not sure if there's a good fix to this aside from
which seems a bit verbose.