Core ML

COMP 105 Assignment

Due Tuesday, October 16, 2018 at 11:59PM

NEXT TIME: YOU ABSOLUTELY MUST RUN THE ML SANITY CHECKER (WHICH NEEDS TO FUNCTORIZE ENVBOTH, BY THE WAY.)

Overview

The purpose of this assignment is to help you get acclimated to programming in Standard ML, which you will use in the next few weeks to implement type systems and lambda calculus. The assignment has three parts:

After completing this assignment, you will be ready to tackle serious programming tasks in Standard ML.

Prelude

Setup

COMP 105 uses two different implementations of Standard ML. For the small problems, we recommend Moscow ML, which is in /usr/sup/bin/mosml. To start Moscow ML, use

ledit mosml -P full -I /comp/105/lib

If everything is working correctly, you should see this prompt:

Moscow ML version 2.10-3 (Tufts University, April 2012)
Enter `quit();' to quit.
- 

If you don’t see the Tufts name, send an immediate email of complaint to staff@cs.tufts.edu, with a copy to comp105-grades@cs.tufts.edu.

For the large problem, we recommend a native-code compiler called mlton (pronounced “Milton”).

The initial basis

As in the hofs and continuations assignments, we expect you to use the initial basis, which is properly known as the Standard ML Basis Library. By the standards of popular languages, the basis is quite small, but it is still much more than you can learn in a week. Fortunately, you only have to learn a few key parts:

The most convenient guide to the basis is the Moscow ML help system; type

- help "";

at the mosml interactive prompt. The help file is badged incorrectly, but as far as I know, it is up to date.

If you have Jeff Ullman’s book, you need to know that Chapter 9 describes the 1997 basis, which is out of date: today’s compilers use the 2004 basis, which is a standard. But there are only a few differences, primarily in I/O and arrays. The most salient difference is in the interface to TextIO.inputLine.

Things you need to review before starting

We provide a guide to Learning Standard ML. And