-
-
Notifications
You must be signed in to change notification settings - Fork 194
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Mutable expressions should be on one line #2280
Comments
It may depend on particular code example and context, and it's possible to imagine cases where a user would want to have this written as single-line and as multiline. let f x =
if condition1 x then x <- expr1
if condition2 x then x <- expr2
if condition3 x then x <- expr3
x let f x =
expr1 arg1 arg2
if condition then
x <- expr2
expr arg3 arg4 What we do in R# formatter for C# and other languages is we try to keep original code unless it violates the chosen formatter settings, because in many places these small stylistic choices are allowed by the style guide and are what makes the code easier to read or helps to convey the meaning by highlighting important or hiding unimportant parts. |
R# formatter approach sounds nice, but I guess would need some re-design from Fantomas side, basically to carry the full original source code as trivia? Or do you have some data-structure of "allowed flexibility"? |
Hello, the style guide does not mention anything about how the mutable expression should react relative to its placement. The line Stylistic bugs in Fantomas need to be reported in the online tool as well, accompanied with the actual link to the section of the style guide which is not respected. |
@Thorium See decision here: fsharp/fslang-design#663 (comment) |
F# Style-guide says:
So this is the correct style:
The mutation is so untypical and notable action, that it should not be hidden, it should be always bring into attention of the person reading the code. But Fantomas dumps the <- arrow some times to same line as pre-conditions, e.g.:
The text was updated successfully, but these errors were encountered: