Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

F# coding style and standard

While there is no One True Correct Style, some points of general agreement exist 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?

like image 636
Mathias Avatar asked Jun 25 '10 19:06

Mathias


2 Answers

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://docs.microsoft.com/en-us/dotnet/fsharp/style-guide/component-design-guidelines

like image 180
Brian Avatar answered Oct 12 '22 13:10

Brian


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#.

like image 37
bentayloruk Avatar answered Oct 12 '22 13:10

bentayloruk