Abstract
Implementors of compilers, program refactorers, theorem provers, proof checkers, and other systems that manipulate syntax know that dealing with name binding is difficult to do well. Operations such as α-equivalence and capture-avoiding substitution seem simple, yet subtle bugs often go undetected. Furthermore, their implementations are tedious, requiring "boilerplate" code that must be updated whenever the object language definition changes.
Many researchers have therefore sought to specify binding syntax declaratively, so that tools can correctly handle the details behind the scenes. This idea has been the inspiration for many new systems (such as Beluga, Delphin, FreshML, FreshOCaml, Cαml, FreshLib, and Ott) but there is still room for improvement in expressivity, simplicity and convenience.
In this paper, we present a new domain-specific language, Unbound, for specifying binding structure. Our language is particularly expressive - it supports multiple atom types, pattern binders, type annotations, recursive binders, and nested binding (necessary for telescopes, a feature found in dependently-typed languages). However, our specification language is also simple, consisting of just five basic combinators. We provide a formal semantics for this language derived from a locally nameless representation and prove that it satisfies a number of desirable properties.
We also present an implementation of our binding specification language as a GHC Haskell library implementing an embedded domain specific language (EDSL). By using Haskell type constructors to represent binding combinators, we implement the EDSL succinctly using datatype-generic programming. Our implementation supports a number of features necessary for practical programming, including flexibility in the treatment of user-defined types, best-effort name preservation (for error messages), and integration with Haskell's monad transformer library.
Supplemental Material
- B. Aydemir and S. Weirich. LNgen: Tool support for locally nameless representations. Technical Report MS-CIS-10-24, Computer and Information Science, University of Pennsylvania, June 2010.Google Scholar
- B. Aydemir, A. Charguéraud, B. C. Pierce, R. Pollack, and S. Weirich. Engineering formal metatheory. In ACM SIGPLAN-SIGACT Symposium on Principles of Programming Languages (POPL), pages 3--15, Jan. 2008. Google Scholar
Digital Library
- C. Calvès. A Haskell nominal toolkit. http://www.inf.kcl.ac.uk/pg/calves/hnt/, Jan. 2009.Google Scholar
- A. Charguéraud. The locally nameless representation. Journal of Automated Reasoning, Special Issue on the POPLmark Challenge, 2011. To appear.Google Scholar
- J. Cheney. Toward a general theory of names: binding and scope. In Proceedings of the 3rd ACM SIGPLAN workshop on Mechanized reasoning about languages with variable binding, MERLIN '05, pages 33--40, New York, NY, USA, 2005\natexlaba. ACM. Google Scholar
Digital Library
- J. Cheney. Scrap your nameplate: (functional pearl). In Proceedings of the tenth ACM SIGPLAN international conference on Functional programming, ICFP '05, pages 180--191, New York, NY, USA, 2005. ACM. ISBN 1-59593-064-7. Google Scholar
Digital Library
- H. Cirstea, C. Kirchner, L. Liquori, and B. Wack. Rewrite strategies in the rewriting calculus. In B. Gramlich and S. Lucas, editors, Proceedings of the Third International Workshop on Reduction Strategies in Rewriting and Programming, Valencia, Spain, June 2003. Electronic Notes in Theoretical Computer Science.Google Scholar
- 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, 34 (5): 381--392, 1972.Google Scholar
Cross Ref
- N. G. de Bruijn. Telescopic mappings in typed lambda calculus. Information and Computation, 91 (2): 189--204, 1991. Google Scholar
Digital Library
- G. Gentzen. The Collected Papers of Gerhard Gentzen. North-Holland, 1969. Edited by Mandred Szabo.Google Scholar
- A. D. Gordon. A mechanisation of name-carrying syntax up to alpha-conversion. In J. Joyce and C. Seger, editors, Higher-order Logic Theorem Proving And Its Applications, Proceedings, 1993, volume 780 of Lecture Notes in Computer Science, pages 414--426. Springer, 1994. Google Scholar
Digital Library
- D. Herman and M. Wand. A theory of hygienic macros. In ESOP '08: Proceedings of the Seventeenth European Symposium On Programming, Mar. 2008. Google Scholar
Digital Library
- S. Kleene. Introduction to Metamathematics. ban Nostrand Rheinhold, Princeton, USA, 1952.Google Scholar
- R. Lämmel and S. Peyton Jones. Scrap your boilerplate with class: extensible generic functions. In Proceedings of the ACM SIGPLAN International Conference on Functional Programming (ICFP 2005), pages 204--215. ACM Press, Sept. 2005. Google Scholar
Digital Library
- C. McBride. Dependently Typed Functional Programs and their Proofs. PhD thesis, University of Edinburgh, 1999. Available from http://www.lfcs.informatics.ed.ac.uk/reports/00/ECS-LFCS-00-419/.Google Scholar
- J. McKinna and R. Pollack. Some lambda calculus and type theory formalized. Journal of Automated Reasoning, 23 (3-4): 373--409, 1999. Google Scholar
Digital Library
- U. Norell. Towards a practical programming language based on dependent type theory. PhD thesis, Department of Computer Science and Engineering, Chalmers University of Technology, SE-412 96 Göteborg, Sweden, September 2007.Google Scholar
- B. Pientka and J. Dunfield. Beluga: A framework for programming and reasoning with deductive systems (system description). In J. Giesl and R. Hähnle, editors, IJCAR, volume 6173 of Lecture Notes in Computer Science, pages 15--21. Springer, 2010. Google Scholar
Digital Library
- A. M. Pitts. Nominal logic, a first order theory of names and binding. Information and Computation, 186: 165--193, 2003. Google Scholar
Digital Library
- A. Poswolsky and C. Schürmann. System description: Delphin - a functional programming language for deductive systems. Electron. Notes Theor. Comput. Sci., 228: 113--120, January 2009. Google Scholar
Digital Library
- F. Pottier. An overview of Cαml. In ACM Workshop on ML, pages 27--52, Mar. 2006. Google Scholar
Digital Library
- F. Pottier. Static name control for FreshML. In In IEEE Symposium on Logic in Computer Science, pages 356--365, 2007. Google Scholar
Digital Library
- N. Pouillard and F. Pottier. A fresh look at programming with names and binders. In Proceedings of the 15th ACM SIGPLAN international conference on Functional programming, ICFP '10, pages 217--228, New York, NY, USA, 2010. ACM. ISBN 978-1-60558-794-3. Google Scholar
Digital Library
- D. Prawitz. Natural Deduction: Proof Theoretical Study. Almquist and Wiksell, Stockholm, 1965.Google Scholar
- A. Rodriguez, J. Jeuring, P. Jansson, A. Gerdes, O. Kiselyov, and B. C. d. S. Oliveira. Comparing libraries for generic programming in Haskell. SIGPLAN Not., 44: 111--122, September 2008. Google Scholar
Digital Library
- S. Sarkar, P. Sewell, and F. Zappa Nardelli. Binding and substitution. www.cl.cam.ac.uk/~pes20/ott/bind-doc.pdf, Oct. 2007.Google Scholar
- P. Sewell, F. Z. Nardelli, S. Owens, G. Peskine, T. Ridge, S. Sarkar, and R. Strniša. Ott: Effective tool support for the working semanticist. Journal of Functional Programming, 20 (1): 71--122, 2010. Google Scholar
Digital Library
- Z. Shao. Implementing typed intermediate language. In Proc. 1998 ACM SIGPLAN International Conference on Functional Programming (ICFP'98), pages 313--323, Baltimore, Maryland, September 1998. Google Scholar
Digital Library
- T. Sheard and S. P. Jones. Template meta-programming for Haskell. SIGPLAN Not., 37: 60--75, December 2002. Google Scholar
Digital Library
- M. Shinwell and A. Pitts. Fresh Objective Caml User Manual. Cambridge University Computer Laboratory, Feb. 2005.Google Scholar
- M. R. Shinwell, A. M. Pitts, and M. J. Gabbay. FreshML: Programming with binders made simple. In Eighth ACM SIGPLAN International Conference on Functional Programming (ICFP 2003), Uppsala, Sweden, pages 263--274. ACM Press, Aug. 2003. Google Scholar
Digital Library
- C. Urban. How to prove false using the variable convention. Appears as a poster at TTVSI, 1 page, mar 2008.Google Scholar
- C. Urban. Nominal techniques in Isabelle/HOL. Journal of Automated Reasoning, 40: 327--356, 2008. ISSN 0168-7433. URL http://dx.doi.org/10.1007/s10817-008-9097-2. Google Scholar
Digital Library
- C. Urban and C. Kaliszyk. General bindings and alpha-equivalence in Nominal Isabelle. In G. Barthe, editor, Programming Languages and Systems, volume 6602 of Lecture Notes in Computer Science, pages 480--500. Springer Berlin / Heidelberg, 2011. URL http://dx.doi.org/10.1007/978-3-642-19718-5_25. Google Scholar
Digital Library
- S. Weirich. RepLib: A library for derivable type classes. In Haskell Workshop, pages 1--12, Portland, OR, USA, Sept. 2006. Google Scholar
Digital Library
- F. Zappa Nardelli. A locally-nameless backend for Ott. moscova.inria.fr/~zappa/projects/ln_ott/, 2009.Google Scholar
Index Terms
Binders unbound
Recommendations
Binders unbound
ICFP '11: Proceedings of the 16th ACM SIGPLAN international conference on Functional programmingImplementors of compilers, program refactorers, theorem provers, proof checkers, and other systems that manipulate syntax know that dealing with name binding is difficult to do well. Operations such as α-equivalence and capture-avoiding substitution ...
Layout-sensitive language extensibility with SugarHaskell
Haskell '12: Proceedings of the 2012 Haskell SymposiumProgrammers need convenient syntax to write elegant and concise programs. Consequently, the Haskell standard provides syntactic sugar for some scenarios (e.g., do notation for monadic code), authors of Haskell compilers provide syntactic sugar for more ...
Layout-sensitive language extensibility with SugarHaskell
Haskell '12Programmers need convenient syntax to write elegant and concise programs. Consequently, the Haskell standard provides syntactic sugar for some scenarios (e.g., do notation for monadic code), authors of Haskell compilers provide syntactic sugar for more ...







Comments