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

Relax indentation rules on Records #130

Closed
baronfel opened this issue Oct 20, 2016 · 2 comments
Closed

Relax indentation rules on Records #130

baronfel opened this issue Oct 20, 2016 · 2 comments
Labels

Comments

@baronfel
Copy link
Contributor

baronfel commented Oct 20, 2016

Submitted by Mathias Brandewinder on 8/17/2016 12:00:00 AM
9 votes on UserVoice prior to migration

The current indentation rules around records seem inconsistent, or at least counter-intuitive. Consider for instance:

type Foo = {
....Foo:int
....}
type Bar = {
....F:Foo
....}
let bar = {
....F = {
........Foo = 10
........}
....}

This is valid. But if you change F in Bar to VeryLongName:

type Baz = {
....VeryLongName:Foo
....}
let baz = {
....VeryLongName = {
........Foo = 10
........}
....}

We now get a warning:

warning FS0058: Possible incorrect indentation: this token is offside of context started at position (10:20). Try indenting this token further or using standard formatting conventions.

In a similar fashion, indentation rules around adding members to records seem inconsistent, or at least counter-intuitive.
The 2 examples below are valid:

type Foo1 =
....{
........data:int
....}
....member x.Data = x.data
type Foo2 = {
....data:int
....}
....with member x.Data = x.data
... but this one is not:
type Foo3 = {
....data:int
....}
....member x.Data = x.data

There is a workaround - systematically put the opening brace { on the second line - but the "shorter" syntax is quite nice, and allows to write compact and readable code. Given what is currently acceptable syntax, relaxing a bit the rules would be quite nice, and follow the principle of 'least surprise'.
Note: this is loosely related to /archive/suggestion-9156844-relax-some-of-the-indentation-rules ; that specific problem is brought up in the comments.
Note: sorry about the .... but this is the only way I could find to keep the code indentation preserved.

Original UserVoice Submission
Archived Uservoice Comments

@dsyme dsyme removed the open label Oct 29, 2016
@rmunn
Copy link

rmunn commented Nov 2, 2016

Related suggestion: #470 (which AFAICT is a superset of this suggestion).

@dsyme
Copy link
Collaborator

dsyme commented Nov 2, 2016

@rmunn You're right, I'll close this as a duplicate.

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

No branches or pull requests

3 participants