skip to main content
10.1145/2500365.2500582acmconferencesArticle/Chapter ViewAbstractPublication PagesicfpConference Proceedingsconference-collections
research-article

Complete and easy bidirectional typechecking for higher-rank polymorphism

Authors Info & Claims
Published:25 September 2013Publication History

ABSTRACT

Bidirectional typechecking, in which terms either synthesize a type or are checked against a known type, has become popular for its scalability (unlike Damas-Milner type inference, bidirectional typing remains decidable even for very expressive type systems), its error reporting, and its relative ease of implementation. Following design principles from proof theory, bidirectional typing can be applied to many type constructs. The principles underlying a bidirectional approach to polymorphism, however, are less obvious. We give a declarative, bidirectional account of higher-rank polymorphism, grounded in proof theory; this calculus enjoys many properties such as eta-reduction and predictability of annotations. We give an algorithm for implementing the declarative system; our algorithm is remarkably simple and well-behaved, despite being both sound and complete.

Skip Supplemental Material Section

Supplemental Material

References

  1. Andreas Abel. Termination checking with types. RAIRO--Theoretical Informatics and Applications, 38 (4): 277--319, 2004. Special Issue: Fixed Points in Computer Science (FICS'03).Google ScholarGoogle ScholarCross RefCross Ref
  2. Andreas Abel, Thierry Coquand, and Peter Dybjer. Verifying a semantic βη-conversion test for Martin-Löf type theory. In Mathematics of Program Construction (MPC'08), volume 5133 of LNCS, pages 29--56, 2008. Google ScholarGoogle ScholarDigital LibraryDigital Library
  3. Jean-Marc Andreoli. Logic programming with focusing proofs in linear logic. J. Logic and Computation, 2 (3): 297--347, 1992.Google ScholarGoogle ScholarCross RefCross Ref
  4. Andrea Asperti, Wilmer Ricciotti, Claudio Sacerdoti Coen, and Enrico Tassi. A bi-directional refinement algorithm for the calculus of (co)inductive constructions. Logical Methods in Computer Science, 8 (1), 2012.Google ScholarGoogle Scholar
  5. Gavin M. Bierman, Erik Meijer, and Mads Torgersen. Lost in translation: formalizing proposed extensions toCsharp. In OOPSLA, 2007. Google ScholarGoogle ScholarDigital LibraryDigital Library
  6. Luca Cardelli. An implementation ofFsub. Research report 97, DEC/Compaq Systems Research Center, February 1993.Google ScholarGoogle Scholar
  7. Iliano Cervesato and Frank Pfenning. A linear spine calculus. J. Logic and Computation, 13 (5): 639--688, 2003.Google ScholarGoogle ScholarCross RefCross Ref
  8. Adam Chlipala, Leaf Petersen, and Robert Harper. Strict bidirectional type checking. In Workshop on Types in Language Design and Impl. (TLDI '05), pages 71--78, 2005. Google ScholarGoogle ScholarDigital LibraryDigital Library
  9. Jacek Chrzaszcz. Polymorphic subtyping without distributivity. In Mathematical Foundations of Computer Science, volume 1450 of LNCS, pages 346--355. Springer, 1998. Google ScholarGoogle ScholarDigital LibraryDigital Library
  10. Thierry Coquand. An algorithm for type-checking dependent types. Science of Computer Programming, 26 (1--3): 167--177, 1996. Google ScholarGoogle ScholarDigital LibraryDigital Library
  11. Luis Damas and Robin Milner. Principal type-schemes for functional programs. In POPL, pages 207--212. ACM, 1982. Google ScholarGoogle ScholarDigital LibraryDigital Library
  12. Rowan Davies and Frank Pfenning. Intersection types and computational effects. In ICFP, pages 198--208, 2000. Google ScholarGoogle ScholarDigital LibraryDigital Library
  13. Jana Dunfield. A Unified System of Type Refinements. PhD thesis, Carnegie Mellon University, 2007. Carnegie Mellon University-CS-07-129.Google ScholarGoogle Scholar
  14. Jana Dunfield. Greedy bidirectional polymorphism. In ML Workshop, pages 15--26, 2009. https://research.cs.queensu.ca/home/jana/papers/poly/. Google ScholarGoogle ScholarDigital LibraryDigital Library
  15. Jana Dunfield and Frank Pfenning. Tridirectional typechecking. In POPL, pages 281--292, January 2004. Google ScholarGoogle ScholarDigital LibraryDigital Library
  16. Adam Gundry, Conor McBride, and James McKinna. Type inference in context. In Mathematically Structured Functional Programming (MSFP), 2010. Google ScholarGoogle ScholarDigital LibraryDigital Library
  17. Didier Le Botlan and Didier Rémy.MLF: raising ML to the power of System F. In ICFP, pages 27--38, 2003. Google ScholarGoogle ScholarDigital LibraryDigital Library
  18. Didier Le Botlan and Didier Rémy. RecastingMLF. Information and Computation, 207: 726--785, 2009. Google ScholarGoogle ScholarDigital LibraryDigital Library
  19. Daan Leijen. Flexible types: robust type inference for first-class polymorphism. In POPL, pages 66--77, 2009. Google ScholarGoogle ScholarDigital LibraryDigital Library
  20. Andres Löh, Conor McBride, and Wouter Swierstra. A tutorial implementation of a dependently typed lambda calculus. Unpublished draft, http://people.cs.uu.nl/andres/LambdaPi/index.html, 2008.Google ScholarGoogle Scholar
  21. William Lovas. Refinement Types for Logical Frameworks. PhD thesis, Carnegie Mellon University, 2010. Carnegie Mellon University-CS-10-138. Google ScholarGoogle ScholarDigital LibraryDigital Library
  22. Dale Miller. Unification under a mixed prefix. J. Symbolic Computation, 14: 321--358, 1992. Google ScholarGoogle ScholarDigital LibraryDigital Library
  23. John C. Mitchell. Polymorphic type inference and containment. Information and Computation, 76: 211--249, 1988. Google ScholarGoogle ScholarDigital LibraryDigital Library
  24. Martin Odersky and Konstantin Laufer. Putting type annotations to work. In POPL, 1996. Google ScholarGoogle ScholarDigital LibraryDigital Library
  25. Martin Odersky, Matthias Zenger, and Christoph Zenger. Colored local type inference. In POPL, pages 41--53, 2001. Google ScholarGoogle ScholarDigital LibraryDigital Library
  26. Simon Peyton Jones and Mark Shields. Lexically scoped type variables. Technical report, Microsoft Research, 2004.Google ScholarGoogle Scholar
  27. Simon Peyton Jones, Dimitrios Vytiniotis, Stephanie Weirich, and Mark Shields. Practical type inference for arbitrary-rank types. J. Functional Programming, 17 (1): 1--82, 2007. Google ScholarGoogle ScholarDigital LibraryDigital Library
  28. Frank Pfenning. Church and Curry: Combining intrinsic and extrinsic typing. In Reasoning in Simple Type Theory: Festschrift in Honor of Peter B. Andrews on His 70th Birthday. College Publications, 2008.Google ScholarGoogle Scholar
  29. Brigitte Pientka. A type-theoretic foundation for programming with higher-order abstract syntax and first-class substitutions. In POPL, pages 371--382, 2008. Google ScholarGoogle ScholarDigital LibraryDigital Library
  30. Benjamin C. Pierce and David N. Turner. Local type inference. ACM Trans. Prog. Lang. Sys., 22: 1--44, 2000. Google ScholarGoogle ScholarDigital LibraryDigital Library
  31. Didier Rémy. Extension of ML type system with a sorted equational theory on types. Research Report 1766, INRIA, 1992.Google ScholarGoogle Scholar
  32. Didier Rémy and Boris Yakobowski. From ML toMLF: graphic type constraints with efficient type inference. In ICFP, pages 63--74, 2008.Google ScholarGoogle ScholarDigital LibraryDigital Library
  33. Robert J. Simmons. Structural focalization. http://arxiv.org/abs/1109.6273v4arXiv: 1109.6273v4 {cs.LO}, 2012.Google ScholarGoogle Scholar
  34. Jerzy Tiuryn and Paweł Urzyczyn. The subtyping problem for second-order types is undecidable. In LICS, 1996. Google ScholarGoogle ScholarDigital LibraryDigital Library
  35. Dimitrios Vytiniotis, Stephanie Weirich, and Simon L. Peyton Jones. Boxy types: inference for higher-rank types and impredicativity. In ICFP, pages 251--262, 2006. Google ScholarGoogle ScholarDigital LibraryDigital Library
  36. Dimitrios Vytiniotis, Stephanie Weirich, and Simon L. Peyton Jones. FPH: First-class polymorphism for Haskell. In ICFP, pages 295--306, 2008. Google ScholarGoogle ScholarDigital LibraryDigital Library
  37. Dimitrios Vytiniotis, Simon Peyton Jones, and Tom Schrijvers. Let should not be generalised. In Workshop on Types in Language Design and Impl. (TLDI '10), pages 39--50, 2010. Google ScholarGoogle ScholarDigital LibraryDigital Library
  38. Kevin Watkins, Iliano Cervesato, Frank Pfenning, and David Walker. A concurrent logical framework: The propositional fragment. In Types for Proofs and Programs, pages 355--377. Springer-Verlag LNCS 3085, 2004.Google ScholarGoogle ScholarCross RefCross Ref
  39. J. B. Wells. Typability and type checking in System F are equivalent and undecidable. Annals of Pure and Applied Logic, 98: 111--156, 1999.Google ScholarGoogle ScholarCross RefCross Ref
  40. Hongwei Xi. Dependent Types in Practical Programming. PhD thesis, Carnegie Mellon University, 1998. Google ScholarGoogle ScholarDigital LibraryDigital Library

Index Terms

  1. Complete and easy bidirectional typechecking for higher-rank polymorphism

    Recommendations

    Comments

    Login options

    Check if you have access through your login credentials or your institution to get full access on this article.

    Sign in
    • Published in

      cover image ACM Conferences
      ICFP '13: Proceedings of the 18th ACM SIGPLAN international conference on Functional programming
      September 2013
      484 pages
      ISBN:9781450323260
      DOI:10.1145/2500365

      Copyright © 2013 ACM

      Permission to make digital or hard copies of all or part of this work for personal or classroom use is granted without fee provided that copies are not made or distributed for profit or commercial advantage and that copies bear this notice and the full citation on the first page. Copyrights for components of this work owned by others than the author(s) must be honored. Abstracting with credit is permitted. To copy otherwise, or republish, to post on servers or to redistribute to lists, requires prior specific permission and/or a fee. Request permissions from [email protected].

      Publisher

      Association for Computing Machinery

      New York, NY, United States

      Publication History

      • Published: 25 September 2013

      Permissions

      Request permissions about this article.

      Request Permissions

      Check for updates

      Qualifiers

      • research-article

      Acceptance Rates

      ICFP '13 Paper Acceptance Rate40of133submissions,30%Overall Acceptance Rate333of1,064submissions,31%

      Upcoming Conference

      ICFP '24

    PDF Format

    View or Download as a PDF file.

    PDF

    eReader

    View online with eReader.

    eReader