-
-
Notifications
You must be signed in to change notification settings - Fork 194
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
Consider documenting why certain config options exist #2979
Comments
Hey @brianrourkeboll , |
Sure, no problem. I am on the F# Discord. I'm also open to the possibility that the Fantomas docs aren't the best place for something like this, although it does seem like something that would be useful to have in some discoverable, well-known place. |
Great, we'll get in touch with you. |
I think this would be super useful as a blog post at the very least. I actually especially like the examples with "recipes" of common styles in that context. I also do think it's worth mentioning that having "recipes" like this technically contradicts the official recommendation in the docs to just stick with the defaults, although I personally think we may want to update at least part of that section:
For example, there are now 3 officially recommended ways to format record types, so I don't know if it's accurate to say that the default settings are always the "best". Regardless, ihmo having some minimal explanation as to why a given setting exists can certainly be useful even without being phrased as a recommendation. |
I think it might be worth augmenting the existing documentation (e.g., here) with some of the following information, where appropriate:
fsharp_multiline_bracket_style = stroustrup
).I could see it argued that someone could just document such information in their own style guide instead, but there are some settings that are currently supported for which the existing style guides offer rules but not explanations, and there are some widespread styles for which there is no official, published guide.
I think adding this explanatory information to the Fantomas docs would be especially useful for people coming to F# from C-family languages. In my own experience, I have seen many newcomers perplexed as to why one might use or omit a space in various contexts, for example. Discrepancies between the tooling in Ionide, Rider, and Visual Studio, and the changes to the default formatting used by the compiler (and in documentation) have also contributed to the confusion, especially when newcomers start working in big, long-lived codebases, where significant amounts of old code were written before some of the more recent formatting styles became popular in F#.
Examples
These are some (surely incomplete) examples of the kinds of implicit motivation/historical background for some settings and grouping of settings that it might be worth documenting. They mostly represent my own poorly-phrased understanding or reasoning, so I may be wrong about some things. And there are of course surely other rationales and histories out there for many of the settings, some of which may or may not be worth mentioning. Either way, there is probably someone out there better versed in the lore here than I am—maybe there are blog posts or other writing or documentation that we could consult.
ML style
This seemed like one of the most common styles when I started learning F# a number of years ago, including in the compiler and in the VS tooling.
I think it was mostly inherited from OCaml:
f (x : int)
andf (x : int) (y : int)
.f (x, y)
ando.M (x, y)
as functions taking a single tupled argument.let f (x : int) : int = x
, etc. Perhaps owes its origin to OCaml's French heritage, since the convention when writing French is to use a space before colons (and a variety of other punctuation).Interop/".NET"/C#/TypeScript style
Haskell style
This is probably common in OCaml and many other languages, too.
Diff minimization
I'd be willing to open a PR for this.
The text was updated successfully, but these errors were encountered: