Microsoft has nearly completed feature work for F# 5, a planned upgrade to the open source functional language for .NET. The latest preview adds string interpolation.
A highly requested feature, interpolated strings in F# are fairly similar to those in C# or JavaScript, letting developers write “holes” inside of string literals. F# interpolated strings also allow for typed interpolation, similar to the sprint
function, to enforce that an expression inside of an interpolated context conforms to a particular type.
Microsoft revealed it had reached feature completion on August 27, with the exception of what the company described as one minor enhancement planned for the .NET 5 release candidate. F# 5 is slated to reach general availability alongside the .NET 5 software development platform in November. At this point, Microsoft will focus mostly on bug fixes and addressing feedback.
F# 5 can be accessed by installing the NET 5 preview SDK or through NET and Jupyter Notebooks. In other recent developments in F# 5:
- Support is now complete for
nameof
, which resolves the symbol it is being used for and produces a name that represents what it is called in F# source. This can be useful in scenarios such as logging, with logging protected against changes in source code. - Open type declarations are featured in the preview, similar to open static classes in C# except with differences in syntax and slightly different behavior to conform to F# semantics. With open type declarations, developers can
open
any type to expose its static contents. They also canopen
F#-defined unions and records to expose contents. This can be useful if a union is defined in a module and developers want to access its cases but not open the entire module. - Computation expressions, allowing developers to improve the expressiveness of components, have been enhanced to allow for application forms.
- With this preview, interfaces can be implemented at generic instantiations.