skip to main content
research-article

Hindley-milner elaboration in applicative style: functional pearl

Published: 19 August 2014 Publication History

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.
[2]
Luis Damas and Robin Milner. Principal type-schemes for functional programs. In Principles of Programming Languages (POPL), pages 207--212, 1982.
[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.
[4]
Jacques Garrigue and Didier Rémy. Extending ML with semi-explicit higher-order polymorphism. Information and Computation, 155(1):134--169, 1999.
[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.
[6]
Adam Gundry. Type Inference, Haskell and Dependent Types. PhD thesis, University of Strathclyde, 2013.
[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.
[8]
J. Roger Hindley. The principal type-scheme of an object in combinatory logic. Transactions of the American Mathematical Society, 146:29--60, 1969.
[9]
Gérard Huet. Résolution d'équations dans des langages d'ordre 1, 2, : : :, !. PhD thesis, Université Paris 7, 1976.
[10]
John Hughes. Generalising monads to arrows. Science of Computer Programming, 37(1-3):67--111, 2000.
[11]
George Kuan and David MacQueen. Efficient type inference using ranked type variables. In ACM Workshop on ML, pages 3--14, 2007.
[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.
[13]
Conor McBride and Ross Paterson. Applicative programming with effects. Journal of Functional Programming, 18(1):1--13, 2008.
[14]
Dale Miller. Unification under a mixed prefix. Journal of Symbolic Computation, 14(4):321--358, 1992.
[15]
Robin Milner. A theory of type polymorphism in programming. Journal of Computer and System Sciences, 17(3):348--375, 1978.
[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.
[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.
[18]
François Pottier and Didier Rémy. The essence of ML type inference. Draft of an extended version. Unpublished, 2003.
[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.
[20]
Didier Rémy. Extending ML type system with a sorted equational theory. Technical Report 1766, INRIA, 1992.
[21]
Didier Rémy and Boris Yakobowski. A Church-style intermediate language for MLF. Theoretical Computer Science, 435(1):77--105, 2012.
[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.
[23]
Robert Endre Tarjan. Efficiency of a good but not linear set union algorithm. Journal of the ACM, 22(2):215--225, 1975.
[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.
[25]
Mitchell Wand. A simple algorithm and proof for type inference. Fundamenta Informaticæ, 10:115--122, 1987.

Recommendations

Comments

Information & Contributors

Information

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
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: 19 August 2014
Published in SIGPLAN Volume 49, Issue 9

Check for updates

Author Tags

  1. constraints
  2. elaboration
  3. polymorphism
  4. type inference

Qualifiers

  • Research-article

Contributors

Other Metrics

Bibliometrics & Citations

Bibliometrics

Article Metrics

  • Downloads (Last 12 months)22
  • Downloads (Last 6 weeks)3
Reflects downloads up to 13 Dec 2024

Other Metrics

Citations

View Options

Login options

View options

PDF

View or Download as a PDF file.

PDF

eReader

View online with eReader.

eReader

Media

Figures

Other

Tables

Share

Share

Share this Publication link

Share on social media