Good advice for type-directed programming aspect-oriented programming and extensible generic functions
Geoffrey Washburn, Stephanie Weirich
Abstract
Geoffrey Washburn, Stephanie Weirich
Abstract
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 functional 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.
OpenAlex reports 10 citations for this work. Citation counts describe recorded attention and do not establish research quality.
A contribution statement is not available in the OpenAlex record.
Method details are not available in the OpenAlex metadata.
Findings are not separately available in the OpenAlex metadata.
Limitations are not available in the OpenAlex metadata.
Application details are not available in the OpenAlex metadata.
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 functional 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.
Key concepts: Computer science, Programming language, Haskell, Data type, Generic programming, Functional programming, Type safety, Abstract data type