|
FSharp Installation GuideAs you probably already know, Fsharp is a dialect of the ML Programming Language. ML is well-suited for working with programming languages. The F# dialect is designed to run on the .Net virtual machine which is a Windows-based VM. This document details some steps that can be carried out to get F# running on a Mac running OS X.F# on WindowsIf you're using a Windows system you can take advantage of Microsoft's Dreamspark program which gives Visual Studio away for free to students. Visual Studio comes with F# and tools built-in.If you have questions about how to install Visual Studio on your Windows machine, it might be worthwhile posting them on the course Piazza website. If you have experience with installing Visual Studio, please share your knowledge with your classmates either directly or via Piazza. F# on Mac OS XIf you're using a Mac, you'll have to install a system that implements Microsoft's .NET architecture. The only system that I know of that does that is Mono. Mono is supported by Xamarin.XamarinXamarin gives away a free Eclipse-style cross-platform IDE called Xamarin Studio. Xamarin Studio includes support for F#. (And we will soon be receiving some documentation support for some of the F# tools that we'll be using.)Roll Your OwnIf rigid IDEs aren't your cup of tea, you can do what I've done: download Mono for free and cobble together the set of F# tools that we'll use in CS3366 piece by piece. What follows is a summary of how I configured my Mac OS X 10.10 (Yosemite) system. In summary, you,ll need:
PreliminariesFair Waring: Setting up an F# environment on OS X is a bit involved. To be clear, I set my environment up on OS X 10.10 Yosemite. I have no reason to believe that these instructions won't work on older versions of OS X. But I haven't tried all of them.There are some preliminary steps that more-or-less restore OS X as a full Unix environment (rather than the clipped one that Apple ships as OS X).
Installing Mono, F# and Tools
Configuring your EditorYou can use your favorite text editor to edit your F# code. Both Emacs and Sublime Text (ST) are good options that come with special F# modes and which allow you to run an F# interpreter as a subprocess of the editor. I will flesh out the instructions for installing and configuring Sublime later. For now, we'll cover Emacs.Installing and Setting up Emacs for Editting F# CodeIn order to use Emacs to edit F# code, you'll need to be running Emacs version > 24. In the command shell, type:
Now you can download the F# plug-in (aka a "binding") that makes Emacs understand F# syntax. There is a standard setup available on Github. But ZC has extended it to include handy key-bindings so we recommend that you use this one rather than the standard issue version. Download this archive and expand it in your home directory. The expanded form of the archive should be named dotemacsdotd/. Emacs uses a special home-directory folder: .emacs.d/ for customization. If you're new to Emacs, you can simple rename your folder as follows:
and you should see at the bottom that the ".fs" extension has caused Emacs to enter FSharp Mode. Type an F# definition or two. In Emacs, one is either typing text or control sequences, which seem quite strange to beginners. Control sequences usually involve the Control and/or the Escape keys. The former is usually denoted C or Ctrl, the latter is labeled esc and is usually denoted M or sometimes as Esc or as Meta. The notation C-c means "hold down the control key, then, while still holding it, type the 'c' key". And likewise for the meta key. For example, typing
will fire up the Emacs tutorial. It's worth taking a look. ZC has extended the keyboard short-cuts of F#'s emacs bindings to include:
If you're running emacs in F# mode, C-c C-b should fire up an F# REPL (i.e., fsharpi) and send the contents of your editting buffer to the REPL for evaluation. Emacs is a very powerful text editor and is well-worth mastering. Many of Emacs' commands have made their way into wider usage. For example, the emacs commands C-a, C-e, C-k and C-y will (resp) move the cursor to the front (i.e., left), to the end (i.e., right), "kill" (or delete) what's to the right or "yank" (or restore) what was most recently killed. These emacs commands (and many more) also work in other applications. For example, try positioning your cursor in the URL field of your browser and then see what happens when you type the various emacs commands. The following Cheat Sheet should help. Installing and Setting up Sublime Text for Editting F# CodeIn abstract:
|