BT

InfoQ Homepage News Getting Started with F# on Linux and Mac OS X

Getting Started with F# on Linux and Mac OS X

Lire ce contenu en français

Bookmarks

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
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.

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

Community comments

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

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

BT

Is your profile up-to-date? Please take a moment to review and update.

Note: If updating/changing your email, a validation request will be sent

Company name:
Company role:
Company size:
Country/Zone:
State/Province/Region:
You will be sent an email to validate the new email address. This pop-up will close itself in a few moments.