Skip to main content

Ambivalent Types for Principal Type Inference with GADTs

  • Conference paper
Programming Languages and Systems (APLAS 2013)

Part of the book series: Lecture Notes in Computer Science ((LNPSE,volume 8301))

Included in the following conference series:

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.

This is a preview of subscription content, log in via an institution to check access.

Access this chapter

Chapter
USD 29.95
Price excludes VAT (USA)
  • Available as PDF
  • Read on any device
  • Instant download
  • Own it forever
eBook
USD 39.99
Price excludes VAT (USA)
  • Available as PDF
  • Read on any device
  • Instant download
  • Own it forever
Softcover Book
USD 54.99
Price excludes VAT (USA)
  • Compact, lightweight edition
  • Dispatched in 3 to 5 business days
  • Free shipping worldwide - see info

Tax calculation will be finalised at checkout

Purchases are for personal use only

Institutional subscriptions

Preview

Unable to display preview. Download preview PDF.

Unable to display preview. Download preview PDF.

References

  1. 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)

    Google Scholar 

  2. Cheney, J., Hinze, R.: First-class phantom types. Computer and Information Science Technical Report TR2003-1901, Cornell University (2003)

    Google Scholar 

  3. 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)

    Chapter  Google Scholar 

  4. Garrigue, J.: Monomophic let in OCaml? (September 2013), Blog article at: http://gallium.inria.fr/blog/monomorphic_let/

  5. Garrigue, J., Rémy, D.: Semi-explicit first-class polymorphism for ML. Information and Computation 155, 134–171 (1999)

    Article  MathSciNet  MATH  Google Scholar 

  6. Garrigue, J., Rémy, D.: Ambivalent types for principal type inference with GADTs (June 2013), Available electronically at http://gallium.inria.fr/~remy/gadts/

  7. Le Botlan, D., Rémy, D.: Recasting MLF. Information and Computation 207(6), 726–785 (2009)

    Article  MathSciNet  MATH  Google Scholar 

  8. 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)

    Google Scholar 

  9. 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)

    Google Scholar 

  10. Milner, R.: A theory of type polymorphism in programming. Journal of Computer and System Sciences 17, 348–375 (1978)

    Article  MathSciNet  MATH  Google Scholar 

  11. 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)

    Google Scholar 

  12. 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)

    Google Scholar 

  13. 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)

    Chapter  Google Scholar 

  14. 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 

  15. 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)

    Article  MathSciNet  MATH  Google Scholar 

  16. 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)

    Chapter  Google Scholar 

Download references

Author information

Authors and Affiliations

Authors

Editor information

Editors and Affiliations

Rights and permissions

Reprints 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)

Publish with us

Policies and ethics