F# syntax highlighting dark-theme coloring scheme for VS-2015 with Visual F# Power Tools

Here I share my customized Visual-Studio 2015 (VS-2015) dark-theme coloring scheme that works with Visual F# Power Tools (VFPT).

The selection of colors for syntax highlighting is nearly as tricky as finding good names for functions and values. And it depends on personal taste.

For this dark color scheme the brighter/colorful colors are chosen to highlight the domain relevant things like the names for
  • modules,
  • types (Discriminated Unions (DU), records, classes),
  • Unit of Measures (UoM),
  • values and
  • parameters
The F# language specific syntax elements are defined in darker color. That allows to better focus on the domain during code reading and writing.

This is an example of F# code highlighted with this coloring scheme.
The settings can be found under VS > Tools > Options > Environment > Fonts and Colors > F# … Font-and-Colors-for-F#
The screenshot shows the VS-2015 Options dialog where F# Mutable Variables and Reference Cells are defined in red as a warning (which is good default).

Note that by default not all F# Display items are defined in a stand out color.
Note that the  Visual F# Power Tools (VFPT) must be installed first.
Note that in VS > Tools > Options > F# Power Tools the Syntax coloring is activated.
Visual F# Power Tools Settings

Note: don’t forget to make a backup of your Visual Studio settings before importing and changing settings.
Here is an zipped export (*.vssettings) of the VS-2015-FSharp-Font-and-Colors-Exported-and-pretty-printed-XML containing only font and colors.

And the big thank you goes to the F# community for this excellent tool which is open source.

An F# rewrite of a fully refactored C# Clean Code example

Today I stumbled over a C# clean code refactoring example, where I could not resist to do a full rewrite in F# during my break.

The reason for doing this was mainly to present a comparison how does a piece of deeply refactored C# code can look in F#, to motivate others to learn F#, because it makes things (software: thinking, design, coding, review and tests) much simpler and leads to robust solutions.

And the other reason was to show the nice F# syntax coloring that is possible with the Visual F# Power Tools (VFPT) that is an excellent and must have add-on in VS-2015. This screenshot is taken with my customized coloring scheme.

The F# code

The C# code

“C# BAD PRACTICES: Learn how to make a good code by bad example” http://www.codeproject.com/Articles/1083348/Csharp-BAD-PRACTICES-Learn-how-to-make-a-good-code

If you like to have deep detailed F# training please see our F# 2-day course information (German language).

Ok that’s it, I hope you got some new ideas by comparing the F# and C# code.

??.03.2016 : Some more C# refactoring of this example by Ralf Westphahl here http://ralfw.de/2016/03/dont-let-cleaning-up-go-overboard/

Update 26.01.2017 : More C# refactoring by Pete Smith here https://gist.github.com/beyond-code-github/8711794c4d516cb6941d47274884b248

Update 26.01.2017 : Even more C# refactoring of this example by David Arno with C# 7 and Succinc<T> here http://www.davidarno.org/2017/01/26/using-c-7-and-succinct-to-give-f-a-run-for-its-money/

Update 27.01.2017 : An explanation of the F# code by Richard Dalton  http://www.devjoy.com/2017/01/reading-f/

Update 27.01.2017 : Much more C# refactoring by Kenneth Truyers https://www.kenneth-truyers.net/2017/01/27/refactoring-taken-too-far/

Update 28.01.2017 : An similar F# refactoring , with a merged discout logic (do the domain owner like that?) by Jon Harrop https://gist.github.com/jdh30/b01279a6be91467c5887b72a7c2f303e

Update ??.??.2018 : await C# 8 refactoring // ToDo: check if this F# code was also possible with F# 1.9 (2007)