I became interested in ML programming when I taught CS109, the introduc-
tory Computer Science Foundations course at Stanford, starting in 1991. ML
was used by several of the instructors of this course, including Stu Reges and
Mike Cleron, to introduce concepts such as functional programming and type
systems. It was also used for the practical purpose of introducing a second
programming paradigm, other than the Pascal or С that students learned in
the introductory programming course. Reimplementing algorithms and data
structures in a significantly different language often is an aid to understanding
of basic data structure and algorithm concepts.
I first learned ML from the notes that Reges and Cleron had written for
their students. Initially, I was intrigued by the rule system, which gave me
much of the power of Prolog, a language with which I had worked for several
years. Yet ML did not introduce the semantic complexity that comes from the
use of unification and backtracking in Prolog. However, I soon discovered other
charms of ML: the type system, the use of exceptions, and the module system
for creating abstract datatypes, among others. From the Reges and Cleron
notes I also picked up the utility of giving the student a fast overview, stressing
the most commonly used constructs rather than the complete syntax.
In writing this guide to ML programming, I have thus departed from the
approach found in many books on the language. As an outsider, I had the
opportunity to learn the language from the standpoint of the typical program-
mer. I have tried to remember how things struck me at first, the analogies I
drew with conventional languages, and the concepts that I found most useful
in getting started. I hope that my selection is accurate, and that the book will
facilitate the reader's transition from conventional languages to ML.