BT

Facilitating the Spread of Knowledge and Innovation in Professional Software Development

Write for InfoQ

Topics

Choose your language

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

Getting Started with F# on Linux and Mac OS X

This item in japanese

Lire ce contenu en français

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

BT