This paper introduces a Standard ML realization of the scrap-yourboilerplate generic-programming mechanism (first introduced by Simon Peyton Jones and Ralf Lämmel), which gives programmers tools to make writing traversal functions over complex, mutually recursive, data types considerably easier than with traditional handwritten traversal code. The scrap-your-boilerplate approach is well-known in the Haskell community, but relies on Haskell’s class system and also requires advanced features not present in standard Haskell (rank-2 polymorphism and a type-safe cast operator). None of these features are available in Standard ML. This paper shows how to provide suitable Standard ML substitutes for this “missing functionality”, and builds on those techniques to provide generic traversal-code generation in ML in a way that comes as close as possible to the original concepts as they exist in Haskell. Unlike its Haskell cousin, the ML version requires no language extensions. It also di...
Simon L. Peyton Jones, Ralf Lämmel