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

Long function signature broken into two lines #492

Closed
ivan-brko opened this issue Oct 1, 2019 · 6 comments · Fixed by #769
Closed

Long function signature broken into two lines #492

ivan-brko opened this issue Oct 1, 2019 · 6 comments · Fixed by #769

Comments

@ivan-brko
Copy link

Description

Function with a lot of arguments gets broken into two lines, which is ok. However, second line then blends in with the body of the function, as it is indented at the same level and there is no line break between the arguments and the body

Repro code

This
image

turns into

image

Link to online example in fantomas tool.

@ivan-brko
Copy link
Author

This doesn't seem nice to me, but if it is supposed to look like this please close the issue.

@nojaf
Copy link
Contributor

nojaf commented Oct 1, 2019

Hmm I count 112 characters for let private addTaskToScheduler (scheduler : IScheduler) taskName taskCron prio (task : unit -> unit) groupName = so I would expect it is on the same line.
Seems to be working for 2.x.

@ivan-brko
Copy link
Author

That depends on what the PageWidth is set to?
If I am not mistaken, it's 80 by default? I can see that even on the online fantomas tool (v2.9.2) it is set to 80 by default.
Still, I don't think splitting the arguments in two line is problematic (that will happen with a longer function signature even if I increase PageWidth) but the way it splits the arguments which makes it look like the second line of the arguments is part of the function body.

However, I didn't spend much time with formatting F# code before, I usually just write all of this on the same line, so I don't know if the language itself allows any prettier formatting in this situation.

@nojaf
Copy link
Contributor

nojaf commented Oct 1, 2019

PageWidth on 3.x will be 120 so something doesn't add up.

@ivan-brko
Copy link
Author

That will solve this example.
However, when signature of the function is > 120, it will break the it into two lines. Will the formatting of the second line work the same on 3.x like it is in the initial example I gave?

For example, if I add another parameter to this function and make it longer (as in this link) I would still have the same situation, even with PageWidth set to 120.

My question is not about to what value should PageWidth be set, but how should the last line containing function parameters be formatted to differentiate it easily from function body.

@nojaf
Copy link
Contributor

nojaf commented Oct 2, 2019

A very good question. Personally I would say that the function definition should be on one line for readability but that is only my opinion. I can't find anything immediately in the F# style guide that supports this.

So we could modify this behaviour if we want. Any thoughts @jindraivanek?

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 a pull request may close this issue.

2 participants