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

Revise F# formatting guide #25972

Merged
merged 9 commits into from
Sep 14, 2021
Merged

Revise F# formatting guide #25972

merged 9 commits into from
Sep 14, 2021

Conversation

dsyme
Copy link
Contributor

@dsyme dsyme commented Sep 6, 2021

Summary

  • Rearrange sections of F# formatting guide to follow a logical order
  • Add some clarifications
  • Add a comment saying blank lines should come before /// documentation comments
  • Consistently use "multi-line" not "multiline"
  • Address https://github.com/dotnet/docs/issues/25917#issuecomment-913516706
  • Removed the naming conventions from this doc. F# naming conventions are in the F# component design guideline, they were inconsistent with the naming conventions here
  • There was a comment saying "put two blank lines between type definitions" - I've removed that and just said one - I don't think it really makes sense to differentiate that and in any case doesn't cover what to do between "let" and "type" definitions, nor "type" and "module" etc.
  • added some information about whether to put spaces after a function/method name in an application

Preview Link

@dsyme dsyme requested a review from a team as a code owner September 6, 2021 13:01
@dotnet-bot dotnet-bot added this to the September 2021 milestone Sep 6, 2021
@dsyme
Copy link
Contributor Author

dsyme commented Sep 6, 2021

@nojaf Could you review?

This addresses https://github.com/dotnet/docs/issues/25917#issuecomment-913516706 but also rearranges the sections in the guide to follow a logical order.

Please check these in particular

  • Recommend to always ensure a blank line before any /// doc comment. Always - including for members, union cases, record fields

  • I've left the record declaration formatting guidance in place but noted that if record fields have /// comments then the formatting used should expand to accomodate this, including blank lines and the initial { on a separate line. I think this seems right but we should discuss and ensure Fantomas aligns

  • I added an explicit link to Fantomas and recommendation that a code formatter should be used.

@nojaf
Copy link
Contributor

nojaf commented Sep 6, 2021

This was a bit hard to review, so I may have missed some things.
I think the reordering is fine.
The remark to recommend Fantomas is much appreciated 🎉!

As for the blank lines above comments, if the original code already had them Fantomas will do the right thing.
If they are not there, I'm not sure if it will be applied in all scenarios.

@dsyme
Copy link
Contributor Author

dsyme commented Sep 6, 2021

@nojaf I'm going through the entire revised doc using the Fantomas preview online tools to check the formatting.

Could you check this one? I was expecting

Target.create "Build" (fun ctx ->
    // code
    // here
    ())

https://fsprojects.github.io/fantomas-tools/#/fantomas/preview?data=N4KABGBEDGD2AmBTSAuKAVAhgJwOaIBcA6abRTAxMAHUgCEBXASwBt5awAKAMwYDsw0AgA8wAWgB81bNQEQwAegWCEiabPmLlAC0Rl1ciJwCUxyABpwUAM6ECTPrmuowAbSsRQmiJAAkBAE8AB2Q0SAcCCw95PwA3TBYGULdozQAGS28YgEk%2BJD4CAGUmAC9kTKywABZUsABdaIBfCs9av0CQl3CCqKy4hKSXd0qwAEYW70gAWUxhABkHRDnERwJtXsrRgCY02obNZuivSf9g5MgAI1hYFg3NfsTk4cqtifvCxABbJjgWWD4AIIEACieQA8twFnxyrUINwErY9k0Jsd7qdOmErjc7jFfPFHkNYWAAMxvGKFIKYaCIOiIbiwMgABRwmE%2BhD0OM0BGwSSRBxRbXR5yxtzJD0GaGeWSqZJ8FKpNLpDKWsAA7npoJhbLlYrBNfZ-pz5NzeVl9vJDppUbiOsLrqLBfiJSkRgBWWVQeXU2n0sgAVSCIWwmu1fF1%2BqYho98JYiLNyKOgttXRFRvFTyJADYPZAvYrfYgAMIsLXWQv-awmoQMo1whGIPkWgV9IUp%2B1pvEDDMjADsObzPuVUy%2BFw50frjYglvk1p8rcx7bFnYJkqJAA5%2B5TvUqyOW-nxa2AY3HvOap82TsmF9il07u5UAJybhUA7iUbDlz6fTCHk0N%2BP8omLZXlAqa3l2hIjKMGRErmW75sqHzfL8UZEse-6ngmVpJmcbY3o6EGrlB4ywXmr7vkhPw3KhIx-pOYDTq0wG4deDotnekGbK8sG5PkBBgnw6DYAEADqTBrIe6H0YxYCzlA86gYuBEri6mykqR8EAtgsD8PAAAiiAsEw3zvr%2BPIYZoZ4MReaIgd0kTgSpUreKMMqwTMwjZNw6C6HwwKxoghTaAyBBifAEkelUuwAU2QGXixUARB2HF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DGQcBQS5foT7-AMtAEs2MDRT3ASsnBfsXnrKfo3D5aSsjEmQcY%2Bp2AfgEGYUgcps8rB1AqOEaw11youCko0IAA

