Friday, 4 November 2016

F Sharp for Pleasure and well just pleasure really

The language F# has its origins at Microsoft and is now available in the latest versions of Visual Studio - but looking at I see there is an option to use F# on Linux.

But first you need Mono for it to run on... which I did basically by following the instructions on the Mono site.  The instructions are nice and clear so I resist the inclination to copy them here.

Then to test.  Create a file called hello.cs containing this code:

using System;

public class HelloWorld
    static public void Main ()
        Console.WriteLine ("Hello Mono World");

Then on the command line (you can come out of super user mode now) compile with this command:

mcs hello.cs

This creates a file called hello.exe that you can execute:

$ mcs hello.cs
$ ls h*
hello.cs  hello.exe
$ ./hello.exe
Hello Mono World
$ mono hello.exe
Hello Mono World

You can execute with the command mono but I didn't spot this and I find you can invoke the hello.exe directly. What have I just done? Blimey I've typed in and compiled a C# program almost without realising it.

So anyway that does demonstrate that Mono is installed... jolly good.

So I next need

apt-get install fsharp

Looks ok.  This installs fsharpc (the compiler) and fsharpi (the interactive REPL)

Possibly at this point... install Visual Studio Code...?

OK go on then.

Had to log off and log on as administrator to get this to work. It's a download from the Visual Studio Code web site.

However this seems to be in place.  Then you add the F-Sharp mode to the editor by going

ext install Ionide-fsharp

Then you select the right one, opt to install and then activate.

So that was very successful - the F Sharp site and the Mono site have excellent instructions for getting set up.

Now also there is an F-Sharp mode for Emacs.  I'll look into that another day.

No comments:

Post a Comment