F# on Mac and Linux

is not, in 2012, in a great state. There are 2 not-great options and I add here a third, also not-great option. It has the advantage of working, and not requiring you to learn emacs. (Jump straight to F# with Sublime)

F# on MonoDevelop

The F# language bindings for MonoDevelop broke after version 2.4. You can get MonoDevelop version 2.4 by consulting the wayback machine for the MonoDevelop Download page at July 2011. You can then use the fsharpbindings and instructions from http://functional-variations.net/monodevelop/.
Personally I fould MonoDeveloper before 2.6 more prone to crashing, and I couldn't get 2.4 working with FSharp.

F# on Aquamacs

If you're an emacs fan, then you won't need my help to find and install the f# mode for it.
For emacs newbies on the Mac with a day to burn on the learning curve, a couple of the answers on stackover gives you some clue as to how to get fsharp working:
http://stackoverflow.com/questions/1210125/is-there-any-f-ide-that-works-over-mono
http://stackoverflow.com/questions/2120533/how-to-setup-aquamacs-for-clojure-development

F# with Sublime Text 2 (Quick and Dirty)


This was the best I could do in 2 hours:

  1. Get Sublime Text 2
  2. In the Sublime text menu : Tools - Build System - New Build System
    {
    	"cmd": ["/usr/bin/fsharpcandrun", "$file"]
    }

    and save as fsharp.sublime-build .

  3. At a terminal command line, use your favourite editor to save this file as /usr/bin/fsharpcandrun :
    #!/bin/bash
    fsharpc "$1" && nameafterquote=${1#\"} && exe=${nameafterquote%.*}.exe && mono "$exe" && echo done
  4. Make it executable, again from a terminal command line:
    sudo chmod a+x /usr/bin/fsharpcandrun

    The password that sudo asks your for is your login password.

  5. If your new favourite editor is in fact Sublime, you can save files in directories requiring sudo-ed permissions by putting a command line alias for sublime in your ~/.bash_profile script:
    alias edit='open -a /Applications/Sublime\ Text\ 2.app/Contents/MacOS/Sublime\ Text\ 2'

    and typing edit foo.txt to open Sublime

  6. Choose Tool -- build system -- fsharp in Sublime
  7. Now, <f7> your file. It should compile and run. At least, it did for me.
  8. Get some kind of syntax colouring by creating a .fs file, and then choosing View -- Syntax -- Open all with current extension as ... OCaml. This is because F# is near enough to OCaml for the colouring to be pretty good.

I wouldn't call this great, but it will do for the moment. It only "builds" a single file, which is hardly a build system. But it does give you syntax colouring and compile-and-run for learning F#.

The next step forwards might be to modify the bash script to fsharpc a list of files, or all files in the directory of the file to be run.

F# on Mac and Linux

by Chris F Carroll read it in 2 min
0