\documentstyle[12pt]{article}
\topmargin=-0.5in
\oddsidemargin=-0.225in
\textwidth=6.5in
\textheight=9in
\newcommand{\I}[1]{{\tt #1}}
\setlength{\parskip}{1em}
\setlength{\parindent}{0in}
\begin{document}

\begin{center}\bf
        {\Large Com Sci 221 --- Programming Languages}\\[3ex]
        {\Large\bf Using Standard ML of New Jersey}\\[3ex]
        (by Steph Bailey, edited by Mike O'Donnell, Dec. 1994)
\end{center}

\subsection{Working the Compiler}
Once you have created your source program, using your favorite editor,
you would like to compile it and run it.  This is accomplished by
running the ML program, and then loading the file, and then asking ML
to perform some task for you (much like LISP or Prolog systems).

Below is a sample ML session with my {\tt prop.sml} program:

\begin{verbatim}
Sun3: ml
Standard ML of New Jersey, Version 0.24, 22 November 1988
val it = () : unit
- use "prop.sml"; (* Load prop.sml *)
[opening prop.sml]
datatype  truth
con FALSE : truth
con TRUE : truth
datatype  term
con AND : term * term -> term
con CON : truth -> term
con NOT : term -> term
con OR : term * term -> term
con VAR : string -> term
val negate = fn : term -> term
val cnf = fn : term -> term
[closing prop.sml]
val it = () : unit
- cnf(OR(AND(VAR "p",VAR "q")), VAR "r")); (* Test a case *)
val it = AND (OR (VAR #,VAR #),OR (VAR #,VAR #)) : term
- (* # means that there is more to the list, but it is not printed *)
- (* Now set the magic variable to the whole list *)
- System.Control.Print.printDepth:= 10;
val it = () : unit
- cnf(OR(AND(VAR "p",VAR "q")), VAR "r")); (* Test the case again *)
val it = AND (OR (VAR "p",VAR "r"),OR (VAR "q",VAR "r")) : term
- (* This time it printed the whole list *)
- ^D
Sun3:
\end{verbatim}

\subsection{Documentation}
One of the easiest ways to learn a programming language is by example.
If you have many good examples, you often don't even need a text (at
least for basic language use).  Fortunately, Standard ML of New Jersey
comes with a whole suite of interesting examples which can be found in
\begin{quotation}
{\em /usr/local/share/classes/cs221/examples}
\end{quotation}

The {\em prop.sml}
program I used above is just one of the many fine examples to be found
in this directory.

The reference manual for ML is in \LaTeX\ form in:
\begin{quotation}
{\em /usr/local/share/classes/cs221/refman}
\end{quotation}
There are a number of {\em .tex} files, each of which is a chapter of
the reference manual.  The easiest way to view these is to simply type
them out on the terminal, and ignore any funny stuff that you see in
the files (formatting commands).  Please don't print the reference
manual out because it is sure to be many pages which will just go to
the recycling bin shortly after you print it. I will print one copy
for each of you early in the quarter. For the small programs you write
for class, you probably won't need debugging tools. In case you want
to look into debugging in ML, instructions are in
{\em /usr/local/share/classes/cs221/debug}.

Unfortunately, the MacLab tutors are not well versed in ML, so your
best source of information is the instructor, or one of your fellow
students.  For general Unix questions, however, the tutors are usually
excellent sources of advice.
\end{document}
