COMP 212: Functional Programming

Help Sessions

Sunday (Cole, Caroline), 7:30pm-9pm
Monday non-US timezones (Mitchell), 7am UTC
Monday (Joe, Adina), 7:30pm-9pm
Wednesday (Ammie), 1:30-3pm
Wednesday (Isabel), 7:30pm-9pm
Thursday (Phil), 7:30pm-9pm

Office hours: In a class this large, it doesn't work very well to have office hours for homework help in my office, so I'll often come to some of the TA sessions. Or, feel free to email me to set up a one-on-one meeting!


Lab 1 (Phil, Adina): Tuesday, 1:20pm-2:40pm
Lab 2 (Isabel, Ammie, Caroline, Mitchell): Tuesday, 2:50pm-4:10pm


We will use Piazza for questions about the assignments, for students to discuss course materials, and to make announcements about the class. You are responsible for being current with the information and discussions that are posted there.

You will get an email from Piazza with a link inviting you to create an account within the first week of the term. If you haven't gotten one in that time, please contact course staff.

In addition to the web interface, there are Piazza apps for Android and iOS available for free through their respective app stores.


Common recurrences


To install a local copy of sml/nj:

Mac OS

  1. Download and run this installer (you may need to right click and Save link as..). Note: The installer works on macOS Catalina, but you will need to right-click on the installer to launch it, since it is not a notarized installer.
  2. In the terminal, run
              xcode-select --install 
    Run the installer that pops up if one does; otherwise you already have the command line tools installed.
  3. To have a nicer SML interactive prompt, install MacPorts. Note: even though it says you need to install XCode, you probably don't (tested on Mojave). Then, in Terminal (to open Terminal, go to Applications/Utilities), run
    sudo /opt/local/bin/port install rlwrap
    rlwrap is a utility that lets you use the left/right arrow keys to move around and use the up/down arrows to go through lines you have previously typed.
  4. In the terminal, run
    echo 'export PATH="/opt/local/bin:/usr/local/smlnj/bin:${PATH}"' >> ~/.bash_profile
  5. In the terminal, run
    echo 'alias smlnj="rlwrap sml"' >> ~/.bash_profile
  6. If you are on the latest MacOS (Catalina) and don't have strong preferences about what unix shell you use, run
    	chsh -s /bin/bash
    (then type your mac password and hit enter when prompted) to switch your default shell to BASH from the new default of zsh. If you do have strong preferences about using zsh, then add the equivalent of the above lines setting your PATH and smlnj alias to your zsh startup files.
  7. Start a new terminal and you should be able to run smlnj to start SML.


  1. Use this installer. When it asks where to install, choose C:\SMLNJ\ (the default is in Program Files, but the space in that name can confuse cygwin, so change it).
  2. Cygwin lets you do Unix-y things on Windows; it will come in handy in other CS classes. First, you need a standard Cygwin installation. Download the 32-bit Cygwin installer from (do not get the 64-bit variant). Run the installer using standard paths (should install to C:\cygwin). Eventually, it will ask you which packages to install. Search for the following packages, and for each one, click "Skip" once so a version number appears, like in the image ("Skip" means "do not install"; the version number means "install this version"). You only need one of the packages that come up when you search, not all of them.

    • tar (may already be selected)
    • rlwrap
  3. The Cygwin installer will create a shortcut on the desktop which opens a Cygwin shell. If it fails, you can create a shortcut to C:\cygwin\bin\mintty.exe and change the "Start in" field to %USERPROFILE%.

  4. In the cygwin terminal, run
    echo 'export PATH=$PATH:/cygdrive/c/SMLNJ/bin'>> ~/.bash_profile
  5. Then run
    echo 'alias smlnj="rlwrap sml.bat"' >> ~/.bash_profile
    Note: Some students had trouble with rlwrap on Windows 10, in which case you can avoid it by instead doing
    echo 'alias smlnj="sml.bat"' >> ~/.bash_profile
  6. Start a new cygwin terminal and you should be able to run smlnj to start SML.

Text Editor

We recommend Atom or Sublime Text or GNU emacs for editing SML source files.

Sublime Text

Sublime Text is available here; get version 3.

More specifically:
  1. Download the installer for your operating system. On Windows, follow the instructions in the installer. On Mac, navigate to your downloads and open the .dmg file. A pop-up containing your local Applications folder and a Sublime Text 3 file. Drag the Sublime Text file into the Applications folder.
  2. On Windows, you can open Sublime Text through the Start Menu. On Mac, you can open Sublime Text in one of three ways:
    • Finder: Open a new Finder window, navigate to your Applications folder (it should be listed in the left-hand column) and double-click on Sublime Text.
    • Terminal: In terminal, enter “cd /Applications ; open Sublime\“.
    • Launchpad: Open Launchpad and search for Sublime Text.
    You may want to put a shortcut to Sublime Text on your desktop/in your Dock.
  3. Install Package Control: Go to the Tools menu, click on Command Pallet, and then type Install Package Control.
  4. To get syntax highlighting, install the "SML (Standard ML)" package:
    1. Press on Tools > Command Palette in the menu bar and search for “install package”, then press enter with Package Control: Install Package.
    2. Search for “SML (Standard ML)” and press enter to install.
  5. To use SML highlighting, you may now navigate to View > Syntax > SML.


If you want to use Atom, you can. The support for SML is not quite as nice as emacs or Sublime, but it's as beginner-friendly as Sublime and open-source like Emacs. You'll want to install the language-sml package by going to Prefrences/Settings and then choosing the Install tab.


If you have Linux, you almost certainly have emacs installed. For Mac and Windows get:

To install SML syntax highlighting:

  1. Make a software directory in your home directory (to do this in the terminal, run mkdir ~/software/).
  2. Download sml-mode.tar and unzip it in your software directory (to find it outside the terminal, your software directory will be in software in your home directory on a Mac or in C:\cygwin\users\YOURNAME\software on Windows). This will create a directory ~/software/sml-mode-3.3-custom.
  3. Open Emacs, type Control-x Control-f to open a file, and then edit the line at the bottom of the screen to
            Find file: ~/.emacs
    and press enter. This is your emacs startup file.
  4. Copy the the contents of dotemacs-win.txt (Windows) or dotemacs-mac.txt (Mac) into this file. On Windows, you will need to edit the first line, replacing YOURNAME with your Cygwin user name. NOTE: The windows file is untested; let me know if you have problems.
  5. Save, close, and restart emacs.
  6. When you open emacs again and open a file.sml, it will now color the syntax. Also, you can run SML inside emacs as follows:
    • Control-c Control-b: load the current emacs buffer into the SML repl.
    • Control-c Control-s: pop up a separate window with the SML repl.

Some emacs resources: