-
Notifications
You must be signed in to change notification settings - Fork 7
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
Computation expresions formatting #19
Comments
This one's a bit of a poser. I think I exclusively use: let items =
seq {
yield "item1"
yield "item2"
} However, in the case of an async function only, I use the following, with let foo () : Async<int> = async {
let! blah = Async.Sleep 100.
return 3
} If it's a variable, I'd often do the following: let somethingElse () : int =
let bar =
async {
let! blah = Async.Sleep 100.
return 3
}
bar |> Async.RunSynchronously I'll write up a PR to this effect, and run it past the GR team. |
Having that exception only for |
I checked with the rest of the team and we're happier staying consistent, everything on a newline. I'll update my PR. |
(The reason for the exception is that this is the only computation expression in common use where the intent is to be "just like a normal function".) |
It can be applied the same to any computation expression. |
The only case when the next line must be forced regardless of the setting is when computation expression passed to the left pipe let somethingElse () : int =
async {
let! blah = Async.Sleep 100.
return 3
}
|> Async.RunSynchronously By the way this constructs (with a single pipe) I always write as let somethingElse () : int = Async.RunSynchronously <| async {
let! blah = Async.Sleep 100.
return 3
} |
To be clear, the G-Research/fsharp-formatting-conventions repo is primarily here to record G-Research's style guidelines; Fantomas uses it as a reference, because Fantomas supports G-Research's style guidelines as well as Microsoft's. I am only an imperfect vessel for GR's style, and it turns out I was wrong about what the team wanted, so I amended my original PR to completely remove the |
My team and I would really appreciate this code style to be included as an option. We have 1000+ usages of async on the same line (and some of the other CEs) and we really can't bear with the amount of indentation that default code style generates. |
Hello, there might be room for this in fsprojects/fantomas#1408. |
Original issue fsprojects/fantomas#1526
This repository does not provide any sample of computation expressions formatting.
I propose to define
as a standard formatting option.
Currently Fantomas changes the code above to
The text was updated successfully, but these errors were encountered: