F# style guide concerning do! indents + docs issue
Nobody has claimed this yet.
Assessment
- Difficulty
- 2/5
- Estimated time
- 1-3 hours
- Newbie friendliness
- 68/100
- Issue type
- Documentation
- Clarity
- Clearly specified
- Activity status
- Stale
- Tech stack
- fsharp
- Domain
- documentation
Research direction
Start with docs/fsharp/style-guide/formatting.md, linked in the issue as the content source, and review the do! indentation guidance and its examples. Compare the article with the proposed four-space formatting and update the wording and examples so the documented style is consistent; confirm the rendered formatting page reflects the correction.
Written by the indexing model from the issue text.
Description
Type of issue
Other (describe below)
Description
This ticket pertains to the F# code style guide and the linked documentation article.
The article says:
Here's an example with do! using two spaces of indentation (because with do! there is coincidentally no difference between the approaches when using four spaces of indentation):
// ✔️ OK
async {
let! foo =
fooBarBaz
|> loremIpsumDolorSitAmet
|> theQuickBrownFoxJumpedOverTheLazyDog
do!
fooBarBaz
|> loremIpsumDolorSitAmet
|> theQuickBrownFoxJumpedOverTheLazyDog
}
// ❌ Not OK - notice the "do!" expression is indented two spaces more than the `let!` expression
async {
let! foo =
fooBarBaz
|> loremIpsumDolorSitAmet
|> theQuickBrownFoxJumpedOverTheLazyDog
do! fooBarBaz
|> loremIpsumDolorSitAmet
|> theQuickBrownFoxJumpedOverTheLazyDog
}
My comments:
There is a difference when using 4 spaces, because do! works out to be exactly 4 characters.
The "bad example" becomes aligned and takes up less space:
async {
let! foo =
fooBarBaz
|> loremIpsumDolorSitAmet
|> theQuickBrownFoxJumpedOverTheLazyDog
do! fooBarBaz
|> loremIpsumDolorSitAmet
|> theQuickBrownFoxJumpedOverTheLazyDog
} |> ignore
I have encountered this issue when working with async and other CTES. The new lines inserted after do! don't affect alignment and reduce information density.
Here's an abbreviated version of some of my code. It's formatted by Fantomas with default settings.
// [...]
match relatedParent with
| Some parent ->
do!
writeRelated<TType1, TParent>
httpClient
host
ctx
siteId
targetId
(cast ctx)
[| parent.Id |]
| _ -> ()
do!
writeRelated<TType1, TType3>
httpClient
host
"en"
do!
writeRelated<TType1, TType2>
httpClient
host
"en"
if someRelatedDataVals.Length > 0 then
do!
writeRelated<TType1, TType2>
httpClient
host
"en"
dataCxt
siteId
do!
publish<TargetType> httpClient host "en" scope siteId targetId
|> AsyncResult.ignore
Here's how the same code would look like with the change.
// [...]
match relatedParent with
| Some parent ->
do! writeRelated<TType1, TParent>
httpClient
host
ctx
siteId
targetId
(cast ctx)
[| parent.Id |]
| _ -> ()
do! writeRelated<TType1, TType3>
httpClient
host
"en"
do! writeRelated<TType1, TType2>
httpClient
host
"en"
if someRelatedDataVals.Length > 0 then
do! writeRelated<TType1, TType2>
httpClient
host
"en"
dataCxt
siteId
do! publish<TargetType> httpClient host "en" scope siteId targetId
|> AsyncResult.ignore
Page URL
https://learn.microsoft.com/en-us/dotnet/fsharp/style-guide/formatting
Content source URL
https://github.com/dotnet/docs/blob/main/docs/fsharp/style-guide/formatting.md
Document Version Independent Id
1efdd523-8552-6421-e149-74f76826ef8f
Article author
@KathleenDollard
Metadata
- ID: 8c09996f-24ac-cf39-ef43-d7909cbc2b89
- Service: dotnet-fsharp
- Dominant language
- No language data
- Stars
- 4.8k
- Forks
- 6.1k
- Avg merge
- 15h 30m
- Merged PRs (30d)
- 374
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
More from dotnet/docs
-
:watch: Not Triaged dotnet-framework/svc install-deployment/subsvc
Difficulty 2/5 1-3 hours Newbie friendliness 72/100
-
:watch: Not Triaged
Difficulty 1/5 1-3 hours Newbie friendliness 84/100
-
:watch: Not Triaged dotnet-fundamentals/svc
Difficulty 1/5 Under an hour Newbie friendliness 82/100
-
dotnet-fundamentals/svc waiting-on-feedback
Difficulty 2/5 1-3 hours Newbie friendliness 68/100
-
dotnet-csharp/svc lang-reference/subsvc
Difficulty 1/5 1-3 hours Newbie friendliness 70/100
Similar issues
-
user-reported
Difficulty 2/5 1-3 hours Newbie friendliness 85/100
Kong/developer.konghq.com#7316 ·
-
Difficulty 2/5 1-3 hours Newbie friendliness 88/100
HarperFast/skills#96 ·
-
Difficulty 2/5 1-3 hours Newbie friendliness 82/100
infinispan/infinispan#18150 ·
-
bug triage:deciding
Difficulty 1/5 Under an hour Newbie friendliness 88/100
open-telemetry/otel-arrow#4132 ·
-
Ecosystem: ClawMetry — the Qwen Code reader is now free and open source (follow-up to #9294 / #9338) Opencategory/integration priority/P3 scope/documentation status/ready-for-human type/feature-request
Difficulty 1/5 Under an hour Newbie friendliness 84/100