Introducing the New Features of F# 3.0

by Anand Narayanaswamy on Jul 31, 2012 |

The upcoming release of .NET Framework 4.5 brings in several new features for F# 3.0 (F Sharp) language such as a new type attribute, triple-quoted string literals, auto-properties, and unused variable warnings in addition to the core features such as type providers and LINQ queries.

If you attach [<CLIMutable>] attribute, which is newly introduced in F# 3.0, to an F# record type, the compiler emits a default constructor and property setters into the generated Intermediate Language code for this type.

"[<CLIMutable>] attribute may help you with WPF data binding or Entity Framework scenarios", says Brian McNamara, Visual Studio F# Developer at Microsoft.

F# 3.0 introduces triple-quoted string literals, which means that every code between triple quotes is kept verbatim and hence there is no possibility for escaping. With the help of this feature, developers will be able to add XAML as a string literal and will be useful for embedding XML code as data in a program or for passing large strings as arguments to type providers.

"I've been coding in F# for 4 years now and I'm really glad to see F# as a fully supported language in Visual Studio and finally it is time for F# to become mainstream", says Nick, the lead engineer-architect of M-Brace

F# 3.0 consists of an improved usage of auto-property when compared to its previous version, with which developers will be able to make use of this feature in a single line of code as shown below

type MyClass() = member val Y = 0 with get, set,

In the above code, member val denotes auto-property and the value of Y is declared after =.

I have been using F# for 2+ years now, and absolutely love it. Having previously developed in C#, the initial switch was mind bending but well worth it, said Huw Simpson, Software Developer.

F# 3.0 introduces a new feature with which you can activate warning number 1182 using the command line option and the F# compiler warns you if there are any unused variables in your code. In Visual Studio 2012, you can activate this feature from the Build tab of the project properties dialog and adding --warnon:1182 to the Other flags field.

In a large project with 100K lines of code, unused variable warnings may help you find bugs, said McNamara, Visual Studio F# Developer at Microsoft.

Rate this Article


Hello stranger!

You need to Register an InfoQ account or or login to post comments. But there's so much more behind being registered.

Get the most out of the InfoQ experience.

Tell us what you think

Allowed html: a,b,br,blockquote,i,li,pre,u,ul,p

Email me replies to any of my messages in this thread

Interesting F# talk at CUFP - Commercial Users of Functional Programming by Faisal Waris

Adam Granicz will present at CUFP on bioinformatics visualization with F# and WebSharper.

CUFP ( Sept 13-15, Copenhagen

Better Visual Studio support required by Paulo Pinto

I still miss official Microsoft's tooling support for doing .NET Desktop and Web UIs in F#.

Re: Better Visual Studio support required by Faisal Waris

For desktop UI's, you can easily build MVVM XAML apps in F#. The templates are available online for VS2012. FSharpX (an open source F# library) allows XAML files to be 'typed' via F# TypeProviders.

I recently finished a medium sized analytics application (approx. 2000 LOC) with 2D and 3D WPF views, using this approach (i.e. F# + XAML only, no C#).

Note that with MVVM (something like MVC, for those not familiar) you don't need 'code behind'. Most everything can be 'data bound' - including events via Expression Blend events-to-commands approach.

Re: Better Visual Studio support required by Roopesh Shenoy

Wow, that's interesting - how was the experience vs. say doing it in C#?

Allowed html: a,b,br,blockquote,i,li,pre,u,ul,p

Email me replies to any of my messages in this thread

Allowed html: a,b,br,blockquote,i,li,pre,u,ul,p

Email me replies to any of my messages in this thread

4 Discuss
General Feedback
Marketing and all content copyright © 2006-2016 C4Media Inc. hosted at Contegix, the best ISP we've ever worked with.
Privacy policy

We notice you're using an ad blocker

We understand why you use ad blockers. However to keep InfoQ free we need your support. InfoQ will not provide your data to third parties without individual opt-in consent. We only work with advertisers relevant to our readers. Please consider whitelisting us.