Abstract
We propose a novel technique to represent names and binders in Haskell. The dynamic (run-time) representation is based on de Bruijn indices, but it features an interface to write and manipulate variables conviently, using Haskell-level lambdas and variables. The key idea is to use rich types: a subterm with an additional free variable is viewed either as forallν.ν → Term(ɑ + ν) or ϶ν.ν x Term(ν.ν) depending on whether it is constructed or analysed. We demonstrate on a number of examples how this approach permits to express term construction and manipulation in a natural way, while retaining the good properties of representations based on de Bruijn indices.
- T. Altenkirch. A formalization of the strong normalization proof for System F in LEGO. In J. G. M. Bezem, editor, Typed Lambda Calculi and Applications, LNCS 664, pages 13--28, 1993. URL http://www.cs.nott.ac.uk/txa/publ/tlca93.pdf. Google Scholar
Digital Library
- T. Altenkirch and B. Reus. Monadic presentations of lambda terms using generalized inductive types. In Computer Science Logic, volume 1683 of Lecture Notes in Computer Science, pages 453--468. Springer, 1999. URL http://www.cs.nott.ac.uk/txa/publ/csl99.pdf. Google Scholar
Digital Library
- S. Ambler, R. L. Crole, and A. Momigliano. Combining higher order abstract syntax with tactical theorem proving and (co)induction. In Proceedings of the 15th International Conference on Theorem Proving in Higher Order Logics, TPHOLs '02, pages 13--30, London, UK, UK, 2002. Springer-Verlag. ISBN 3-540-44039-9. URL http://dl.acm.org/citation.cfm?id=646529.695204. Google Scholar
Digital Library
- R. Atkey. Syntax for free: representing syntax with binding using parametricity. In International Conference on Typed Lambda Calculi and Applications (TLCA), volume 5608 of Lecture Notes in Computer Science, pages 35--49. Springer, July 2009. Google Scholar
Digital Library
- F. Bellegarde and J. Hook. Substitution: A formal methods case study using monads and transformations. Sci. Comput. Program., 23 (2--3): 287--311, 1994. http://dx.doi.org/10.1016/0167-6423(94)00022-0. Google Scholar
Digital Library
- J.-P. Bernardy and G. Moulin. A computational interpretation of parametricity. In Proceedings of the Symposium on Logic in Computer Science. IEEE Computer Society, 2012. Google Scholar
Digital Library
- J.-P. Bernardy and G. Moulin. Type-theory in color. In Proceeding of the 18th ACM SIGPLAN international conference on Functional Programming, 2013. To appear. Google Scholar
Digital Library
- J.-P. Bernardy, P. Jansson, and R. Paterson. Proofs for free -- parametricity for dependent types. Journal of Functional Programming, 22 (02): 107--152, 2012. 10.1017/S0956796812000056. Google Scholar
Digital Library
- R. Bird and R. Paterson. de Bruijn notation as a nested datatype. Journal of Functional Programming, 9 (1): 77--91, Jan. 1999. URL http://dx.doi.org/10.1017/S0956796899003366. Google Scholar
Digital Library
- V. Capretta and A. P. Felty. Combining de bruijn indices and higher-order abstract syntax in coq. In Proceedings of the 2006 international conference on Types for proofs and programs, TYPES'06, pages 63--77, Berlin, Heidelberg, 2007. Springer-Verlag. ISBN 3-540-74463-0, 978-3-540-74463-4. URL http://dl.acm.org/citation.cfm?id=1789277.1789282. Google Scholar
Digital Library
- A. Chlipala. Parametric higher-order abstract syntax for mechanized semantics. In phProceedings of the 13th ACM SIGPLAN international conference on Functional programming, pages 143--156, New York, NY, USA, 2008. ACM. ISBN 978--1--59593--919--7. http://doi.acm.org/10.1145/1411204.1411226. Google Scholar
Digital Library
- 972)}de_bruijn_lambda_1972N. G. de Bruijn. Lambda calculus notation with nameless dummies. In phIndagationes Mathematicae, volume 34. Elsevier, 1972.Google Scholar
- L. Fegaras and T. Sheard. Revisiting catamorphisms over datatypes with embedded functions (or, programs from outer space). In phProceedings of the 23rd ACM SIGPLAN-SIGACT symposium on Principles of programming languages, pages 284--294, St. Petersburg Beach, Florida, United States, 1996. ACM. ISBN 0--89791--769--3. 10.1145/237721.237792. URL http://portal.acm.org/citation.cfm?id=237792. Google Scholar
Digital Library
- L.-J. Guillemette and S. Monnier. A type-preserving closure conversion in haskell. In phProceedings of the ACM SIGPLAN workshop on Haskell, pages 83--92. ACM, 2007. Google Scholar
Digital Library
- L.-J. Guillemette and S. Monnier. A type-preserving compiler in haskell. In Proceedings of the 13th ACM SIGPLAN international conference on Functional Programming, pages 75--86. ACM, 2008. Google Scholar
Digital Library
- C. Keller and M. Lasson. Parametricity in an impredicative sort. In CSL, pages 381--395, 2012.Google Scholar
- E. Kmett. Bound: Making de Bruijn Succ less, 2012. URL http://hackage.haskell.org/package/bound. Haskell package.Google Scholar
- C. McBride. I am not a number, i am a classy hack, 2010. URL http://www.e-pig.org/epilogue/?p=773. Weblog entry.Google Scholar
- C. McBride and J. McKinna. The view from the left. phJ. Funct. Program., 14: 69--111, January 2004. ISSN 0956--7968. 10.1017/S0956796803004829. URL http://www.cs.ru.nl/ james/RESEARCH/view-final2004.pdf. Google Scholar
Digital Library
- nd Paterson(2007)}mcbride_applicative_2007C. McBride and R. Paterson. Applicative programming with effects. phJournal of Functional Programming, 18 (01): 1--13, 2007. 10.1017/S0956796807006326. URL http://www.journals.cambridge.org/abstract\_S0956796807006326. Google Scholar
Digital Library
- D. A. Miller and A. F. Tiu. A proof theory for generic judgments: An extended abstract. In phProceedings of the 18th Annual IEEE Symposium on Logic in Computer Science, pages 118--127. IEEE Computer Society, June 2003. Google Scholar
Digital Library
- A. Nanevski, F. Pfenning, and B. Pientka. Contextual modal type theory. phACM Trans. Comput. Logic, 9 (3): 23:1--23:49, June 2008. ISSN 1529--3785. 10.1145/1352582.1352591. URL http://doi.acm.org/10.1145/1352582.1352591. Google Scholar
Digital Library
- N. Pouillard and F. Pottier. A unified treatment of syntax with binders. phJournal of Functional Programming, 22 (4--5): 614--704, 2012. Google Scholar
Digital Library
- J. C. Reynolds. Types, abstraction and parametric polymorphism. In phInformation Processing 83, pages 513--523. Elsevier Science, 1983. URL ftp://ftp.cs.cmu.edu/user/jcr/typesabpara.pdf.Google Scholar
- G. Washburn and S. Weirich. Boxes go bananas: encoding higher-order abstract syntax with parametric polymorphism. In phProceedings of the eighth ACM SIGPLAN international conference on Functional programming, pages 249--262, Uppsala, Sweden, 2003. ACM. ISBN 1--58113--756--7. 10.1145/944705.944728. URL http://portal.acm.org/citation.cfm?id=944728. Google Scholar
Digital Library
Index Terms
Names for free: polymorphic views of names and binders
Recommendations
Names for free: polymorphic views of names and binders
Haskell '13: Proceedings of the 2013 ACM SIGPLAN symposium on HaskellWe propose a novel technique to represent names and binders in Haskell. The dynamic (run-time) representation is based on de Bruijn indices, but it features an interface to write and manipulate variables conviently, using Haskell-level lambdas and ...
Free Theorems and Runtime Type Representations
Reynolds's abstraction theorem [John C. Reynolds. Types, abstraction and parametric polymorphism. In Information Processing '83, pages 513-523. North-Holland, 1983. Proceedings of the IFIP 9th World Computer Congress], often referred to as the ...
Graduality and parametricity: together again for the first time
Parametric polymorphism and gradual typing have proven to be a difficult combination, with no language yet produced that satisfies the fundamental theorems of each: parametricity and graduality. Notably, Toro, Labrada, and Tanter (POPL 2019) conjecture ...







Comments