神刀安全网

Getting Started with F# on Linux and Mac OS X

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:

  • F# Interactive (REPL) panel
  • Package management throughPaket
  • Target building with FAKE
  • Project scaffolding using F# Yeoman Generator

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.

转载本站任何文章请注明:转载至神刀安全网,谢谢神刀安全网 » Getting Started with F# on Linux and Mac OS X

分享到:更多 ()

评论 抢沙发

  • 昵称 (必填)
  • 邮箱 (必填)
  • 网址