A Quick Look at F# In Visual Studio Code

It’s F# Advent time again! This is a yearly event the F# community comes together for the month of December and each person releases an F# related post on a day of their choosing. Today is that day for me this year.

With the recent announcement at Microsoft’s Connect() conference, Visual Studio Code now has an awesome update that can install extensions. With me being an F# fanatic I got excited to see that actually using F# is one of the first extensions available via Ionide which is originally made for developing in F# in GitHub’s Atom client.

While you could technically already “use” F# in Visual Studio Code, it was only for syntax highlighting. You couldn’t run any of the code. This quick post will help show you the steps to started developing F# within Visual Studio code.

The original creator of Ionide, Krzysztof Cieślak, did a great guest post for the .NET Blog to help announce F# support for VS Code. I figured I’d do my best to extend on it with this post.

Installing the F# Extensions

If you’re used to Atom or Sublime you’re already familiar with the command palette in Visual Studio Code (scroll down to the Command Pallete section). If not, just hit Cmd+P for the Mac version..

In here, just type in ext install f# and you’ll get a list of available F# extensions. The first one is for FAKE (which we have a few posts detailing some uses) and the second one is the main F# extension we’ll use.

Install Extension

The next one that you’d want to install is Paket. Think of this as NuGet on steroids. Once these are all installed go ahead and restart VS Code to use them.

Using the F# Interactive (FSI)

Now that the extension is installed, you can now create .fs or .fsx files in Visual Studio Code and execute the code in there in the F# interactive.

First, to launch the FSI, go back to the command palette and enter >fsi start. This will launch another split window with the FSI.

FSI

And, of course, we now have intellisense for F#.

F# Intellisense

In all of your F# code, you can send directly to the interactive window. I’m using >fsi send selection in the command palette here to send the highlighted selection to the FSI.

Send to Interactive

Although, at the time of this writing, you can’t type directly into the interactive window.


Of course, this is just the very beginning of what can be done with VS Code with F# as more and more features will be supported in Ionide. Look for more posts on all of those here. This is a great beginning for F# cross-platform development and I can’t wait to see where all of this goes.

We deliver solutions that accelerate the value of Azure.

Ready to experience the full power of Microsoft Azure?

Start Today

Blog Home

Stay Connected

Upcoming Events

All Events