skip to main content
research-article

Hindley-milner elaboration in applicative style: functional pearl

Published:19 August 2014Publication History
Skip Abstract Section

Abstract

Type inference - the problem of determining whether a program is well-typed - is well-understood. In contrast, elaboration - the task of constructing an explicitly-typed representation of the program - seems to have received relatively little attention, even though, in a non-local type inference system, it is non-trivial. We show that the constraint-based presentation of Hindley-Milner type inference can be extended to deal with elaboration, while preserving its elegance. This involves introducing a new notion of "constraint with a value", which forms an applicative functor.

References

  1. Julien Cretin and Didier Rémy. On the power of coercion abstraction. In Principles of Programming Languages (POPL), pages 361--372, 2012. Google ScholarGoogle ScholarDigital LibraryDigital Library
  2. Luis Damas and Robin Milner. Principal type-schemes for functional programs. In Principles of Programming Languages (POPL), pages 207--212, 1982. Google ScholarGoogle ScholarDigital LibraryDigital Library
  3. Jacques Garrigue. Relaxing the value restriction. In Functional and Logic Programming, volume 2998 of Lecture Notes in Computer Science, pages 196--213. Springer, 2004.Google ScholarGoogle ScholarCross RefCross Ref
  4. Jacques Garrigue and Didier Rémy. Extending ML with semi-explicit higher-order polymorphism. Information and Computation, 155(1):134--169, 1999. Google ScholarGoogle ScholarDigital LibraryDigital Library
  5. Jacques Garrigue and Didier Rémy. Ambivalent types for principal type inference with GADTs. In Asian Symposium on Programming Languages and Systems (APLAS), 2013.Google ScholarGoogle ScholarDigital LibraryDigital Library
  6. Adam Gundry. Type Inference, Haskell and Dependent Types. PhD thesis, University of Strathclyde, 2013.Google ScholarGoogle ScholarDigital LibraryDigital Library
  7. Jörgen Gustavsson and Josef Svenningsson. Constraint abstractions. In Symposium on Programs as Data Objects, volume 2053 of Lecture Notes in Computer Science. Springer, 2001. Google ScholarGoogle ScholarDigital LibraryDigital Library
  8. J. Roger Hindley. The principal type-scheme of an object in combinatory logic. Transactions of the American Mathematical Society, 146:29--60, 1969.Google ScholarGoogle Scholar
  9. Gérard Huet. Résolution d'équations dans des langages d'ordre 1, 2, : : :, !. PhD thesis, Université Paris 7, 1976.Google ScholarGoogle Scholar
  10. John Hughes. Generalising monads to arrows. Science of Computer Programming, 37(1-3):67--111, 2000. Google ScholarGoogle ScholarDigital LibraryDigital Library
  11. George Kuan and David MacQueen. Efficient type inference using ranked type variables. In ACM Workshop on ML, pages 3--14, 2007. Google ScholarGoogle ScholarDigital LibraryDigital Library
  12. David McAllester. A logical algorithm for ML type inference. In Rewriting Techniques and Applications (RTA), volume 2706 of Lecture Notes in Computer Science, pages 436--451. Springer, 2003. Google ScholarGoogle ScholarDigital LibraryDigital Library
  13. Conor McBride and Ross Paterson. Applicative programming with effects. Journal of Functional Programming, 18(1):1--13, 2008. Google ScholarGoogle ScholarDigital LibraryDigital Library
  14. Dale Miller. Unification under a mixed prefix. Journal of Symbolic Computation, 14(4):321--358, 1992. Google ScholarGoogle ScholarDigital LibraryDigital Library
  15. Robin Milner. A theory of type polymorphism in programming. Journal of Computer and System Sciences, 17(3):348--375, 1978.Google ScholarGoogle Scholar
  16. Simon Peyton Jones, Dimitrios Vytiniotis, Stephanie Weirich, and Mark Shields. Practical type inference for arbitrary-rank types. Journal of Functional Programming, 17(1):1--82, 2007. Google ScholarGoogle ScholarDigital LibraryDigital Library
  17. François Pottier. Inferno: a library for Hindley-Milner type inference and elaboration, February 2014. http://gallium.inria.fr/~fpottier/inferno/inferno.tar.gz.Google ScholarGoogle Scholar
  18. François Pottier and Didier Rémy. The essence of ML type inference. Draft of an extended version. Unpublished, 2003.Google ScholarGoogle Scholar
  19. François Pottier and Didier Rémy. The essence of ML type inference. In Benjamin C. Pierce, editor, Advanced Topics in Types and Programming Languages, chapter 10, pages 389--489. MIT Press, 2005.Google ScholarGoogle Scholar
  20. Didier Rémy. Extending ML type system with a sorted equational theory. Technical Report 1766, INRIA, 1992.Google ScholarGoogle Scholar
  21. Didier Rémy and Boris Yakobowski. A Church-style intermediate language for MLF. Theoretical Computer Science, 435(1):77--105, 2012. Google ScholarGoogle ScholarDigital LibraryDigital Library
  22. S. Doaitse Swierstra and Luc Duponcheel. Deterministic, errorcorrecting combinator parsers. In Advanced Functional Programming, volume 1129 of Lecture Notes in Computer Science, pages 184--207. Springer, 1996. Google ScholarGoogle ScholarDigital LibraryDigital Library
  23. Robert Endre Tarjan. Efficiency of a good but not linear set union algorithm. Journal of the ACM, 22(2):215--225, 1975. Google ScholarGoogle ScholarDigital LibraryDigital Library
  24. Dimitrios Vytiniotis, Simon L. Peyton Jones, Tom Schrijvers, and Martin Sulzmann. OutsideIn(X): Modular type inference with local assumptions. Journal of Functional Programming, 21(4--5):333--412, 2011. Google ScholarGoogle ScholarDigital LibraryDigital Library
  25. Mitchell Wand. A simple algorithm and proof for type inference. Fundamenta Informaticæ, 10:115--122, 1987.Google ScholarGoogle ScholarCross RefCross Ref

Index Terms

  1. Hindley-milner elaboration in applicative style: functional pearl

      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

      Full Access

      • Published in

        cover image ACM SIGPLAN Notices
        ACM SIGPLAN Notices  Volume 49, Issue 9
        ICFP '14
        September 2014
        361 pages
        ISSN:0362-1340
        EISSN:1558-1160
        DOI:10.1145/2692915
        Issue’s Table of Contents
        • cover image ACM Conferences
          ICFP '14: Proceedings of the 19th ACM SIGPLAN international conference on Functional programming
          August 2014
          390 pages
          ISBN:9781450328739
          DOI:10.1145/2628136

        Copyright © 2014 ACM

        Publisher

        Association for Computing Machinery

        New York, NY, United States

        Publication History

        • Published: 19 August 2014

        Check for updates

        Qualifiers

        • research-article

      PDF Format

      View or Download as a PDF file.

      PDF

      eReader

      View online with eReader.

      eReader
      About Cookies On This Site

      We use cookies to ensure that we give you the best experience on our website.

      Learn more

      Got it!