开发者

F# coding style and standard

While there is no One True Correct Style, some points of general agreement exist 开发者_JAVA百科in the C# community regarding coding standard / style; usually, they are variations of the .NET Framework Design Guidelines.

When you look into F#, though, the standard is visibly different from what is considered normal in C#. As an example, the functions accessible on List or Seq (almost) all start in lower case: List.fold, List.map (but List.Cons and List.Empty don't...), whereas it is usually accepted that a method or property in C# should be capitalized.

So my question is, are there widely accepted coding conventions for F#? Is there an equivalent to the Framework Design Guidelines, or a good coding standard out there? And, as a bonus, in the whitespace-based F# world, do people have topics to argue endlessly about, similar to the timeless C# curly-brace position?


The F# team has drafted a document that sounds like exactly what you're asking for. (We're currently in the process of incorporating feedback from community/insiders we've sent the draft to.) It is likely to be published in the near future. I'll be sure to link it here when it's published.

EDIT

The document is archived now and you should consult the updated version instead.

There's also a section of the MS docs that's derived from itL https://learn.microsoft.com/en-us/dotnet/fsharp/style-guide/component-design-guidelines


Update #2: There is now an F# Style Guide on Microsoft Docs. This contains new material and also incorporates the material I linked to in Update #1 below.

Update #1: Don's paper (linked below) has been removed from the Microsoft site. However, A comprehensive guide to F# Formatting Conventions appears to be based on the same paper.

Don Syme's F# Coding Guidelines paper deals with the "curly-brace" formatting style issues for F#.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