Programming With Miranda

This page gives brief information about our new book, which will be available in the bookshops from 3rd October 1994. If you want to find my home page, click here.

Chris Clack, Colin Myers and Ellen Poon

published Prentice Hall, 1994 (317pp)

ISBN 0-13-192592-X



"The purpose of this book is to teach structured programming skills using the functional language Miranda. It may be used as an introductory textbook for people with little programming experience or as an intermediate textbook for more advanced programmers who wish to learn a functional programming language.

The approach we adopt in this book is to show good software engineering principles by discussion of both correct and incorrect design decisions, using realistic examples. There is no Ackermann function and there are no miracles.

The book was developed during the teaching of functional programming courses to first and second year undergraduates, and both advanced and conversion postgraduate classes at University College London (UCL). and at the University of Westminster (formerly PCL)."


The first two chapters of the book provide a simple introduction to Miranda syntax and the functional approach to programming, whilst also serving to re-orientate the imperative programmer. Some of the features shown will be quite familiar to anyone with imperative programming experience: these features include the standard mathematical operators, the clear distinction made between different types of data and the idea of function definition and application. Novel features are dealt with in greater depth: these include pattern matching, polymorphism and the use of recursion for program control.

The third and fourth chapters explore in depth the heart of the functional style. They are core to Miranda (and functional) programming and will probably appear quite new to a programmer only familiar with an imperative programming language. In Chapter 3, the list aggregate type is introduced as the most fundamental Miranda data structure and various styles of recursive programming using lists are investigated. The chapter ends with the design of a program similar to the UNIX utility grep, which is used in subsequent chapters to highlight the expressive power of new features. Chapter 4 introduces the important concept of partial application and demonstrates that functions can be treated as data. It also shows how recursive solutions to programming tasks can be generalized to facilitate control structure abstraction.

Chapter 5 explores two important concepts: controlling the availability of identifiers and functions, and also lazy evaluation. The former is essential for any production programming since it gives the ability to make blocks of code private to other blocks of code - thereby enabling safer and more re-usable software. The latter provides an important mechanism for combining functions and structuring programs.

The next two chapters explore the relationship between data and process by showing Miranda's powerful facilities to create new types and data structures, and also to encapsulate a type and its associated operations into a single abstraction.

Chapter 8 introduces the programmer to file handling and interactive programming, whilst Chapter 9 provides tools for medium to large scale program construction.

It is recommended that the main body of the book is studied sequentially, and that the reader attempt the exercises as they are encountered. The exercises serve both as a review of the student's current knowledge and also as a commentary on the text: sample solutions are given at the end of the book.