Scrap your boilerplate: a practical design pattern for generic programming

  title={Scrap your boilerplate: a practical design pattern for generic programming},
  author={Ralf L{\"a}mmel and Simon L. Peyton Jones},
  booktitle={ACM SIGPLAN International Workshop on Types In Languages Design And Implementation},
  • R. LämmelS. Jones
  • Published in
    ACM SIGPLAN International…
    18 January 2003
  • Computer Science
We describe a design pattern for writing programs that traverse data structures built from rich mutually-recursive data types. [] Key Method It makes essential use of rank-2 polymorphism, an extension found in some implementations of Haskell. Further it relies on a simple type-safe cast operator.

Algebraic Specialization of Generic Functions for Recursive Types

A generic recursion toolbox for Haskell or: scrap your boilerplate systematically

The scrap-your-boilerplate approach is extended by rich traversal strategies and by a combination of transformations and accumulations, which leads to a comprehensive recursive traversal library Reclib in a statically typed framework.

Scrap your nameplate: (functional pearl)

This paper shows how nominal abstract syntax techniques similar to those of FreshML can be provided as a Haskell library called FreshLib, and shows how existing genericmprogramming techniques can be used to reduce the amount of nameplate code that needs to be written for new datatypes involving names and binding to almost nothing.

Scrap more boilerplate: reflection, zips, and generalised casts

This paper adds a few extra "introspective" or "reflective" facilities, that together support a rich variety of serialisation and de-serialisation in generic programming, and generalises the ability to over-ride a generic function with a type-specific one.

Alloy: fast generic transformations for Haskell

This work describes use cases for a generic system derived from work on a nanopass compiler, and detail a new generics approach (Alloy) that is developed in Haskell to allow the authors' compiler passes to traverse the abstract syntax tree quickly.

"Scrap Your Boilerplate" Reloaded

This paper reveals the structural view that SYB builds upon, which allows us to define the combinators as generic functions in the classical sense, and shows that the SYB view is applicable to a very large class of data types, including generalized algebraic data types.

“ Scrap Your Boilerplate ” Explained

This paper reveals the structural view that SYB builds upon, and defines the combinators as generic functions in the classical sense, and shows that the SYB view is applicable to a very large class of data types, including generalized algebraic data types.

Effective strategic programming for Java developers

The goal was to make the notion of strategic programming available in a widely used language such as Java and thus to offer generic traversals in typed Java structures and present the strategy language SL that provides programming support for strategies in Java.

Scrap Your Boilerplate using Dynamic Types in Ordinary SML

This paper shows how to provide suitable Standard ML substitutes for “missing functionality”, and buildsonthosetechniques 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.

Practical generic programming in OCaml

Deriving is described, a system of extensible generic functions for OCaml implemented as a preprocessor and supporting library and it is shown how this can lead to dramatically improved performance in the serialisation task without the user writing a single line of serialisation code.



Derivable Type Classes

PolyP—a polytypic programming language extension

This paper extends a functional language with a construct for writing polytypic functions, and infers the types of all other expressions using an extension of Jones' theories of qualified types and higher-order polymorphism.

Template meta-programming for Haskell

A new extension to the purely functional programming language Haskell that supports compile-time meta-programming and the ability to generate code at compile time allows the programmer to implement such features as polytypic programs, macro-like expansion, user directed optimization, and the generation of supporting data structures and functions from existing data structure and functions.

Compiling polymorphism using intensional type analysis

This paper examines an alternative approach for compiling polymorphism where types are passed as arguments to polymorphic routines in order to determine the representation of an object, and shows how to translate an ML-like language into the target language so that primitive operators can analyze types to produce efficient representations.

A new approach to generic functional programming

A new approach to generic functional programming is described, which allows us to define functions generically for all datatypes expressible in Haskell, to model types by terms of the simply typed λ-calculus augmented by a family of recursion operators.

Typed Combinators for Generic Traversal

This work introduces emph{functional strategies: typeful generic functions that not only can be applied to terms of any type, but which also allow generic traversal into subterms.

de Bruijn notation as a nested datatype

Programming with nested types is only a little more difficult than programming with regular types, provided the authors stick to well-established structuring techniques and describe a representation in which all terms are well-formed.

Polytypic Programming

This paper introduces polytypic functions, and shows how to construct and reason about polyTYpic functions.

Generic unification via two-level types and parameterized modules

This work describes an efficient, modularized implementation of unification using the state of mutable referencecells to encode substitutions and the use of rank-2 polymorphism inside Haskell's record types to implement a form of typeparameterized modules.

Adaptive Object-Oriented Software: The Demeter Method with Propagation Patterns

This ground-breaking book presents a complete methodology for adaptive programming in any object-oriented programming language, and signals a new approach to object- oriented program design that goes beyond object encapsulation and hard-coded navigation paths to achieve more flexible interactions among objects.