@dsyme
Copy link
Contributor Author

dsyme commented Sep 6, 2021

@nojaf Also this one, which formats the + at the beginning of line not end of line - I guess that's by design?

https://fsprojects.github.io/fantomas-tools/#/fantomas/preview?data=N4KABGBEDGD2AmBTSAuKAbRAXMAzArgHbRYCWshAjGAIYBOA5tfQwEy2MDMHDALGAF4e1ANQ92Ylt0mN%2BMtmHnSec8Yp7KWvADp1thSABpwUAM7YyhBqdRgA2iYigILqABIsATwAOyNJFJCLCNHF0g3ADcadHw-e1DXAAZjV1dIAElCJCCAZVIAL2QU1IheBLAAXVCAX2KncvCvX1sAoJCS8KiYuIcSiEo61MgAWRoADwAZQMQJxCssAAt2vspWRPKq11rQ5yGPHzjIACNYWHRltMjo2NtevtZBtJzEAFtSOHQKAEEsAFEsgDyuCmhCK5QguGi5g2NUGu0uTUOJzOFzCV26t3BYE4jzCOW8NGgiAAQohcLA6IgAAr0GgvbCIOio1xYOixGFbOENfbNfzI864zrXHpY3i4iCQfGEklkikzWAAd0Z0Bo5kyEVgKrIFGZLlZ7JKmxc21c8LRiJa-N1QoxaDuJQArOKoFKiaTyZSAKreXx0FVqwgarXkAzOyHoaGG2E7bkWvmnAXcro3O1YgBszslBLdsspAGF0KrTHmKKZ9SQKbqIVDEBzjVyOjykQnreiU-E%2BmAAOyZ10yj2IYavI6Mqt4Gt1iAmlxmiVNy0twVtkWdgAcvez-blJc%2Boax4cjqSNU4bezjUCtS%2BTK76AE4N9KvrgsIySy8XjQx-ra1HOTHG%2BexyLkmwqYp2lDJFiWbSu6crPG8Hw6mGE6-vW-5ngcC4oleoGpuBAxQX2T4vnQ8HvGcSFYt%2Bk5gNO9QAZh8bYSBtodisDxQZk2RYAChAACp0J4ADqpCLGOB4-ke0amrGjEXsBjbXmBKw4oRm5fHQsBEPAAAiiDoKQbwkV%2BbKSa4x60aeCJya0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gDxoMQUm%2B57EU1GsnKpnD5Yfx0evfR3cFm93AaYDSWksibzLIgX6HcJalzKhVWxzpqKqLwadDRCk34ZyxJwL%2Bez6CwUpJk0w0A6CGUCAVS5npT4UD0tAQsuMxGlLMqsxx6zEkjK2R47EyD9ENJBSQRhSBEWHRMBUYoARTA3QqrYWe1QgA

@dsyme
Copy link
Contributor Author

dsyme commented Sep 6, 2021

Maybe check this one too

