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

[Feature request] #1309

Closed
3 of 6 tasks
halcwb opened this issue Dec 19, 2020 · 5 comments
Closed
3 of 6 tasks

[Feature request] #1309

halcwb opened this issue Dec 19, 2020 · 5 comments

Comments

@halcwb
Copy link

halcwb commented Dec 19, 2020

I propose we ...
Start a list argument like this:

someFunc [
    someOther func [
        "some item"
        "another item"
    ]
]

The existing way of Fantomas deals with this problem is ...

someFunc [ someOther func [ "some item"; "another item" ] ]

The same applies to indentation of records.

Pros and Cons

The advantages of making this adjustment to Fantomas are ...

  1. Easier to read
  2. Easier to refactor and indent
  3. Easier to collapse

I have experienced lot's of mind bending refactorings with Fantomas formatting code, especially in code using Fable or Feliz.

The disadvantages of making this adjustment to Fantomas are ...

?

Examples

See my blog: https://informedica.nl/?p=203
See my issue: #999

Extra information

Estimated cost S?

Affidavit (please submit!)

Please tick this by placing a cross in the box:

Please tick all that apply:

  • This is not a breaking change to Fantomas
  • I or my company would be willing to help implement and/or test this
  • This suggestion is part of the Microsoft style guide (please add a link to section if so)
  • This suggestion is part of the G-Research style guide (please add a link to section if so)
@nojaf
Copy link
Contributor

nojaf commented Dec 19, 2020

Hello @halcwb, thank you for writing this suggestion.

I'm afraid this falls under the section what are we not looking for.
This is yet another exception of writing function applications and it is unclear who (besides yourself) this benefits.

You are deviating from the Feliz syntax and to me, this seems inconsistent on your end.
As a workaround, you could try to partially apply until the AST shape matches again.

let appliedOther = someOther func

someFunc [
    appliedOther [
        "some item"
        "another item"
    ]
]

To have your proposed style, yet another check needs to be done if the AST matches the func param [] shape.
Even though behind a setting, everybody else will pay for the cost of checking this.

For the time being, I'm not allowing any more stylistic changes that are not based on the F# style guides.
The goal of Fantomas is to format all F# code according to a curated style guide, with the biggest challenge being the F# compiler. All the rest is a distraction I'm afraid.

I hope you understand and thank you again for showing an interest in the project.

@nojaf nojaf closed this as completed Dec 19, 2020
@halcwb
Copy link
Author

halcwb commented Dec 19, 2020

@nojaf. Ok, that's crystal clear. Where would you think this could be discussed best? The G-research of Microsoft guidelines?

Thanks.

@nojaf
Copy link
Contributor

nojaf commented Dec 19, 2020

G-Research is a closed system and is not using Fable, so your best bet would be the Microsoft style guide.

@halcwb
Copy link
Author

halcwb commented Dec 19, 2020

@nojaf Just a quick sanity check for me, is at least my issue clear to you? If not, just say no, then I have to rewrite things.

@nojaf
Copy link
Contributor

nojaf commented Dec 19, 2020

This single case here is clear for me.
However, the reasoning and scope of the style are not really captured.

Imagine the following code:

List.map fst [
   ("a", 1); ("b", 2);  ("c", 3)
]

This also matches the shape you originally wrote down

 someOther func [
        "some item"
        "another item"
    ]

I assume you would not write the List.map like that but for Fantomas those are identical.
Fantomas only knows the AST behind the code and has no idea what your code is doing.

Does it only occur with a single non-list parameter and a list or are you suggesting it as well for other constructs?
What about someOther func [] someOtherArg?

Is there a need for a nested list scenario?

someFunc [
    someOther func [
        "some item"
        "another item"
    ]
]

And also, does this the style make sense outside the currently targeted framework.
Meaning, would you apply these rules also to non-Feliz code?

I don't need any answers right here, but I'm trying to illustrate that there should be clear reasoning behind all of it.
I hope this again makes some sense.

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

2 participants