To some readers functional pearls may seem like London buses: you can wait ages for one and then two or three come along at once. In the following pages you will find no less than three pearls for your enjoyment and instruction. There are a number of others a little way down the road, so I trust that your pleasure will continue for some time yet.If my calculations are correct, twenty-seven pearls have been published in the eight and a half years since JFP was inaugurated. There was something of a desert in 1994 and 1995, but since January 1997 they have been appearing in virtually every issue. When I was asked to contribute a regular column to JFP in 1990, the general idea was for something in style that was a mixture of Jon Bentley's Programming Pearls column for the Communications of the ACM, and Martin Rem's Small Programming Exercises section in the Science of Computer Programming. Articles could be on any subject, but they had to be polished, preferably short, and to show something of the unique opportunities a functional perspective could offer to the study of computing. In my own case that usually meant the use of functional notation to derive programs from their specifications, to optimise them, and to reason about their properties in an equational style. Over the years it has emerged that a functional approach is also extremely attractive in the presentation of ideas about data structures, and some very intriguing pearls have been about the use of elegant data structures to achieve efficiency. But there have also been pearls about particular applications, like parsing, pretty-printing, theorem proving, and unification. In fact, practically every area of computing science can benefit from the clarity and brevity a functional approach can offer. That is why I believe the importance of the subject goes beyond the activity of simply writing code in a functional language.I knew from the outset that I wasn't going to write all of the pearls, and believed that other contributors would soon emerge. Fortunately, I was right: I have written about a third, but some twenty contributors have composed the rest. Authors like writing pearls perhaps because they like responding to the opportunities and challenges provided by the format. All pearls are refereed (including my own), and there is often a fair amount of polishing as a result of the reviewing stage. I would like to record my gratitude to the authors of the pearls so far published (Stephen Adams, Lennart Augustsson, Koen Claessen, Martin Erwig, Jeremy Gibbons, Ralf Hinze, Rob Hoogerwoord, Gerard Huet, Graham Hutton, Patrik Jansson, Johan Jeuring, Andrew Kennedy, Jamie Leifer, Doug Mcllroy, Eric Meijer, Chris Okasaki, Mikael Rittri, Colin Runciman, Bernard Sufrin, Dan Synek) and to ask them, and others, to continue in their good work.
Read full abstract