Concurrent programming in ML (Abstract)

Programs written in functional languages seldom use side effects. This makes functional programs good candidates for concurrent execution, since computations without side effects can proceed concurrently without interfering. Some side effects are required for I/O and communication; we can introduce them in a disciplined way by adding message-passing primitives to a functional language. Although ML is not purely functional, it is especially well suited to concurrent programming because it has a safe polymorphic type system and garbage collection.

Following the examples of Pike's Newsqueak and Hoare's CSP, I have added concurrent primitives to ML, using the Standard ML of New Jersey compiler. The primitives provide dynamic creation of processes and channels and synchronous communication over channels. Input and output (to the Unix file system) is available on the same footing as communication over channels. I use SML-NJ's callcc and throw to simulate concurrent execution on a sequential machine.

Concurrent programs can be structured as large collections of simple processes. I present several example processes. Because they are polymorphic (i.e. they operate on values of any type), these processes can be used in many programs. I present an application that uses these processes. I comment on the implementation and suggest how it might be extended to run on a multiprocessor. I show how the Standard ML modules system can be used to effect changes in the meanings of the primitives.

The full paper is available in PostScript form.