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.
Supplemental Material
- 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 Scholar
Digital Library
- 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 Scholar
Digital Library
- 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 Scholar
Digital Library
- 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 Scholar
Digital Library
- 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 Scholar
Digital Library
- 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 Scholar
Cross Ref
- 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 Scholar
Digital Library
- M. Felleisen, D. P. Friedman, E. Kohlbecker, and B. Duba. A syntactic theory of sequential control. Theor. Comput. Sci., 52: 205--237, 1987. Google Scholar
Digital Library
- M. Gabbay and A. Pitts. A new approach to abstract syntax with variable binding. Formal Aspects of Computing, 13: 341--363, 2002.Google Scholar
Digital Library
- 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 Scholar
Digital Library
- 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 Scholar
Digital Library
- 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 Scholar
Digital Library
- 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 Scholar
Digital Library
- 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 Scholar
Digital Library
- 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 Scholar
Cross Ref
- D. Miller and A. Tiu. A proof theory for generic judgments. ACM Trans. Comput. Logic, 6 (4): 749--783, 2005. Google Scholar
Digital Library
- 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 Scholar
Digital Library
- S. Peyton-Jones. The Implementation of Functional Programming Languages. Prentice Hall, 1987.Google Scholar
- F. Pfenning and C. Elliott. Higher-order abstract syntax. In ACM SIGPLAN Symposium on Language Design and Implementation, 1988. Google Scholar
Digital Library
- 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 Scholar
Digital Library
- 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 Scholar
Digital Library
- 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 Scholar
Digital Library
- 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 Scholar
Digital Library
- 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 Scholar
Digital Library
- T. Sheard and S. P. Jones. Template meta-programming for haskell. SIGPLAN Not., 37: 60--75, 2002. Google Scholar
Digital Library
- 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 Scholar
- 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 Scholar
Digital Library
- C. Urban. Nominal techniques in isabelle/hol. J. Autom. Reason., 40 (4), 2008. Google Scholar
Digital Library
- 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 Scholar
Digital Library
- E. Westbrook. Higher-Order Encodings with Constructors. PhD thesis, Washington University in Saint Louis, 2008. Google Scholar
Digital Library
- 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 Scholar
Digital Library
Index Terms
Hobbits for Haskell: a library for higher-order encodings in functional programming languages
Recommendations
Hobbits for Haskell: a library for higher-order encodings in functional programming languages
Haskell '11: Proceedings of the 4th ACM symposium on HaskellAdequate 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 ...
The Intel labs Haskell research compiler
Haskell '13The Glasgow Haskell Compiler (GHC) is a well supported optimizing compiler for the Haskell programming language, along with its own extensions to the language and libraries. Haskell's lazy semantics imposes a runtime model which is in general difficult ...
The Intel labs Haskell research compiler
Haskell '13: Proceedings of the 2013 ACM SIGPLAN symposium on HaskellThe Glasgow Haskell Compiler (GHC) is a well supported optimizing compiler for the Haskell programming language, along with its own extensions to the language and libraries. Haskell's lazy semantics imposes a runtime model which is in general difficult ...







Comments