https://fsprojects.github.io/fantomas-tools/#/fantomas/preview?data=N4KABGBEDGD2AmBTSAuKAbRAXMAnAhgJYB2ARrAO4BMYAvADq73EQTB5FmVgWFYAWjZqxFgAQrADOkumHqQAUogBmy3IgCe8oS1EQAMvmgBrTTNpgA2nMgAtQgAcHWyAG4bAcUSxcAc0Ty7vJiAK7EvpjyYAC6YAC%2BOpAANOBQkthYJL6SqFapbPmskAAkWBoOyGiQJFjJhRAlAG746CGVeXoQAAwpnVAAksRIxFgAyoQAXsi9nQAs9TGFcTMFeiVlFbnVI3Vrxc2t7ZYLEACMK6KQALL4AB76JIj6iOECu52nVF0L0UsXoHsNu1IORYOh3iImi02rljn0qBdIaNEABbQhwdCwYgAQSwAFEhgB5ZQPYjTE5gZQtdI-P6FAGXUrlYGg8GIqD7aFHCkAZnZDVGDiMiDEKh8iAACvgCCjsIhcBDRFhcG1aSJlvSFutmVtWYqGpzDrCKbN%2BVBBcLRcpxfpKPLoPh0oNGrAHZksfrWMrVXpfur-lqmZsqnr2VCjWg4Z0AKxmyAW6AisXqACqTntjsQztd%2BHdxE9ECp6BpvrpIgZkKDLNgYM94ZhkYpADY4wmk9b1ABhdCOySdrGSb3QLA%2BAuU6mINWsDXlwNA3U1tmBg4NjqdADsraFiat4quqNI8rHRZLoj904DgJ1IcXdcNq6jegAHFvLcnEP3MfmzSfJ6X-ZqV7BlAobLlyxp9AAnK%2BibYsoWDyv2KIovgY7en%2BZ5lqwFZFFWC61mG97cn0pw9BS8bbu24rImiGIej%2BE5ThAM7YXO14gbehErsRHznORbZwQhuA0ei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oXLfgowNAjDuIU%2BxZSoAvHgMSPBowyiYHIaovQPJW7uIJP0kkBSca4HQMoP2ECKaKMcRUjhLi%2Bg8jnu41BiB0FDFEYMNe%2BB9FcyPoQyJxDon11iaMhJrAeR33ccvM5xg8GSBcm5IYD9ByIGRgvPW3VeqIH6mEs0kkVka1YRfWBlSxmiB5Eg150pdzqDqZIaAuBfIkFzAClMv8sReWgD2DqNiGJ2OhQo2FSiNm4U4byKh7ihk4uHJIpAXSIGpGiDMaokhgb91yMfOIQA

@dsyme
Copy link
Contributor Author

dsyme commented Sep 6, 2021

@nojaf There's also a discrepency with respect to named arguments - the style guide says "no space"

https://fsprojects.github.io/fantomas-tools/#/fantomas/preview?data=N4KABGBEDGD2AmBTSAuKAbRAXMBbAhgNaIDKWATovrgEpVLlgAeYAvGAHaIDuYJAngGcsiXADoAkgHkxZStTr4GACgAO%2BLAAtWTAJQAdcvo6QANOCiDsWAJYcA5oNRgA2hYigIXqABIs-VWQ0SDssM3cvSB8AN3x0AFcg1wjvAAZzb29ICQ4kDiwSGwAvZAzMiAAWFLAAXQiAXzKPaqj-QOcQ-PDyqNiEpLdyiABGJszIAFl8JgAZO0QZxActbqHhgCZU6rrvRojPcb8ApMgAI1hYdFWsmLjE50Gh9bGsklEbOHRYDgBBLABRXJSABmcy410ywLiVm2DTGBxubRO50uEIgvTuA2qEAAzC9IiR1NBEAAhRDA2CUAAK%2BHI1GwiHIaK8FESsN28JaR3awRRV3xGP6D2xYAq%2BPRhPwxLJFMoM1g3EZ0HwVhy0Vgyts32ZEFZiHZXj23gRkW5yIu-K5fXuaEe5QArOKoJLpeTKYgAKqqQLkZWqjjqzU2bVOqHoGHlHaGzk9M0dPnMwU25JDMAANidkBdpLdlAAwugVYI899hOR4tAsJSdWAwxHMlGIEavCb0XHeRbE7chbaRQB2TPZmXuiaiU6Mmt1-WRuH7LlI%2BOdgXd5N2zIADkHRJzssQJa%2BJlD0OnDdnxvnx0XqOX1qxqYAnFupYgfsCROQS7gCD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Uk511UZLZ%2B3gcRW20SrWwYIFjUFOPAfABZYBlQcGvbgQtrHSXQTXZRydHHQOcV4HEwdtEGSZvgU4mAEFM00AIfI0xwlKJGu2KASx4Agi8WQfgmA1FN3KDiLO2jASlNBMA-65B0DAmhmAzBilsEqVwYvFxLdtEfy-jI-IORe74CEfjehiiukzx6awvp7D1FDBxCvbRncpmEC8YIHSelchr2EIgeAHj25cGLiVMqVinS-nmcwrBSyG4rJqZkHEr9Nm0jgnvJm0ByCmTsBoE5HpD7fCMtAQsdItTjyGJPRh08HmLPrg-G4T8A64jgdouQHxla0PyWAiwNQyghEEGdMqzg0L1CAA

