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

Hobbits for Haskell: a library for higher-order encodings in functional programming languages

Published: 22 September 2011 Publication History

Abstract

Adequate encodings are a powerful programming tool, which eliminate whole classes of program bugs: they ensure that a program cannot generate ill-formed data, because such data is not part of the representation; and they also ensure that a program is well-defined, meaning that it cannot have different behaviors on different representations of the same piece of data. Unfortunately, it has proven difficult to define adequate encodings of programming languages themselves. Such encodings would be very useful in language processing tools such as interpreters, compilers, model-checking tools, etc., as these systems are often difficult to get correct. The key problem in representing programming languages is in encoding binding constructs; previous approaches have serious limitations in either the operations they allow or the correcness guarantees they make. In this paper, we introduce a new library for Haskell that allows the user to define and use higher-order encodings, a powerful technique for representing bindings. Our library allows straightforward recursion on bindings using pattern-matching, which is not possible in previous approaches. We then demonstrate our library on a medium-sized example, lambda-lifting, showing how our library can be used to make strong correctness guarantees at compile time.

Supplementary Material

JPG File (_talk4.jpg)
MP4 File (_talk4.mp4)

References

[1]
Z. M. Ariola, J. Maraist, M. Odersky, M. Felleisen, and P. Wadler. A call-by-need lambda calculus. In Proceedings of the 22nd ACM SIGPLAN-SIGACT symposium on Principles of programming languages (POPL '95), pages 233--246, 1995.
[2]
R. Atkey, S. Lindley, and J. Yallop. Unembedding domain-specific languages. In Proceedings of the 2nd ACM SIGPLAN symposium on Haskell (Haskell '09), pages 37--48, 2009.
[3]
D. Baelde, A. Gacek, D. Miller, G. Nadathur, and A. Tiu. The Bedwyr system for model checking over syntactic expressions. In 21st Conference on Automated Deduction (CADE '07), pages 391--397, 2007.
[4]
C. Calcagno, E. Moggi, and W. Taha. Closed Types as a Simple Approach to Safe Imperative Multi-stage Programming. In ICALP '00: Proceedings of the 27th International Colloquium on Automata, Languages and Programming, pages 25--36, 2000.
[5]
J. Carette, O. Kiselyov, and C. chieh Shan. Finally tagless, partially evaluated: Tagless staged interpreters for simpler typed languages. J. Funct. Program., 19 (5): 509--543, 2009.
[6]
N. G. de Bruijn. Lambda calculus notation with nameless dummies, a tool for automatic formula manipulation, with application to the church-rosser theorem. Indagationes Mathematicae (Proceedings), 75 (5): 381 -- 392, 1972.
[7]
L. Fegaras and T. Sheard. Revisiting catamorphisms over datatypes with embedded functions (or, programs from outer space). In Proceedings of the 23rd Symposium on Principles of Programming Languages (POPL '96), pages 284--294, 1996.
[8]
M. Felleisen, D. P. Friedman, E. Kohlbecker, and B. Duba. A syntactic theory of sequential control. Theor. Comput. Sci., 52: 205--237, 1987.
[9]
M. Gabbay and A. Pitts. A new approach to abstract syntax with variable binding. Formal Aspects of Computing, 13: 341--363, 2002.
[10]
D. Leijen and E. Meijer. Domain specific embedded compilers. In Proceedings of the 2nd conference on Conference on Domain-Specific Languages (DSL '99), 1999.
[11]
D. Licata and R. Harper. A universe of binding and computation. In Proceedings of the 14th ACM SIGPLAN international conference on Functional programming (ICFP '09), pages 123--134, 2009.
[12]
G. Mainland. Why it's nice to be quoted: quasiquoting for haskell. In Proceedings of the ACM SIGPLAN workshop on Haskell workshop (Haskell '07), pages 73--82, 2007.
[13]
C. McBride and J. McKinna. Functional pearl: i am not a number--i am a free variable. In Haskell '04: Proceedings of the 2004 ACM SIGPLAN workshop on Haskell, 2004.
[14]
E. Meijer and G. Hutton. Bananas in Space: Extending fold and unfold to Exponential Types. In Proceedings of the 7th International Conference on Functional Programming and Computer Architecture, 1995.
[15]
D. Miller. A logic programming language with lambda-abstraction, function variables, and simple unification. J. of Logic and Computation, 1 (4): 497--536, 1991.
[16]
D. Miller and A. Tiu. A proof theory for generic judgments. ACM Trans. Comput. Logic, 6 (4): 749--783, 2005.
[17]
M. Odersky. A functional theory of local names. In Proc. 21st ACM Symposium on Principles of Programming Languages (POPL '94), pages 48--59, 1994.
[18]
S. Peyton-Jones. The Implementation of Functional Programming Languages. Prentice Hall, 1987.
[19]
F. Pfenning and C. Elliott. Higher-order abstract syntax. In ACM SIGPLAN Symposium on Language Design and Implementation, 1988.
[20]
ann(1999)}PfS98F. Pfenning and C. Schürmann. System Description: Twelf -- A Meta-Logical Framework for Deductive Systems. In 16th International Conference on Automated Deduction, 1999.
[21]
B. Pientka. A type-theoretic foundation for programming with higher-order abstract syntax and first-class substitutions. In Proceedings of the 35th ACM SIGPLAN-SIGACT Symposium on Principles of Programming Languages, 2008.
[22]
A. M. Pitts. Nominal system t. In Proceedings of the 37th ACM SIGACT-SIGPLAN Symposium on Principles of Programming Languages (POPL 2010), pages 159--170, 2010.
[23]
ann and Poswolsky(2008)}poswolsky08C. Schürmann and A. Poswolsky. Practical programming with higher-order encodings and dependent types. In 17th European Symposium on Programming (ESOP '08), pages 93--107, 2008.
[24]
C. Schürmann, J. Despeyroux, and F. Pfenning. Primitive recursion for higher-order abstract syntax. Theoretical Computer Science, 266 (1-2): 1--57, 2001.
[25]
T. Sheard and S. P. Jones. Template meta-programming for haskell. SIGPLAN Not., 37: 60--75, 2002.
[26]
T. Sheard, J. Hook, and N. Linger. GADTs + extensible kind system = dependent programming. Technical report, Portland State University, 2005. http://www.cs.pdx.edu/ sheard.
[27]
W. Taha and M. F. Nielsen. Environment classifiers. In POPL '03: Proceedings of the 30th ACM SIGPLAN-SIGACT symposium on Principles of programming languages, pages 26--37, 2003.
[28]
C. Urban. Nominal techniques in isabelle/hol. J. Autom. Reason., 40 (4), 2008.
[29]
G. Washburn and S. Weirich. Boxes go bananas: encoding higher-order abstract syntax with parametric polymorphism. In Proceedings of the 8th International Conference on Functional Programming (ICFP '03), pages 249--262, 2003.
[30]
E. Westbrook. Higher-Order Encodings with Constructors. PhD thesis, Washington University in Saint Louis, 2008.
[31]
E. Westbrook, A. Stump, and E. Austin. The Calculus of Nominal Inductive Constructions. In J. Cheney and A. Felty, editors, Proceedings of the Workshop on Logical Frameworks and Meta-Languages: Theory and Practice (LFMTP) 2009, 2009.

Cited By

View all

Index Terms

  1. Hobbits for Haskell: a library for higher-order encodings in functional programming languages

    Recommendations

    Comments

    Information & Contributors

    Information

    Published In

    cover image ACM Conferences
    Haskell '11: Proceedings of the 4th ACM symposium on Haskell
    September 2011
    136 pages
    ISBN:9781450308601
    DOI:10.1145/2034675
    • cover image ACM SIGPLAN Notices
      ACM SIGPLAN Notices  Volume 46, Issue 12
      Haskell '11
      December 2011
      129 pages
      ISSN:0362-1340
      EISSN:1558-1160
      DOI:10.1145/2096148
      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: 22 September 2011

    Permissions

    Request permissions for this article.

    Check for updates

    Author Tags

    1. haskell
    2. higher-order encodings
    3. name-binding

    Qualifiers

    • Research-article

    Conference

    ICFP '11
    Sponsor:

    Acceptance Rates

    Overall Acceptance Rate 57 of 143 submissions, 40%

    Contributors

    Other Metrics

    Bibliometrics & Citations

    Bibliometrics

    Article Metrics

    • Downloads (Last 12 months)1
    • Downloads (Last 6 weeks)0
    Reflects downloads up to 15 Sep 2024

    Other Metrics

    Citations

    Cited By

    View all

    View Options

    Get Access

    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