GADTs Meet Subtyping
While generalized algebraic datatypes (GADTs) are now considered well-understood, adding them to a language with a notion of subtyping comes with a few surprises. What does it mean for a GADT parameter to be covariant? The answer turns out to be quite subtle. It involves fine-grained properties of the subtyping relation that raise interesting design questions. We allow variance annotations in GADT definitions, study their soundness, and present a sound and complete algorithm to check them. Our work may be applied to real-world ML-like languages with explicit subtyping such as OCaml, or to languages with general subtyping constraints.
KeywordsEquality Constraint Inference Rule Variance Annotation Closure Property Proof Obligation
- [Abe06]Abel, A.: Polarized subtyping for sized types. Mathematical Structures in Computer Science (2006); Goguen, H., Compagnoni, A. (eds.) Special issue on subtypingGoogle Scholar
- [KR05]Kennedy, A., Russo, C.V.: Generalized algebraic data types and object-oriented programming. In: Proceedings of the 20th Annual ACM SIGPLAN Conference on Object-Oriented Programming, Systems, Languages, and Applications (2005), http://research.microsoft.com/pubs/64040/gadtoop.pdf
- [Pfe01]Pfenning, F.: Intensionality, extensionality, and proof irrelevance in modal type theory. In: Proceedings of the 16th IEEE Symposium on Logic in Computer Science, LICS 2001, June 16-19. Boston University, USA (2001)Google Scholar
- [SP07]Simonet, V., Pottier, F.: A constraint-based approach to guarded algebraic data types. ACM Transactions on Programming Languages and Systems 29(1) (January 2007)Google Scholar
- [SR]Scherer, G., Rémy, D.: GADTs meet subtyping. Long version, available electronically, http://gallium.inria.fr/~remy/gadts/