PLDI '88 Proceedings of the ACM SIGPLAN 1988 conference on Programming Language design and Implementation
Types and programming languages
Types and programming languages
Generalized algebraic data types and object-oriented programming
OOPSLA '05 Proceedings of the 20th annual ACM SIGPLAN conference on Object-oriented programming, systems, languages, and applications
Lightweight modular staging: a pragmatic approach to runtime code generation and compiled DSLs
GPCE '10 Proceedings of the ninth international conference on Generative programming and component engineering
Variance and generalized constraints for C# generics
ECOOP'06 Proceedings of the 20th European conference on Object-Oriented Programming
Matching objects with patterns
ECOOP'07 Proceedings of the 21st European conference on Object-Oriented Programming
Reify your collection queries for modularity and speed!
Proceedings of the 12th annual international conference on Aspect-oriented software development
Hi-index | 0.00 |
Generalized algebraic data types (GADTs) allow embedding extensible typed ASTs and transformations on them. Such transformations on typed ASTs are useful for code optimization in deeply embedded DSLs, for instance when using Lightweight Modular Staging (LMS). However, in Scala it is hard to make transformations for typed ASTs type-safe. Therefore, AST transformations in LMS are often not fully typechecked, preventing bugs from being caught early and without extensive testing. We show that writing type-safe transformations in such embeddings is in fact not just hard, but impossible without using unsafe casts or significantly restricting extensibility: Declaration-site variance opens GADTs representing typed ASTs not only to desirable extensions, but also to extensions that introduce exotic terms. We make the problem concrete on an embedding of λ through covariant GADTs. We discuss solution approaches, and sketch a Scala extension to address this problem without either introducing unsafe casts or restricting extensibility. We believe a complete solution would significantly ease writing transformations by allowing type-checking to verify them, and thus would ease their development.