COMP 212: Functional Programming

Help Sessions

Lucas: Sunday, 7:10pm-8:40pm, Exley 109
Joe: Monday, 4:20pm-5:50pm, Exley 109
George: Tuesday, 7:10pm-8:40pm, Exley 109
Winona: Thursday, 7:10pm-8:40pm, Exley 109
Dan: See you at the above, or send me an email to make an appointment!

Labs

Lab 1 (Lucas, Joe): Wednesday, 5:40pm-7:10pm, Exley 72
Lab 2 (George, Winona): Wednesday, 7:10pm-8:40pm, Exley 72

Piazza

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.

Handouts

Common recurrences

SML

To install a local copy of sml/nj:

Mac OS

  1. Download and run this 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. Start a new terminal and you should be able to run smlnj to start SML.

Windows

  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 http://cygwin.com/install.html (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
        
  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\ Text.app/“.
    • 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.

Atom

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.

Emacs

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: