Elementary Standard ML [book]

G Michaelson
2014
University College London Press, UK, 1995, ISBN 1-85728-398-8 PB, pp 306 Standard ML is a functional programming language that is often used for teaching the principles of programming to rst year Computer Science students. Often the teacher of a functional programming language has to be like a doctor: The medicine is bitter but he says that it is good for you. Most students may know some C, Pascal or Basic, and they will nd a functional language alien, dislikable or even useless. It is quite a
more » ... hallenge to write a book that will appeal to such students. Elementary Standard ML tries to meet the challenge by approaching the subject in a way that is a little di erent from that chosen by the classical texts (for example 1, 2]). Elementary Standard ML does not make heavy use of mathematics as many of the competitors do. At rst I thought that this would be a missed opportunity but after having read the book, I felt positive about it. Michaelson presents the important concepts in a way that is as simple as possible. In spite of this, rigour is not sacri ced: The book contains a large number of derivations that show step-by-step how an expression is evaluated to its result. The derivations are presented in a natural term rewriting style without betraying their mathematical origins. Theorems and proofs would be out of place in Elementary Standard ML, and they are thus not present. The second aspect that I liked about the book is the modelling approach to problem solving as described in the rst chapter. The fundamental idea that a problem can be solved by decomposing it into more manageable sub-problems is nicely explained. The discussion then naturally leads on to presenting the concept of a type as a means of conveying information about the solutions of problems and to maintain the consistency of solutions. The second chapter discusses basic types, as they form the foundations of both programming in a strongly typed languages (SML) and problem solving. The SML basic types are discussed in rather a lot of detail. This is hard to avoid, mainly because SML does not support overloading properly. The third chapter gives an in depth discussion of functions over values of basic types. The separation of the concepts of naming and abstraction is nicely presented, even though the notation provided by SML for this separation is a bit awkward. In between the lines I read the essence of the -calculus, but Michaelson has skillfully avoided the mathematical notation (which would put students o completely), the intricacies of -conversion, and even di cult words and de nitions. The computational model for SML is nevertheless developed in a highly e ective way. I regard this as a strong pedagogical feature of the book. Chapter 4 discusses more advanced use of functions, using pattern matching and recursion. Here I felt that more emphasis should have been put on the case analysis that precedes the creation of functions. Important issues such as'should all cases be disjoint', and'should all cases be covered' and'what to do when not all cases are covered' are unfortunately not discussed systematically. Chapter 5 discusses lists in a rather operational fashion. This did not appeal to me, but Michaelson also gives the usual inductive de nition of a list (using plain English). The computational model introduced earlier is a bit too simple to cope well with pattern matching, but the presentation used in the book is acceptable. Chapter 6 discusses higher order functions, mainly operating on lists. Many of the examples here use accumulating arguments which seems a little arti cial. Neater solutions are available to many of the problems presented. These solutions are discussed later, when let expressions are introduced. Chapter 7 discusses the combination of using lists and tuples, to create the data structures that were called for in the analyses of the rst chapter. We are now on page 155, so the reader has to go through a lot of detail before the problems discussed in the rst chapter can nally be solved. This is the weakest point of the book. I would have welcomed a stronger connection between the study of the SML language, and problem solving. Some of the solutions in chapter 7 are a bit ad hoc, where combinations of map, filter, foldr and/or foldl would have been appropriate. I realise that students dislike foldl and foldr, but map and filter are generally appreciated. Chapter 8 puts the material of the preceding 7 chapters into practice by building a collection of text processing functions. Here the detailed step-by-step derivations gets a bit long winded; perhaps the student might at this stage be able to ll in some intermediate steps. SML does not treat a list of characters as a string, hence the functions in this chapter make pro igate use of explode and implode. This is unpleasant but alas unavoidable.
doi:10.1201/9781315273587 fatcat:ok3r2lwydbeuvekkyo4xmblhca