Introduction To F# Interactive in Visual Studio 2013 RC

Introduction

As I introduced you in my earlier article, Microsoft has released the latest version of Visual Studio, in other words Visual Studio 2013 Release Candidate. So, here in this article I am introducing the various new features announced with the Preview release and one of them is for F# developers.

There is one spanking new feature include in the Visual Studio 2013 Release Candidate. Like the preview version it has the new update of F#, in other words F# 3.1 and the enhanced Visual F# Tools. The latest feature in RC for F# is "Send to F# Interactive". F# interactive is also known as a REPL that stands for Read Evaluate Print Loop. This is used to accept the code and after compiling and executing, it displays the result.  It allows you to very easily and quickly experiment with the code instead of creating new projects or build an application for display the results.

In your Solution Explorer, the assembly references have the new option. This option is used to send those references to a F# Interactive (FSI) session. It is generally much faster and easier than typing a full command.

Let's start to create a F# application to use the FSI with the following procedure.

Step 1: Open the Visual Studio 2013 Release Candidate

StartPage-in-RC2013.jpg

Step 2: Click on "New Project" to create a console application.

NewProject.jpg

Step 3: Creating a simple program. Replace the code of the "Program.fs" file with the following code:

open System

Console.WriteLine("Hello World")

Console.ReadKey(true)

Step 4: Execute your application.

Output.jpg

Now, there are three ways to use this feature:

  • Adding Individual Reference
  • Adding Project Reference
  • Adding Output Assembly

Adding Individual Reference

If the individual reference is to send, then right-click on the reference:

Individual Reference.jpg

Adding Project Reference

The project reference is to be sent by a right-click as shown below:

Project Reference.jpg

Adding Output Assembly

If you want to add the output assembly then right-click the project and select "FSI" as shown below.

Output Assembly.jpg

You can show your F# Interactive for further process.

Note: You need to notice that once your assembly is loaded in FSI then it will be locked on that disk. You cannot load the new version of the same assembly on the FSI Session. You need to reset your FSI (F# Interactive) to update the assembly.

Summary

So far in this article I introduced you to the latest feature in F#, Send to FSI in the Visual Studio 2013 Release Candidate. So enjoy this feature and thanks for reading.