skip to main content
research-article

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

Published:22 September 2011Publication History
Skip Abstract Section

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.

Skip Supplemental Material Section

Supplemental Material

_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. Google ScholarGoogle ScholarDigital LibraryDigital Library
  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. Google ScholarGoogle ScholarDigital LibraryDigital Library
  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. Google ScholarGoogle ScholarDigital LibraryDigital Library
  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. Google ScholarGoogle ScholarDigital LibraryDigital Library
  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. Google ScholarGoogle ScholarDigital LibraryDigital Library
  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.Google ScholarGoogle ScholarCross RefCross Ref
  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. Google ScholarGoogle ScholarDigital LibraryDigital Library
  8. M. Felleisen, D. P. Friedman, E. Kohlbecker, and B. Duba. A syntactic theory of sequential control. Theor. Comput. Sci., 52: 205--237, 1987. Google ScholarGoogle ScholarDigital LibraryDigital Library
  9. M. Gabbay and A. Pitts. A new approach to abstract syntax with variable binding. Formal Aspects of Computing, 13: 341--363, 2002.Google ScholarGoogle ScholarDigital LibraryDigital Library
  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. Google ScholarGoogle ScholarDigital LibraryDigital Library
  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. Google ScholarGoogle ScholarDigital LibraryDigital Library
  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. Google ScholarGoogle ScholarDigital LibraryDigital Library
  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. Google ScholarGoogle ScholarDigital LibraryDigital Library
  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. Google ScholarGoogle ScholarDigital LibraryDigital Library
  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.Google ScholarGoogle ScholarCross RefCross Ref
  16. D. Miller and A. Tiu. A proof theory for generic judgments. ACM Trans. Comput. Logic, 6 (4): 749--783, 2005. Google ScholarGoogle ScholarDigital LibraryDigital Library
  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. Google ScholarGoogle ScholarDigital LibraryDigital Library
  18. S. Peyton-Jones. The Implementation of Functional Programming Languages. Prentice Hall, 1987.Google ScholarGoogle Scholar
  19. F. Pfenning and C. Elliott. Higher-order abstract syntax. In ACM SIGPLAN Symposium on Language Design and Implementation, 1988. Google ScholarGoogle ScholarDigital LibraryDigital Library
  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. Google ScholarGoogle ScholarDigital LibraryDigital Library
  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. Google ScholarGoogle ScholarDigital LibraryDigital Library
  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. Google ScholarGoogle ScholarDigital LibraryDigital Library
  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. Google ScholarGoogle ScholarDigital LibraryDigital Library
  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. Google ScholarGoogle ScholarDigital LibraryDigital Library
  25. T. Sheard and S. P. Jones. Template meta-programming for haskell. SIGPLAN Not., 37: 60--75, 2002. Google ScholarGoogle ScholarDigital LibraryDigital Library
  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.Google ScholarGoogle Scholar
  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. Google ScholarGoogle ScholarDigital LibraryDigital Library
  28. C. Urban. Nominal techniques in isabelle/hol. J. Autom. Reason., 40 (4), 2008. Google ScholarGoogle ScholarDigital LibraryDigital Library
  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. Google ScholarGoogle ScholarDigital LibraryDigital Library
  30. E. Westbrook. Higher-Order Encodings with Constructors. PhD thesis, Washington University in Saint Louis, 2008. Google ScholarGoogle ScholarDigital LibraryDigital Library
  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. Google ScholarGoogle ScholarDigital LibraryDigital Library

Index Terms

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

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

      Copyright © 2011 ACM

      Publisher

      Association for Computing Machinery

      New York, NY, United States

      Publication History

      • Published: 22 September 2011

      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!