skip to main content
10.1145/1159803.1159811acmconferencesArticle/Chapter ViewAbstractPublication PagesicfpConference Proceedingsconference-collections
Article

Simple unification-based type inference for GADTs

Published: 16 September 2006 Publication History

Abstract

Generalized algebraic data types (GADTs), sometimes known as "guarded recursive data types" or "first-class phantom types", are a simple but powerful generalization of the data types of Haskell and ML. Recent works have given compelling examples of the utility of GADTs, although type inference is known to be difficult. Our contribution is to show how to exploit programmer-supplied type annotations to make the type inference task almost embarrassingly easy. Our main technical innovation is wobbly types, which express in a declarative way the uncertainty caused by the incremental nature of typical type-inference algorithms.

References

[1]
Lennart Augustsson. Cayenne- a language with dependent types. In ACMSIGPLAN International Conference on Functional Programming (ICFP'98), volume 34(1) of ACM SIGPLAN Notices, pages 239--250, Baltimore, 1998. ACM.
[2]
Lennart Augustsson and Kent Petersson. Silly type families. Available as http://www.cs.pdx.edu/~sheard/papers/silly. pdf, 1994.
[3]
Arthur L Baars and S. Doaitse Swierstra. Typing dynamic typing. In ACMSIGPLAN International Conference on Functional Programming (ICFP'02), pages 157--166, Pittsburgh, September 2002. ACM.
[4]
Luca Cardelli. Basic polymorphic typechecking. Polymorphism, 2(1), January 1985.
[5]
James Cheney and Ralf Hinze. First-class phantom types. CUCIS TR2003-1901, Cornell University, 2003.
[6]
Thierry Coquand. Pattern matching with dependent types. In Proceedings of the Workshop on Types for Proofs and Program, pages 66--79, Baastad, Sweden, June 1992.
[7]
Peter Dybjer. Inductive Sets and Families in Martin-Lf's Type Theory. In Grard Huet and Gordon Plotkin, editors, Logical Frameworks. Cambridge University Press, 1991.
[8]
Ralf Hinze. Fun with phantom types. In Jeremey Gibbons and Oege de Moor, editors, The fun of programming, pages 245--262. Palgrave, 2003.
[9]
Barry Jay. The pattern calculus. ACM Transactions on Programming Languages and Systems, 26:911--937, November 2004.
[10]
Lena Magnusson. The implementation of ALF - a proof editor based on Martin-Löf's monomorhic type theory with explicit substitution. PhD thesis, Chalmers University, 1994.
[11]
Conor McBride and James McKinna. The view from the left. Journal of Functional Programming, 14(1):69--111, 2004.
[12]
Erik Meijer and Koen Claessen. The design and implementation of Mondrian. In John Launchbury, editor, Haskell workshop, Amsterdam, Netherlands, 1997.
[13]
Simon Peyton Jones. The Implementation of Functional Programming Languages. Prentice Hall, 1987.
[14]
Simon Peyton Jones, Geoffrey Washburn, and Stephanie Weirich. Wobbly types: type inference for generalised algebraic data types. Microsoft Research, 2004.
[15]
François Pottier and Yann Régis-Gianas. Stratified type inference for generalized algebraic data types. In ACM Symposium on Principles of Programming Languages (POPL'06), Charleston, January 2006. ACM.
[16]
Tim Sheard. Languages of the future. In ACM Conference on Object Orientated Programming Systems, Languages and Applicatioons (OOPSLA'04), 2004.
[17]
Tim Sheard. Putting Curry-Howard to work. In Proceedings of ACM Workshop on Haskell, Tallinn, pages 74--85, Tallinn, Estonia, September 2005. ACM.
[18]
Tim Sheard and Emir Pasalic. Meta-programming with built-in type equality. In Proceedings of the Fourth International Workshop on Logical Frameworks and Meta-languaegs (LFM'04), Cork, July 2004.
[19]
Peter Stuckey and Martin Sulzmann. Type inference for guarded recursive data types. Technical report, National University of Singapore, 2005.
[20]
Martin Sulzmann. A Haskell programmer's guide to Chameleon. Available at http://www.comp.nus.edu.sg/sulzmann/chameleon/download/haskell. html, 2003.
[21]
Martin Sulzmann, JeremyWazny, and Peter Stuckey. A framework for extended algebraic data types. Technical report, National University of Singapore, 2005.
[22]
Dimitrios Vytiniotis, Stephanie Weirich, and Simon Peyton Jones. Boxy type: Inference for higher-rank types and impredicativity. In ACMSIGPLAN International Conference on Functional Programming (ICFP'06), Portland, Oregon, 2006. ACM Press.
[23]
Dimitrios Vytiniotis, Stephanie Weirich, and Simon Peyton Jones. Simple unification-based type inference for GADTs, Technical Appendix. Technical Report MS-CIS-05-22, University of Pennsylvania, April 2006.
[24]
Hongwei Xi. Applied type system. In Proceedings of TYPES 2003, volume 3085 of Lecture Notes in Computer Science, pages 394--408. Springer Verlag, 2004.
[25]
Hongwei Xi, Chiyan Chen, and Gang Chen. Guarded recursive datatype constructors. In Proceedings of the 30th ACM SIGPLANSIGACT Symposium on Principles of Programming Languages, pages 224--235. ACM Press, 2003.
[26]
Hongwei Xi and Frank Pfenning. Dependent types in practical programming. In 26th ACM Symposium on Principles of Programming Languages (POPL'99), pages 214--227, San Antonio, January 1999. ACM.
[27]
Christoph Zenger. Indexed types. Theoretical Computer Science, pages 147--165, 1997.

Cited By

View all
  • (2024)Intensional FunctionsProceedings of the ACM on Programming Languages10.1145/36897148:OOPSLA2(87-112)Online publication date: 8-Oct-2024
  • (2024)The Essence of Generalized Algebraic Data TypesProceedings of the ACM on Programming Languages10.1145/36328668:POPL(695-723)Online publication date: 5-Jan-2024
  • (2023)Generic Programming with Extensible Data Types: Or, Making Ad Hoc Extensible Data Types Less Ad HocProceedings of the ACM on Programming Languages10.1145/36078437:ICFP(356-384)Online publication date: 31-Aug-2023
  • Show More Cited By

Recommendations

Comments

Information & Contributors

Information

Published In

cover image ACM Conferences
ICFP '06: Proceedings of the eleventh ACM SIGPLAN international conference on Functional programming
September 2006
308 pages
ISBN:1595933093
DOI:10.1145/1159803
  • General Chair:
  • John Reppy,
  • Program Chair:
  • Julia Lawall
  • cover image ACM SIGPLAN Notices
    ACM SIGPLAN Notices  Volume 41, Issue 9
    Proceedings of the 2006 ICFP conference
    September 2006
    296 pages
    ISSN:0362-1340
    EISSN:1558-1160
    DOI:10.1145/1160074
    Issue’s Table of Contents
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 ACM 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]

Sponsors

Publisher

Association for Computing Machinery

New York, NY, United States

Publication History

Published: 16 September 2006

Permissions

Request permissions for this article.

Check for updates

Author Tags

  1. generalized algebraic data types
  2. type inference

Qualifiers

  • Article

Conference

ICFP06
Sponsor:

Acceptance Rates

Overall Acceptance Rate 333 of 1,064 submissions, 31%

Upcoming Conference

ICFP '25
ACM SIGPLAN International Conference on Functional Programming
October 12 - 18, 2025
Singapore , Singapore

Contributors

Other Metrics

Bibliometrics & Citations

Bibliometrics

Article Metrics

  • Downloads (Last 12 months)15
  • Downloads (Last 6 weeks)0
Reflects downloads up to 24 Jan 2025

Other Metrics

Citations

Cited By

View all
  • (2024)Intensional FunctionsProceedings of the ACM on Programming Languages10.1145/36897148:OOPSLA2(87-112)Online publication date: 8-Oct-2024
  • (2024)The Essence of Generalized Algebraic Data TypesProceedings of the ACM on Programming Languages10.1145/36328668:POPL(695-723)Online publication date: 5-Jan-2024
  • (2023)Generic Programming with Extensible Data Types: Or, Making Ad Hoc Extensible Data Types Less Ad HocProceedings of the ACM on Programming Languages10.1145/36078437:ICFP(356-384)Online publication date: 31-Aug-2023
  • (2022)A case for DOT: theoretical foundations for objects with pattern matching and GADT-style reasoningProceedings of the ACM on Programming Languages10.1145/35633426:OOPSLA2(1526-1555)Online publication date: 31-Oct-2022
  • (2022)Compositional embeddings of domain-specific languagesProceedings of the ACM on Programming Languages10.1145/35632946:OOPSLA2(175-203)Online publication date: 31-Oct-2022
  • (2022)Reasonable Agda is correct Haskell: writing verified Haskell using agda2hsProceedings of the 15th ACM SIGPLAN International Haskell Symposium10.1145/3546189.3549920(108-122)Online publication date: 6-Sep-2022
  • (2022)Embedded pattern matchingProceedings of the 15th ACM SIGPLAN International Haskell Symposium10.1145/3546189.3549917(123-136)Online publication date: 6-Sep-2022
  • (2022)Staging with class: a specification for typed template HaskellProceedings of the ACM on Programming Languages10.1145/34987236:POPL(1-30)Online publication date: 12-Jan-2022
  • (2021)Implementing path-dependent GADT reasoning for Scala 3Proceedings of the 12th ACM SIGPLAN International Symposium on Scala10.1145/3486610.3486892(22-32)Online publication date: 17-Oct-2021
  • (2021)Haskell⁻¹: automatic function inversion in HaskellProceedings of the 14th ACM SIGPLAN International Symposium on Haskell10.1145/3471874.3472982(41-55)Online publication date: 18-Aug-2021
  • Show More Cited By

View Options

Login options

View options

PDF

View or Download as a PDF file.

PDF

eReader

View online with eReader.

eReader

Figures

Tables

Media

Share

Share

Share this Publication link

Share on social media