Skip to content
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] do! indents #793

Open
palsskv opened this issue Jan 23, 2025 · 2 comments
Open

[style-guide] do! indents #793

palsskv opened this issue Jan 23, 2025 · 2 comments

Comments

@palsskv
Copy link

palsskv commented Jan 23, 2025

I suggest to remove the line-break after do! for multi-line expressions when using 4-space indents.
do! is 4 characters long and fits into the current alignment scheme.

Some sample code using the current style guide:

do!
    writeRelated<TType1, TType3>
        httpClient
        host

do!
    writeRelated<TType1, TType2>
        httpClient
        host

if someRelatedDataVals.Length > 0 then
    do!
        writeRelated<TType1, TType2>
            httpClient
            host
            someRelatedDataVals

Suggested fix:

do! writeRelated<TType1, TType3>
        httpClient
        host

do! writeRelated<TType1, TType2>
        httpClient
        host

if someRelatedDataVals.Length > 0 then
    do! writeRelated<TType1, TType2>
            httpClient
            host
            someRelatedDataVals

Single-line expressions should not be affected, as there is no forced line break. I.e. do! writeRelated<TType1, TType3> httpClient host is already fine.

I originally filed this under .NET docs: dotnet/docs#39302

@nojaf
Copy link
Contributor

nojaf commented Jan 27, 2025

One problem I can already see is that this doesn't work when the indentation would be 2 spaces.

do! writeRelated<TType1, TType3>
    httpClient
    host

This is no longer an application but a sequence of expressions.

I also question how well this would behave with different types of expressions.
(again with indent_size = 2)

// This is already invalid code
do! try
  foo()
  with ex ->
    bar()

@JustinWick
Copy link

@nojaf The original suggestion was for the case of 4-spaces only. Obviously this is not a good idea for two-space code.

For your try block, in 4-space code it looks reasonable to me:

do! try
        foo()
    with ex ->
        bar()

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants