GADTs Meet Subtyping

  • Gabriel Scherer
  • Didier Rémy
Part of the Lecture Notes in Computer Science book series (LNCS, volume 7792)

Abstract

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.

References

  1. [Abe06]
    Abel, A.: Polarized subtyping for sized types. Mathematical Structures in Computer Science (2006); Goguen, H., Compagnoni, A. (eds.) Special issue on subtypingGoogle Scholar
  2. [EKRY06]
    Emir, B., Kennedy, A., Russo, C.V., Yu, D.: Variance and Generalized Constraints for C# Generics. In: Thomas, D. (ed.) ECOOP 2006. LNCS, vol. 4067, pp. 279–303. Springer, Heidelberg (2006)CrossRefGoogle Scholar
  3. [Gar04]
    Garrigue, J.: Relaxing the Value Restriction. In: Kameyama, Y., Stuckey, P.J. (eds.) FLOPS 2004. LNCS, vol. 2998, pp. 196–213. Springer, Heidelberg (2004)CrossRefGoogle Scholar
  4. [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
  5. [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
  6. [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
  7. [SR]
    Scherer, G., Rémy, D.: GADTs meet subtyping. Long version, available electronically, http://gallium.inria.fr/~remy/gadts/

Copyright information

© Springer-Verlag Berlin Heidelberg 2013

Authors and Affiliations

  • Gabriel Scherer
    • 1
  • Didier Rémy
    • 1
  1. 1.INRIARocquencourtFrance

Personalised recommendations