Types that Change: The Extensible Type Design Pattern
Compilers are often structured as chains of transformations, from source code to object code, through multiple intermediate representations. The existence of different representations of the same program presents challenges both for code maintenance and in terms of architecture. The types used to capture programs at multiple stages may be similar but not interchangeable, leading to code duplication. Methods to alleviate such duplication often lead to violations of software engineering principles of abstraction and encapsulation. This pearl discusses a design pattern where an algebraic data type (ADT) is extended with an argument type function that is applied to every component of the ADT. The resulting parametric type can be instantiated with multiple type functions, each providing a different feature. We demonstrate the versatility of this pattern by capturing notions of traceability and error recovery, and demonstrate that it can also be used to selectively modify existing types, as well as to extend them. Our proposal has been validated by applying it to a real-world use case with very good results.
Sr. Research Scientist @ KBR / NASA Ames Research Center
Past: IMDEA Software, Keera Studios, HLRS Stuttgart, University of Nottingham, University of Twente, Polytecnic University of Madrid (UPM).
Fri 8 SepDisplayed time zone: Pacific Time (US & Canada) change
16:00 - 17:30
|Typed Design Patterns for the Functional Era
A: Will Crichton Brown UniversityDOI
|Types that Change: The Extensible Type Design Pattern
A: Ivan Perez NASA Ames Research CenterDOI