Abstract
GADTs, short for Generalized Algebraic DataTypes, which allow constructors of algebraic datatypes to be non-surjective, have many useful applications. However, pattern matching on GADTs introduces local type equality assumptions, which are a source of ambiguities that may destroy principal types—and must be resolved by type annotations. We introduce ambivalent types to tighten the definition of ambiguities and better confine them, so that type inference has principal types, remains monotonic, and requires fewer type annotations.
Access provided by Autonomous University of Puebla. Download to read the full chapter text
Chapter PDF
Similar content being viewed by others
Keywords
These keywords were added by machine and not by the authors. This process is experimental and the keywords may be updated as the learning algorithm improves.
References
Baars, A.I., Swierstra, S.D.: Typing dynamic typing. In: ICFP 2002: Proceedings of the 7th ACM SIGPLAN International Conference on Functional Programming, pp. 157–166. ACM Press (2002)
Cheney, J., Hinze, R.: First-class phantom types. Computer and Information Science Technical Report TR2003-1901, Cornell University (2003)
Garrigue, J.: A certified implementation of ML with structural polymorphism. In: Ueda, K. (ed.) APLAS 2010. LNCS, vol. 6461, pp. 360–375. Springer, Heidelberg (2010)
Garrigue, J.: Monomophic let in OCaml? (September 2013), Blog article at: http://gallium.inria.fr/blog/monomorphic_let/
Garrigue, J., Rémy, D.: Semi-explicit first-class polymorphism for ML. Information and Computation 155, 134–171 (1999)
Garrigue, J., Rémy, D.: Ambivalent types for principal type inference with GADTs (June 2013), Available electronically at http://gallium.inria.fr/~remy/gadts/
Le Botlan, D., Rémy, D.: Recasting MLF. Information and Computation 207(6), 726–785 (2009)
Leroy, X., Doligez, D., Frisch, A., Garrigue, J., Rémy, D., Vouillon, J.: The OCaml system release 4.00, Documentation and user’s manual. Projet Gallium, INRIA (July 2012)
Lin, C.-K., Sheard, T.: Pointwise generalized algebraic data types. In: Proceedings of the 5th ACM SIGPLAN Workshop on Types in Language Design and Implementation, TLDI 2010, pp. 51–62. ACM, New York (2010)
Milner, R.: A theory of type polymorphism in programming. Journal of Computer and System Sciences 17, 348–375 (1978)
Pottier, F., Régis-Gianas, Y.: Stratified type inference for generalized algebraic data types. In: Proceedings of the 33rd ACM Symposium on Principles of Programming Languages (POPL 2006), Charleston, South Carolina, pp. 232–244 (January 2006)
Schrijvers, T., Peyton Jones, S., Sulzmann, M., Vytiniotis, D.: Complete and decidable type inference for gadts. In: Proceedings of the 14th ACM SIGPLAN International Conference on Functional Programming, ICFP 2009, pp. 341–352. ACM, New York (2009)
Sheard, T., Linger, N.: Programming in Omega. In: Horváth, Z., Plasmeijer, R., Soós, A., Zsók, V. (eds.) CEFP 2007. LNCS, vol. 5161, pp. 158–227. Springer, Heidelberg (2008)
Simonet, V., Pottier, F.: A constraint-based approach to guarded algebraic data types. ACM Transactions on Programming Languages and Systems 29(1) (January 2007)
Vytiniotis, D., Peyton Jones, S., Schrijvers, T., Sulzmann, M.: OutsideIn(X) Modular type inference with local assumptions. Journal of Functional Programming 21(4-5), 333–412 (2011)
Xi, H., Chen, C., Chen, G.: Guarded recursive datatype constructors. In: Proceedings of the 30th ACM SIGPLAN-SIGACT Symposium on Principles of Programming Languages, POPL 2003, pp. 224–235. ACM, New York (2003)
Author information
Authors and Affiliations
Editor information
Editors and Affiliations
Rights and permissions
Copyright information
© 2013 Springer International Publishing Switzerland
About this paper
Cite this paper
Garrigue, J., Rémy, D. (2013). Ambivalent Types for Principal Type Inference with GADTs. In: Shan, Cc. (eds) Programming Languages and Systems. APLAS 2013. Lecture Notes in Computer Science, vol 8301. Springer, Cham. https://doi.org/10.1007/978-3-319-03542-0_19
Download citation
DOI: https://doi.org/10.1007/978-3-319-03542-0_19
Publisher Name: Springer, Cham
Print ISBN: 978-3-319-03541-3
Online ISBN: 978-3-319-03542-0
eBook Packages: Computer ScienceComputer Science (R0)