Blog

Using F# in Sublime Text on Linux Mint

June 5, 2015

I’ve been learning about functional programming for quite some time now, trying to wrap my head around the various concepts that this paradigm has to offer. One of the languages that spiked my interest besides Clojure is F#.

The reason for this is quite obvious. As a software developer who uses the .NET framework on a daily basis, I regularly run into the limitations of C#. Embracing a powerful functional language that targets the CLR and mitigates most of these limitations definitely looks quite appealing.

My goal has been to limit my use of Visual Studio to the absolute bare minimum. Especially during my spare time where I develop all my hobby projects on Linux Mint. I’m currently dabbling with F# using my preferred editor, Sublime Text.

Setting up F# on Linux Mint is quite easy. You just have to run the following commands:

$ sudo apt-get update
$ sudo apt-get install mono-complete
$ sudo apt-get install fsharp

This couldn’t be more easy. However, using F# in Sublime Text takes a bit more configuration.

First of all, you have to install the F# package which provides F# syntax highlighting for Sublime Text.

Secondly, in order to run F# code from Sublime Text it is recommended that you install the SublimeREPL package. Unfortunately, there is a minor issue with SublimeREPL what makes that the F# REPL doesn’t work in Sublime Text on Linux. In order to fix this issue you can just install SublimeREPL using Package Control and manually apply the changes from this pull request.

After installing these packages, you can add the following custom key bindings to the Key Bindings - User file in Sublime Text.

{
	"keys": ["ctrl+alt+f"], 
	"command": "run_existing_window_command",
	"args": {
	    "id": "repl_f#", 
	    "file": "config/F/Main.sublime-menu"
	}
},
{
    "keys": ["ctrl+alt+r"], 
    "command": "repl_transfer_current",
    "args": {
        "scope": "selection"
    }
}

Now when you open a new group in Sublime Text and press the CTRL-ALT-F key combination, you get the following layout:

Split view in Sublime Text, code on the left, REPL on the right

Selecting the block of F# code in the left pane and pressing the CTRL-ALT-R key combination executes the code in the REPL in the right pane. I personally find this very useful during my explorations of the F# language.

Until next time.

Update 01:

In response to this blog post, Guillermo López mentioned that he has been working on the FSharp package for SublimeText.

This package brings autocompletion, live error checking and several other cool things to the table and can easily be installed using package control. Simply a must have when using F# in SublimeText. ​

If you and your team want to learn more about how to write maintainable unit tests and get the most out of TDD practices, make sure to have look at our trainings and workshops or check out the books section. Feel free to reach out at infonull@nullprincipal-itnull.be.

Profile picture of Jan Van Ryswyck

Jan Van Ryswyck

Thank you for visiting my blog. I’m a professional software developer since Y2K. A blogger since Y2K+5. Provider of training and coaching in XP practices. Curator of the Awesome Talks list. Past organizer of the European Virtual ALT.NET meetings. Thinking and learning about all kinds of technologies since forever.

Comments

About

Thank you for visiting my website. I’m a professional software developer since Y2K. A blogger since Y2K+5. Author of Writing Maintainable Unit Tests. Provider of training and coaching in XP practices. Curator of the Awesome Talks list. Thinking and learning about all kinds of technologies since forever.

Contact information

(+32) 496 38 00 82

infonull@nullprincipal-itnull.be