BT

Getting Started with F# on Linux and Mac OS X

| by Pierre-Luc Maheu Follow 3 Followers on Apr 20, 2016. Estimated reading time: 1 minute |

The advent of .NET Core brings the ability to build and run F# programs on Linux and Mac OS X with the same level of support as Windows. David Stephens, program manager for F# at Microsoft, presented how to get started with F# on .Net Core at Build 2016.

The first step is to install the .NET Core tools. This step is the same for both C# and F#, as the tools are for .NET and not a specific language.

A basic F# project is created using the following CLI command:

dotnet new –lang f#

The resulting project file is a Json file, following the new project file format introduced in NuGet 3. The project.json file for a newly created F# project contains the basic dependencies to compile and run a program:

{
  "version": "1.0.0-*",
  "compilationOptions": {
    "emitEntryPoint": true
  },

  "compilerName": "fsc",
  "compileFiles": [
    "Program.fs"
  ],

  "dependencies": {
    "Microsoft.FSharp.Core.netcore": "1.0.0-alpha-151221",
    "NETStandard.Library": "1.0.0-rc2-23811"
  },

  "frameworks": {
    "dnxcore50": { }
  }
}

The dependencies assemblies are not included at project creation. The only step remaining remaining before executing the program is to restore them:

dotnet restore
dotnet run

These steps are the minimum required to compile and run an F# program on .NET Core. Cross-platform IDEs Visual Studio Code and Atom both support F# through the open-souce extension Ionide. Alongside the more common IDE features such as autocompletion, Ionide includes:

It is important to note that .Net CLI and .Net Core are still work in progress at the time of this writing. The porting of libraries to .Net Core is also a work in progress.

Rate this Article

Adoption Stage
Style

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
Community comments

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

Discuss

Login to InfoQ to interact with what matters most to you.


Recover your password...

Follow

Follow your favorite topics and editors

Quick overview of most important highlights in the industry and on the site.

Like

More signal, less noise

Build your own feed by choosing topics you want to read about and editors you want to hear from.

Notifications

Stay up-to-date

Set up your notifications and don't miss out on content that matters to you

BT