"I do not believe in object-oriented programming."
Functional Pearls: Drawing Trees
Andrew Kennedy.
Journal of Functional Programming, 6(3): 527-534, Cambridge
University Press, May 1996.
This article describes the application of functional programming techniques to a problem previously studied by imperative programmers, that of drawing general trees automatically. We first consider the nature of the problem and the ideas behind its solution (due to Radack), independent of programming language implementation. We then describe a Standard ML program which reflects the structure of the abstract solution much better than an imperative language implementation. We conclude with an informal discussion on the correctness of the implementation and some changes which improve the algorithm's worst-case time complexity.
Functional Pearls: Pickler
Combinators
Andrew Kennedy. Journal of Functional Programming, special issue on Functional Pearls, 14(6): 727-739, Cambridge University Press, Nov 2004.
The tedium of writing pickling and unpickling functions by hand is relieved using a combinator library similar in spirit to the well-known parser combinators. Picklers for primitive types are combined to support tupling, alternation, recursion, and structure sharing. Code is presented in Haskell; an alternative implementation in ML is discussed.