@dsyme
Copy link
Contributor Author

dsyme commented Sep 6, 2021

@nojaf Here's another case of interest - records with XML doc comments on the fields. Looks a bit odd to place that brace on the last line

https://fsprojects.github.io/fantomas-tools/#/fantomas/preview?data=N4KABGBEDGD2AmBTSAuKB6dYAijoBsBDAJwEsA7AczEPnlIBdTZzD8wBbRDgI0WIDOYFmAAKsAQzYBBOsUQCBAHWJLyDAJ4AHRGIlT8s%2BPMVgAvCrUQIwS%2BWsOwmLABUAFrtrGFy1fccQRiYCaJJkVHZ2ARDOYO660IwaUdEAwkmhDOGUkX7RTphxHmAAXqRaYHBIKQEAWuWZ2TVgAL6QADTgUAKIDExUAqhgANpdNmPWkAAkmjpDkBQMHRMQ0wBubACuyGij%2BQAMnfmQAJLkSOoAyqQlyEfRACwrYAC6Ey334wHTsztQi8tvlMNvhtkM9tEAIyfRyQACyhAAHgAZCiIZGIKgMNyA6IADn2zzeDg%2BE1AQN%2B8x4sFg%2BFxDnWWz%2BEICACYYQzLtxSHB8CxpAwAKLnADyADNUeQ7s8IGK2D0ie8YeTYTNtH9INTafTJsCmeCZWAAMwcyaXLSEaCIABCiDFsHkohIhC4DH4OocWW2ipJyueP3VVJpdNNjNBzMND1Nq3Nlptdod6NgAHd%2BNBCD0zmtYOmmCwPdYvYgfdZSQ4VQy1XM0JrgwWw2DdoaAKzRqCxq22%2B3yACqW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UiQ6KzsQFZz1lQgODhWSUy7m1RSAg3B73yO9Ph9dG5QGbkGZyIiL5iOlsca4VB8CIAypQKGmJuqIB4HCBA3DojEIOqQgR5CTqUJzuLQ0RpjbREgNIPKlByA93IH3Fg1wfGrU2PIFwsAvImNWjtMKUFNalQzt9NRCVnEQNccHDxXj2KsCYGsJMVB8FgQwRQbB54IK8NsfwxJJ9knnRcfkI0BcPFRyYFw5ELoeDwEIMeCQQ84EILROU8KQCG461Aeo1J1CAhGk7h47AEdCA8H0VIiObhLgaHUEiIZcTa5H1GZnGsmJ4Dii4ZcTQ%2Bi6lpIaUvDxwpjkSkGazYg%2BAxSQBGcogMjiwGTNEdYI0V8PGMOYZE9QZwX6EH8WrHhwzFGTxUdpb5s96nRCNDAjx98IWPy4QIDKWVzhwMkIgeALTb5Si3ttMpbY%2BKwrIfCihiLdRz1cXQ9FJAgLyHmQIaAZBFI5KJT2LBLBcAEGdHmf%2B0Kdnjz2R81R74JlIquSiiRHizlkCvBYpA2yIq7JJF0F49wFgCFxgIUgQxAEtCAA

@dsyme
Copy link
Contributor Author

dsyme commented Sep 6, 2021

@nojaf OK I put the whole doc through the "preview" tools and apart from the cases above I think it's all looking good!

Please check over this commit: 6415eee

@dsyme
Copy link
Contributor Author

dsyme commented Sep 6, 2021

@nojaf If you could check the above cases quickly that would be cool - if any of them are Fantomas bugs I can open issues. I think maybe some are the changes we've discussed either not yet implemented or not in preview tools

@nojaf
Copy link
Contributor

nojaf commented Sep 6, 2021

Hey @dsyme, you are correct some stuff is not in the online tool yet (nor in a stable version).
Like

Target.create "Build" (fun ctx ->
    // code
    // here
    ())

is still open in fsprojects/fantomas#1858.
I'll get to that when time permits it.

let function1 arg1 arg2 arg3 arg4 = arg1 + arg2 + arg3 + arg4 + arg2 + arg3 + arg4 + arg2 + arg3 + arg4

Fantomas currently treats almost all infix operators the same. There is nothing in place for arithmetic operators and in general infix operators are quite challenging to get right. It is a bit on an ongoing dragon in the codebase. I'm open to some good heuristics there.

let rainbow2 =
    { rainbow with
        Boss = "Jeffrey"
        Lackeys = [ "Zippy"; "George"; "Bungle" ] }

