Good advice for type-directed programming aspect-oriented programming and extensible generic functions

Geoffrey Washburn, Stephanie Weirich
2006 Proceedings of the 2006 ACM SIGPLAN workshop on Generic programming - WGP '06  
Type-directed programming is an important idiom for software design. In type-directed programming the behavior of programs is guided by the type structure of data. It makes it possible to implement many sorts of operations, such as serialization, traversals, and queries, only once and without needing to continually revise their implementations as new data types are defined. Type-directed programming is the basis for recent research into "scrapping" tedious boilerplate code that arises in
more » ... nal programming with algebraic data types. This research has primarily focused on writing type-directed functions that are closed to extension. However, Lämmel and Peyton Jones recently developed a technique for writing openly extensible type-directed functions in Haskell by making clever use of type classes. Unfortunately, this technique has a number of limitations such as the inability to write specialized cases for existential or nested data types and function types becoming too constrained to be used as first-class functions. We present an alternate approach to writing openly extensible type-directed functions by using the aspect-oriented programming features provided by the language AspectML. Our solution not only avoids the limitations present in Lämmel and Peyton Jones's technique, but also allows type-directed functions to be extended at any time with cases for types that were not even known at compiletime. This capability is critical to writing programs that make use of dynamic loading or runtime type generativity.
doi:10.1145/1159861.1159867 dblp:conf/icfp/WashburnW06 fatcat:ucv7oc4hazfypcthnscoewh3y4