-
Notifications
You must be signed in to change notification settings - Fork 143
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
[style-guide] Format mutation expressions on their own line #663
Comments
@nojaf @charlesroddie thoughts? |
Likewise someThing <- fun a -> expr :) Which should at least be parenthesized: someThing <- (fun a -> expr) |
This is detectable from an AST point of view, so I don't see any technical limitations here. |
These seem ad-hoc and I don't see any general principles that would justify them.
Perhaps this tries to attain a good visual appearance by avoiding spurious symmetries. I don't think there is any lack of clarity and I don't see any structural reason for preferring either form. To make a slippery slope argument, if we go down this route we will end up flagging
Well this is not "likewise" as parenthesizing this would still break the first rule which is to avoid Adding brackets for clarity sometimes does help, especially in cases where precedence is more confusing than this. But I don't see how this idea could be formalized. |
@charlesroddie If you assume the beginner doesn't know the precedence of By putting these on separate lines, we clarify this automatically. It's also how we clarify nested |
I will update the style guide to indicate this specific case, and also to make a general recommendation that assignment expressions let f() =
if condition then a <- b which would always be formatted let f() =
if condition then
a <- b The reasoning is that |
@nojaf I'm labelling decided style guide issues using "style-gudie-decided" When style guide decisions are made like this in this repo, you can assume that this is decided and we can adjust fantomas even before the actual style guide is updated 👍 |
Example catalog (we can add to this): let f() =
a <- b
let f() =
if condition then
a <- b
let f() =
let x = 1
a <- b |
@dsyme are there any other constructs that fit this bill? |
I think it's just about this, in the sense that adding anything else would be very heuristic. Ideally perhaps any unit-typed expression or void-returning interop call, but we don't have types available to fantomas.... |
The change from "a -> b <- c" to "Format mutation expressions on their own line" seems good to me. The only exception to the rule I can think of is to allow |
I have a strong dislike of code where
->
and<-
appear on the same line:Because this code is relatively rare I think we should consider a style guide entry to explicitly say "put this on two lines"
The text was updated successfully, but these errors were encountered: