-
Notifications
You must be signed in to change notification settings - Fork 21
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
Comments
I would like to see this done if possible. |
Marked as approved. I'll try to look at this today |
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 :/ |
Travelling at the moment but I will give it a go in a few days. |
Thanks @charlesroddie |
@cartermp You're not meant to be typing! |
@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,
...) = |
@FunctionalFirst Yes and that will be a very common way to format. That's how it works with function inputs at the moment. |
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 |
@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. // 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) |
Completed |
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:
Undentation is not allowed:
Function inputs allow undentation (and it's explicitly in the F# spec):
The text was updated successfully, but these errors were encountered: