F# Moves Forward in 3.1 Preview Release
Microsoft’s functional programming language, F#, has just released version 3.1 through the Visual Studio 2013 Preview. F# originated at Microsoft Research, Cambridge but despite these origins the language is fully support by Microsoft, and is licensed under the Apache 2.0 open source license.
In an announcement by the F# team, the authors describe that in contrast to the major feature implementations of past releases, this release focuses on refinements. Yet among these refinements F# developers will benefit from several new features including: improved F# type inference, printf performance, portable library support, and project round-tripping.
The major language additions in 3.1:
- Named union type fields – Now possible to name union fields within each case of a union type
- Extensions to array slicing – Previously array slicing was limited to arrays of equal dimensions, but this is no longer required
- Type Inference enhancements for LINQ-style methods - Improves F# type inference when using overloaded methods which take functions as arguments
- Support for C# extension members with first parameter a type parameter – 3.1 supports the use of extension members (“this”), as shown in this snippet: static member M<T>(this T input, T other)
- Alignment of supported declaration of constants in attributes and literal expressions – Examples include allowing the use of “+” to combine strings or bitwise OR (|||) on enum flags
Compiler Library / Additions
- Printf performance – No code changes required to take advantage of significant speed increases (reportedly 40x faster)
- Debug info in Quotations – Using the --quotations-debug flag with fsc.exe or fsi.exe
- Support for .NET 4.5 + Windows Store portable libraries – This means that F# can use C# portable assemblies for built for “.NET 4.5 + Windows Store” and that F# can in turn generate assemblies for that profile.
A big addition for F# developers using Visual Studio in a multi-generational team is the addition of support for project round-tripping. Any F# project targeting F# 3.0 can be edited in either VS2012 or VS2013. Coincident with this addition is the ability to specify in the F# project dialog or the Solution Explorer which version of F# to target for the application under development.
Users can access F# 3.1 through the VS2013 Preview today. Note that the 3.1 enhancements described above are not yet available in the open source edition which does support several non-Windows platforms (OS X, Linux, etc). The F# developers state that the 3.1 features will be released into the OSS project once complete.
Keith Adams Dec 06, 2013