COMP 212: Functional Programming

Office Hours

Dan: Thursday, 2:30-3:30pm, Exley 633
Samuel: Sunday, 7pm-8:30pm, Exley 109
Hailey: Monday, 7:30pm-9pm, Exley 109
Lizzie: Tuesday, 7:30pm-9pm, Exley 109


Lab 1 (Samuel): Wednesday, 5:30pm-7pm, Exley 72
Lab 2 (Lizzie, Hailey): Wednesday, 7pm-8:30pm, Exley 72


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


SML of New Jersey (sml/nj) is installed in the Wesleyan Mac labs (e.g. the one on Exley 1st floor). It can be run by starting Terminal and typing sml. They are running version 110.76. You can use a variant of Emacs called Aquamacs to edit SML files (instructions for how to set up syntax highlighting for Aquamacs coming soon).

To install a local copy of sml/nj:

Mac OS

  1. Download and run this installer.
  2. To have a nicer SML interactive prompt, install MacPorts. 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.
  3. In the terminal, run
    echo 'export PATH="/opt/local/bin:/usr/local/smlnj/bin:${PATH}"' >> ~/.bash_profile
  4. In the terminal, run
    echo 'alias smlnj="rlwrap sml"' >> ~/.bash_profile
  5. 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.

    a Cygwin installation screenshot
    • 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
  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 2.

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 Sublime Text 2.0.2.dmg file. A pop-up containing your local Applications folder and a Sublime Text 2 file. Drag the Sublime Text 2 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 2.
    • Terminal: In terminal, enter “cd /Applications ; open Sublime\ Text\“.
    • Launchpad: Open Launchpad and search for Sublime Text 2.
    You may want to put a shortcut to Sublime Text on your desktop/in your Dock.
  3. Install Package Control:
    1. Open Sublime Text and access the console via View > Show Console in the menu bar.
    2. Copy the code from here into the console's bottom white bar, and then press enter. You should be prompted to restart Sublime Text.
    3. Restart Sublime Text.
  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.
    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 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.tgz 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:


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 SML package from the settings page.
Valid CSS! Valid XHTML 1.0 Strict