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

Allow undentation for constructors #724

Closed
charlesroddie opened this issue Mar 2, 2019 · 11 comments
Closed

Allow undentation for constructors #724

charlesroddie opened this issue Mar 2, 2019 · 11 comments

Comments

@charlesroddie
Copy link

charlesroddie commented Mar 2, 2019

It's good to be able to move 4 characters to the right to get to the next level and leads to smart code where lines generally start at a indentation which is a multiple of 4. This works well with tooling (Tab/shift-tab).

However in constructors, full indentation is required. So when defining types, the length of the type name determines how far to the right inputs must be positioned:

open System
type SixAccessViolations(a:AccessViolationException,
                         b:AccessViolationException,
                         c:AccessViolationException,
                         d:AccessViolationException,
                         e:AccessViolationException,
                         f:AccessViolationException) =
    class end

Undentation is not allowed:

type SixAccessViolations(a:AccessViolationException,
        b:AccessViolationException, c:AccessViolationException,
        d:AccessViolationException, e:AccessViolationException,
        f:AccessViolationException) =
    class end

Function inputs allow undentation (and it's explicitly in the F# spec):

let sixAccessViolations =
    SixAccessViolations(accessViolation,
        accessViolation, accessViolation,
        accessViolation, accessViolation,
        accessViolation)
@cartermp
Copy link
Member

cartermp commented Mar 4, 2019

I would like to see this done if possible.

@dsyme
Copy link
Collaborator

dsyme commented Mar 9, 2019

Marked as approved. I'll try to look at this today

@dsyme
Copy link
Collaborator

dsyme commented Mar 9, 2019

This suggestion is implemented in dotnet/fsharp#6314

@charlesroddie Any chance you could write up a brief RFC? @cartermp has broken his arm so can't type fast :/

@dsyme dsyme added the started label Mar 9, 2019
@charlesroddie
Copy link
Author

Travelling at the moment but I will give it a go in a few days.

@cartermp
Copy link
Member

cartermp commented Mar 9, 2019

Thanks @charlesroddie

@dsyme
Copy link
Collaborator

dsyme commented Mar 9, 2019

@cartermp You're not meant to be typing!

@FunctionalFirst
Copy link

@dsyme Only asking because I haven't seen an example of this. Will undentation of the first input be allowed? E.g.,

type SixAccessViolations(
    a:AccessViolationException,
    ...) =

@charlesroddie
Copy link
Author

charlesroddie commented Mar 11, 2019

@FunctionalFirst Yes and that will be a very common way to format. That's how it works with function inputs at the moment.

@dsyme
Copy link
Collaborator

dsyme commented Mar 12, 2019

@dsyme Only asking because I haven't seen an example of this. Will undentation of the first input be allowed?

We should double check - the test cases in the PR doesn't cover this yet https://github.com/Microsoft/visualfsharp/pull/6314/files#diff-d652333102a65f9f23289cb1d40938bbR249

@charlesroddie
Copy link
Author

charlesroddie commented Apr 6, 2019

@dsyme Sorry: I didn't have enough time/internet/power to look at the RFC while I was away.

This proposal was for constructors, which tend to have a lot of inputs and long names.
You added static members.
What do you think about extending it to all functions?

// The proposal currently is to allow undentation in constructors and static members.
// Currently: warning FS0058: Possible incorrect indentation
// Proposed: OK
type EightCalculator(
        irrelevantNumber1:int,
        irrelevantNumber2:int) =
    member t.Eight = 8

// Should undentation in other functions be allowed too?
// Currently: warning FS0058: Possible incorrect indentation
// Proposed: OK?
let nineCalculator(
        irrelevantNumber1:int,
        irrelevantNumber2:int) =
    9

let irrelevantNumber1 = 1
let irrelevantNumber2 = 2

// OK: undentation allowed when calling constructors
let eight =
    let ec =
        EightCalculator(
            irrelevantNumber1,
            irrelevantNumber2)
    ec.Eight

// OK: ... and other functions
let nine =
    nineCalculator(
        irrelevantNumber1,
        irrelevantNumber2)

@dsyme
Copy link
Collaborator

dsyme commented Aug 24, 2021

Completed

@dsyme dsyme added completed and removed started labels Aug 24, 2021
@dsyme dsyme closed this as completed Mar 19, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

4 participants