Wednesday, February 4, 2009

F# – Visual Studio Integration

The newer versions of F# support Visual Studio better and better, but don’t wait such feature rich designer support as C# and other mainstream languages have. In fact F# doesn’t have any designer support (yet?).

F# integrates with Visual Studio, so first of all you can create an F# project from File/New/Project… Select Visual F# node. There are three project types:

Project Description
F# Application It creates a project that compiles to .NET .exe. It can be run from command prompt.
F# Library It creates a project that compiles to .NET .dll. It can be referenced from other .NET applications.
F# Tutorial It creates a project containing examples of F# language constructs.

So application template compiles to a standalone application, library templates compiles to a .NET DLL, and tutorial template contains several examples. Library template contains a Script.sfx file. This file can be directly accessed from F# Interactive and loads the DLL so it can be tested in an interactive manner.

F# Interactive is the interactive environment of F#. It’s reminds me to qBasic: expressions are evaluated as you type and close them. It’s basically an interpreter. F# Interactive can be accessed either from command prompt (called fsi.exe) or from Visual Studio. You can display it clicking on View/Other Windows/F# Interactive (CTRL+ALT+F). I prefer it full (editor) screen, so I usually drag it up to the editor area (e.g. over the editor window).
Expressions must be closed with ;; operator in F# Interactive.

No comments:

Post a Comment