Microsoft maps out F# language upgrade

F# 4.1 will include struct tuples, improved error messages, and backing for .Net Core

Microsoft maps out F# language upgrade

Microsoft's plans for the F# "functional first" language include an upgrade later this year that adds capabilities ranging from struct tuples to improved error messages. Backing for .Net Core, a multiplatform, open source version of the .Net programming model, also is in the works.

F# 4.1 focuses on flexibility and incremental improvements, the Microsoft Visual FSharp team said. It features struct tuples and interoperability with Visual C# 7 and Visual Basic tuples.

Tuples are a data structure that can store a finite sequence of data of fixed sizes and can return multiple values from a method. Struct tuples improve performance when there are many tuples allocated in a short period of time.

"The tuple type in F# is a key way to bundle values together in a number of ways at the language level," the team said. "The benefits this brings, such as grouping values together as an ad-hoc convenience, or bundling information with the result of an operation, are also surfacing in the form of struct tuples in C# and Visual Basic."

Version 4.1 will also feature a struct records capability. "In F# 4.1, a record type can be represented as a struct with the [<Struct>] attribute. This allows records to now share the same performance characteristics as structs, without any other required changes to the type definition."

Single-case struct unions, meanwhile, also are enabled. "Single-case union types are often used to wrap a primitive type for domain modeling," the team said. "This allows you to continue to do so, but without the overhead of allocating a new type on the heap."

Error messages will be enhanced in F# 4.1, featuring improvements in suggested fixes with information already contained in the compiler, and a fixed keyword capability is planned as well. The .Net Intermediate Language enables a developer to pin a pointer-type local on the stack; C# supports this with the "fixed" statement preventing garbage collection within the scope of that statement. "This support is coming to F# 4.1 in the form of the 'fixed' keyword used in conjunction with a 'use' binding," said the team. Underscores in numeric literals version 4.1, meanwhile, will enable grouping of digits into logical units for easier reading.

F# 4.1 will enable a collection of types and modules within a single scope in a single file to be mutually referential, and it will include an implicit "module" suffix on modules sharing the same name as a type. "With this feature, if a module shares the same name as a type within the same declaration group -- that is, they are within the same namespace, or in the same group of declarations making up a module -- it will have the suffix 'Module' appended to it at compile-time."

Visual F# Tools for F# 4.1 will support editing and compiling .Net Core and .Net Framework projects. "Our compiler and scripting tools for F# 4.1 will be the first version to offer support for .Net Core," the team said. Planned tooling includes a cross-platform, open source compiler tool chain for .Net Framework and .Net Core for use with Linux, MacOS X, and Windows.

Visual F# IDE tools will be upgraded for use with the next version of Visual Studio, and F# 4.1 support will be included in Microsoft's Xamarin Studio and Visual Studio Code tools. The upgrade will be supported in the Fable F#-to-ECMAScript transpiler and in Roslyn Workspaces, for code analysis and refactoring in the Roslyn compiler platform.

To comment on this article and other InfoWorld content, visit InfoWorld's LinkedIn page, Facebook page and Twitter stream.
From CIO: 8 Free Online Courses to Grow Your Tech Skills
Notice to our Readers
We're now using social media to take your comments and feedback. Learn more about this here.