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

proposing additions for type annotation #12076

Merged
merged 8 commits into from
May 2, 2019
Merged

proposing additions for type annotation #12076

merged 8 commits into from
May 2, 2019

Conversation

smoothdeveloper
Copy link
Contributor

Proposing few examples on how to use whitespace for type annotations.

Proposing few examples on how to use whitespace for type annotations.
@dnfclas
Copy link

dnfclas commented Apr 28, 2019

CLA assistant check
All CLA requirements met.

Copy link
Contributor

@cartermp cartermp left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Some minor changes, but otherwise this is great. Thanks @smoothdeveloper

docs/fsharp/style-guide/formatting.md Outdated Show resolved Hide resolved
docs/fsharp/style-guide/formatting.md Outdated Show resolved Hide resolved
docs/fsharp/style-guide/formatting.md Outdated Show resolved Hide resolved
docs/fsharp/style-guide/formatting.md Outdated Show resolved Hide resolved
docs/fsharp/style-guide/formatting.md Outdated Show resolved Hide resolved
docs/fsharp/style-guide/formatting.md Outdated Show resolved Hide resolved
docs/fsharp/style-guide/formatting.md Outdated Show resolved Hide resolved
cartermp and others added 7 commits May 1, 2019 20:31
thanks

Co-Authored-By: smoothdeveloper <smoothdeveloper@users.noreply.github.com>
Co-Authored-By: smoothdeveloper <smoothdeveloper@users.noreply.github.com>
Co-Authored-By: smoothdeveloper <smoothdeveloper@users.noreply.github.com>
Co-Authored-By: smoothdeveloper <smoothdeveloper@users.noreply.github.com>
Co-Authored-By: smoothdeveloper <smoothdeveloper@users.noreply.github.com>
Co-Authored-By: smoothdeveloper <smoothdeveloper@users.noreply.github.com>
Co-Authored-By: smoothdeveloper <smoothdeveloper@users.noreply.github.com>
@cartermp cartermp merged commit 8d424d3 into dotnet:master May 2, 2019
@auduchinok
Copy link
Member

auduchinok commented Jun 10, 2021

I've seen a lot of code with no space before colon in both values and function definitions, like this:

// values:

let x: SomeType = y

let f () =
    let y: AnotherType = g x
    ()


// functions:

let f (arg: _): unit =
    ()

let f x: unit =
    ()

Perhaps, I've seen even more code formatted like this than with the space like in let a : int = 1.

Also, having different styles for patterns that are parameters and head patterns in bindings adds a lot of confusion on how these should be formatted, since seemingly same things get formatted differently.

@cartermp @dsyme I think we should explicitly allow this style, since Fantomas uses rules defined in this guide to enforce arguably less popular code style without any option to keep the no-space style. What do you think?

@dsyme
Copy link
Contributor

dsyme commented Jun 11, 2021

Hmmm for me only the return type of functions should add whitespace before the :

let f (arg: _) : unit =
    ()

This is partly so ): doesn't look like a weird sad backward smilely.

For values there should be no whitespace:

let x: SomeType = y

@dsyme
Copy link
Contributor

dsyme commented Jun 11, 2021

@auduchinok I made a proposed adjustment here: #24643

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

Successfully merging this pull request may close these issues.

5 participants