Created fsprojects/fantomas#1876

let makeStreamReader x = new System.IO.StreamReader(path=x)

we just format the shape of the argument AST here as is.

Paren
                       (App
                          (NonAtomic, false,
                           App
                             (NonAtomic, true, Ident op_Equality, Ident path,
                              tmp.fsx (1,52--1,57) IsSynthetic=false), Ident x,
                           tmp.fsx (1,52--1,58) IsSynthetic=false),
                        tmp.fsx (1,51--1,52) IsSynthetic=false,
                        Some tmp.fsx (1,58--1,59) IsSynthetic=false,
                        tmp.fsx (1,51--1,59) IsSynthetic=false),
                     tmp.fsx (1,25--1,59) IsSynthetic=false),

we should do something different when it is in the context of SynExpr.New.
Created fsprojects/fantomas#1877

// Declaring additional members on PostalAddress
type PostalAddress =
    {
        /// The address
        Address: string

        /// The city
        City: string

        /// The zip code
        Zip: string
    }

to preserve the original style here, you are looking for the fsharp_multiline_block_brackets_on_same_column setting perhaps?

Example.

@dsyme
Copy link
Contributor Author

dsyme commented Sep 7, 2021

@nojaf Regarding records declarations (with/without XML doc comments):

to preserve the original style here, you are looking for the fsharp_multiline_block_brackets_on_same_column setting perhaps?

This is tricky. Here's my thinking

  1. My natural instinct (not necessarily good) is to have records without XML doc be formatted compactly (record definition braces on same column = false) while those with XML doc be formatted widely (record definition braces on same column = true). This is roughly what I implemented for signature file generation in Printing updates fsharp#12072

  2. However, this means a discontinuous approach that people may find confusing. And also it only applies to record definitions, and not "multiline_block_brackets" more generally, because that's the only place in the syntax where XML doc comments interact with block brackets.

  3. Now there's a strong argument that the "destination" of code should be XML-doc commented. So if I really have to choose one or the other for default formatting then I should be choosing wide formatting (record definition braces on same column = true)

Anyway, on summary on revising the guide I kind of feel that record definitions should get special treatment to support a nice look when XML doc commented. But I'm aware that this is a special case. Would be interested in your thoughts.

@nojaf
Copy link
Contributor

nojaf commented Sep 7, 2021

Hmm, a bit tricky indeed. Although as I understand it there is a clear rule when to always use the wide record formatting:

    1. record type (in implementation or signature file)
    1. all fields have XML comments

This is a relatively easy thing to check in the syntax tree.
From a technical point of view, I think we can have this.
Although it will be raised multiple times on Fantomas side as inconsistent no doubt 🙈.
I would be ok with having this as there is clear reasoning behind it and it is scoped to a limited number of cases.

Slightly related I've raised fsprojects/fantomas#1878.

@dsyme
Copy link
Contributor Author

dsyme commented Sep 7, 2021

@nojaf Added fsprojects/fantomas#1879 where we can discuss

@nojaf
Copy link
Contributor

nojaf commented Sep 7, 2021

I've updated the tool to use our 4.6 branch which has the new lambda style.

@dsyme
Copy link
Contributor Author

dsyme commented Sep 7, 2021

Fantastic!

@luisquintanilla @KathleenDollard could I have a review/approve when your ready? Thanks.

Copy link
Contributor

@luisquintanilla luisquintanilla left a comment

Choose a reason for hiding this comment

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

Thanks all for making these updates. Looks great. Just a few minor formatting issues 😉.

Can you also update the ms.date value in the metadata to reflect this document has been recently updated.

@dsyme
Copy link
Contributor Author

dsyme commented Sep 14, 2021

@luisquintanilla This is ready, thank you!!

Thanks all for making these updates. Looks great. Just a few minor formatting issues 😉.

Thanks, all done

Can you also update the ms.date value in the metadata to reflect this document has been recently updated.

Updated

Copy link
Contributor

@luisquintanilla luisquintanilla left a comment

Choose a reason for hiding this comment

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

Looks good to me. Ready for merge.

@dsyme dsyme merged commit 037ae56 into main Sep 14, 2021
@dsyme dsyme deleted the dsyme-patch-1 branch September 14, 2021 14:46
@dsyme
Copy link
Contributor Author

dsyme commented Sep 14, 2021

@luisquintanilla Thanks!

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

Successfully merging this pull request may close these issues.

4 participants