sml

introduction

sml is an implementation of the strongly-typed functional programming language ML. To run sml in a command window, just type

sml

at a command prompt. Test it by typing

val a = 2 + 3;

and you should see the response

val a = 5 : int

To terminate an sml session, type control-d.

downloads

The sml home page is at Bell Labs. A Linux rpm package can be downloaded from this download page.

installation

Install sml with

rpm -i smlnj-110.0.6.i386.rpm

emacs support for sml programming: sml-mode

Mathew J. Morley's sml-mode provides support for programming with sml under emacs. Here is an sml-mode download site. Since our emacs is in /usr/share, it is most convenient to download and unpack the sml-mode distribution into that directory.

su root
mv sml-mode-3.9.3.tar.gz /usr/share
cd /usr/share
tar xzvf sml-mode-3.9.3.tar.gz 

This creates the directory /usr/share/sml-mode-3.9.3. Now cd into it.

cd sml-mode-3.9.3

The next step is to modify the Makefile. Our emacs is in /usr/share, so change the line

prefix  = /usr/local

to just

prefix  = /usr

Now install sml-mode:

make install
make install_startup 

The sml-mode documentation is in /usr/share/sml-mode-3.9.3/sml-mode.info It is also available from the sml menu inside emacs when you are in sml-mode.

To test sml-mode, open emacs on an sml file such as records.sml which we have borrowed from the early pages of Paulson's fine text. Note that the file which is served from this page is actually named "records.ml" since un-schooled Macintoshes insist on interpreting .sml files as some sort of Quicktime document. (Mac users may be more apt to watch movies than program.) You will want to rename it "records.sml" because emacs automatically opens in sml-mode when launched on a file ending in .sml or .sig.

emacs records.sml &

You should see an indication that you are in sml-mode at the bottom of the emacs window. Go to emacs's sml menu and select SML mode *info*. You should see the info file for sml-mode. Type q to quit sml info. Type C-x 2 to split your screen, C-x o to move the cursor to the bottom pane, and M-x run-sml to run an sml process in the background. Then from the Buffers menu, select the *sml* buffer to view the sml process in the bottom pane. To test that we have a live session, type

Math.sqrt 2.0;
to an sml prompt. You should see the response
val it = 1.41421356237 : real

Select the sml code in the buffer displaying records.sml, and then select "process:send buffer contents" from the sml menu. You should see the code echoed in the bottom sml buffer, and the non-committal response

val it = () : unit

Now find out what it was that King Richard III said by typing the following to the sml prompt:

#quote richardIII;

If your karma is all that it should be, you will see

val it = "Plots have I laid, inductions dangerous..." : string

and you can celebrate that you, emacs, and sml are right with the world.

Click in the bottom pane and type C-d to terminate the sml process, C-x o to move the cursor to the top pane, and C-x 1 to collapse the bottom pane. Type C-x C-c to exit emacs.

ml programming references

ml people

programming languages courses featuring/mentioning ML




cparrish@sewanee.edu