Painless installation of SML on OS X
Studying Computer Science of any kind, you will be asked to install a wide range of software you will use for one semester and are unlikely to ever need again afterwards.
SML/NJ is a popular choice in functional programming lectures, but since it is not incredibly widespread, installing it can be a hassle. You could follow their official installation instructions, but you will end up with bits and pieces of it scattered throughout your entire system with little hope of ever getting rid of the entire thing.
Installing SML/NJ through Homebrew
The Homebrew package manager makes installing SML/NJ on OS X not only much easier, but it will also uninstall all of SML when you are done with it, leaving no dead files on your system.
To install SML/NJ through Homebrew, just follow these steps.
Installing Homebrew is a one-liner, which you can find in their GitHub wiki. The command you need to run is:
(Check their wiki if this command fails for you in case they changed it since.)
If you already have Homebrew installed on your system, make sure it is up to date:
Install Xcode or make sure you are running at least Xcode 4.3.3. Both installation and update are available through the Mac App Store. Xcode is a free download.
Install Command Line Tools
Start Xcode, then go to “Preferences… - Downloads - Components” and install the “Command Line Tools”.
Now you are all set and can install SML/NJ through Homebrew:
Once SML is installed, you need to tell the operating system where to look for it. Edit your
PATH to include
/usr/local/Cellar/smlnj/110.74/libexec/bin. (Note that the exact path to use has been given to you after the installation, so yours might be slightly different from this one.)
First, open your profile in your text editor of choice:
export PATH-directive to this file:
You can now reload your profile with:
PATH will also be loaded every time you open a new terminal session.
Now that you are all done, you can start SML/NJ by typing:
One more thing
You are probably reading this article because you are currently attending a lecture on functional programming at the LMU in Munich, Germany. If so, these screencasts on SML I created while attending this lecture myself should help you hit the ground running.
There is more to learn
Get free previews of my upcoming course materials and other bonus content to help you work smarter. I share tips straight to your inbox once a week. You can read previous mails in the newsletter archive.
I respect your email privacy. Unsubscribe anytime.