Abstract
Self-interpreters can be roughly divided into two sorts: self-recognisers that recover the input program from a canonical representation, and self-enactors that execute the input program. Major progress for statically-typed languages was achieved in 2009 by Rendel, Ostermann, and Hofer who presented the first typed self-recogniser that allows representations of different terms to have different types. A key feature of their type system is a type:type rule that renders the kind system of their language inconsistent.
In this paper we present the first statically-typed language that not only allows representations of different terms to have different types, and supports a self-recogniser, but also supports a self-enactor. Our language is a factorisation calculus in the style of Jay and Given-Wilson, a combinatory calculus with a factorisation operator that is powerful enough to support the pattern-matching functions necessary for a self-interpreter. This allows us to avoid a type:type rule. Indeed, the types of System F are sufficient. We have implemented our approach and our experiments support the theory.
Supplemental Material
- Harold Abelson, Gerald Jay Sussman, and Julie Sussman. Structure and Interpretation of Computer Programs. MIT Press, 1985. Google Scholar
Digital Library
- Henk Barendregt. Self-interpretations in lambda calculus. J. Funct. Program, 1(2):229--233, 1991.Google Scholar
Cross Ref
- HP Barendregt. Handbook of Logic in Computer Science (vol. 2): Background: Computational Structures: Abramski,S (ed), chapter Lambda Calculi with Types. Oxford University Press, Inc., New York, NY, 1993. Google Scholar
Digital Library
- Michel Bel. A recursion theoretic self interpreter for the lambda-calculus. http://www.belxs.com/michel/#selfint.Google Scholar
- Alessandro Berarducci and Corrado Böhm. A self-interpreter of lambda calculus having a normal form. In CSL, pages 85--99, 1992. Google Scholar
Digital Library
- Mathieu Boespflug. From self-interpreters to normalization by evaluation. In Olivier Danvy, editor, Proceedings of Workshop on Normalization by Evaluation, 2009.Google Scholar
- bondi programming language. www-staff.it.uts.edu.au/~cbj/bondi.Google Scholar
- Reg Braithwaite. The significance of the meta-circular interpreter. http://weblog.raganwald.com/2006/11/significance-of-meta-circular_22.html, November 2006.Google Scholar
- Jacques Carette, Oleg Kiselyov, and Chung chieh Shan. Finally tagless, partially evaluated: Tagless staged interpreters for simpler typed languages. Journal of Functional Programming, 19(5):509--543, 2009. Google Scholar
Digital Library
- Olivier Danvy and Pablo E. Martínez López. Tagging, encoding, and Jones optimality. In Proceedings of ESOP'03, European Symposium on Programming, pages 335--347. Springer-Verlag (LNCS), 2003. Google Scholar
Digital Library
- Sir Arthur Conan Doyle. The Sign of the Four. Lippincott's Monthly Magazine, February 1890.Google Scholar
- Brendan Eich. Narcissus. http://mxr.mozilla.org/mozilla/source/js/narcissus/jsexec.js, 2010.Google Scholar
- J-Y. Girard, Y. Lafont, and P. Taylor. Proofs and Types. Tracts in Theoretical Computer Science. Cambridge University Press, 1989. Google Scholar
Digital Library
- Masami Hagiya. Meta-circular interpreter for a strongly typed language. Journal of Symbolic Computation, 8(6):651--680, 1989. Google Scholar
Digital Library
- R. Hindley and J. P. Seldin. Introduction to Combinators and Lambda-calculus. Cambridge University Press, 1986. Google Scholar
Digital Library
- Barry Jay. Pattern Calculus: Computing with Functions and Structures. Springer, 2009. Google Scholar
Digital Library
- Barry Jay and Thomas Given-Wilson. A combinatory account of internal structure. Journal of Symbolic Logic, 2011. To appear. http://www-staff.it.uts.edu.au/~cbj/Publications/factorisation.pdf.Google Scholar
Cross Ref
- Barry Jay and Delia Kesner. First-class patterns. Journal of Functional Programming, 19(2):191--225, 2009. Google Scholar
Digital Library
- C. B. Jay. The pattern calculus. ACM Transactions on Programming Languages and Systems (TOPLAS), 26(6):911--937, November 2004. Google Scholar
Digital Library
- S.C. Kleene. Introduction to Methamathematics. van Nostrand, 1952.Google Scholar
- Stephen C. Kleene. λ-definability and recursiveness. Duke Math. J., pages 340--353, 1936.Google Scholar
Cross Ref
- Konstantin Läufer and Martin Odersky. Self-interpretation and reflection in a statically typed language. In Proceedings of OOPSLA Workshop on Reflection and Metalevel Architectures. ACM, October 1993.Google Scholar
- Oleg Mazonka and Daniel B. Cristofani. A very short self-interpreter. http://arxiv.org/html/cs/0311032v1, November 2003.Google Scholar
- J. C. Mitchell. Polymorphic type inference and containment. Information and Computation, 1985. Google Scholar
Digital Library
- Torben Æ. Mogensen. Efficient self-interpretations in lambda calculus. Journal of Functional Programming, 2(3):345--363, 1992. See also DIKU Report D-128, Sep 2, 1994.Google Scholar
Cross Ref
- Torben Æ. Mogensen. Linear-time self-interpretation of the pure lambda calculus. Higher-Order and Symbolic Computation, 13(3):217--237, 2000. Google Scholar
Digital Library
- Greg Morrisett, David Walker, Karl Crary, and Neal Glew. From System F to typed assembly language. In Proceedings of POPL'98, 25th Annual SIGPLAN-SIGACT Symposium on Principles of Programming Languages, pages 85--97, 1998. Google Scholar
Digital Library
- Matthew Naylor. Evaluating Haskell in Haskell. The Monad.Reader, 10:25--33, 2008.Google Scholar
- Frank Pfenning and Peter Lee. Metacircularity in the polymorphic λ-calculus. Theoretical Computer Science, 89(1):137--159, 1991. Google Scholar
Digital Library
- Didier Rémy. Simple, partial type-inference for System F based on type-containment. In Proceedings of the tenth ACM SIGPLAN international conference on Functional programming, ICFP '05, pages 130--143, New York, NY, USA, 2005. ACM. Google Scholar
Digital Library
- Tillmann Rendel, Klaus Ostermann, and Christian Hofer. Typed self-representation. In Proceedings of PLDI'09, ACM SIGPLAN Conference on Programming Language Design and Implementation, pages 293--303, June 2009. Google Scholar
Digital Library
- John C. Reynolds. Definitional interpreters for higher-order programming languages. In Proceedings of 25th ACM National Conference, pages 717--740. ACM Press, 1972. The paper later appeared in Higher-Order and Symbolic Computation, 11, 363--397 (1998). Google Scholar
Digital Library
- Armin Rigo and Samuele Pedroni. Pypy's approach to virtual machine construction. In OOPSLA Companion, pages 044--953, 2006. Google Scholar
Digital Library
- Andreas Rossberg. HaMLet. http://www.mpi-sws.org/rossberg/hamlet, 2010.Google Scholar
- Fangmin Song, Yongsen Xu, and Yuechen Qian. The self-reduction in lambda calculus. Theoretical Computer Science, 235(1):171--181, March 2000. Google Scholar
Digital Library
- Walid Taha, Henning Makholm, and John Hughes. Tag elimination and Jones-optimality. In Proceedings of PADO'01, Programs as Data Objects, Second Symposium, pages 257--275, 2001. Google Scholar
Digital Library
- Terese. Term Rewriting Systems, volume 53 of Tracts in Theoretical Computer Science. Cambridge University Press, 2003.Google Scholar
- John Tromp. Binary lambda calculus and combinatory logic. In Kolmogorov Complexity and Applications, 2006. A Revised Version is available at http://homepages.cwi.nl/tromp/cl/LC.pdf.Google Scholar
- J. B. Wells. Typability and type checking in the second-order λ-calculus are equivalent and undecidable. In Proceedings of LICS'94, Ninth Annual IEEE Symposium on Logic in Computer Science, 1994.Google Scholar
Cross Ref
- Wikipedia. Pypy. http://en.wikipedia.org/wiki/PyPy, 2010.Google Scholar
- Wikipedia. Rubinius. http://en.wikipedia.org/wiki/Rubinius, 2010.Google Scholar
- Tetsuo Yokoyama and Robert Glück. A reversible programming language and its invertible self-interpreter. In Proceedings of PEPM'07, ACM Symposium on Partial Evaluation and Semantics-Based Program Manipulation, 2007. Google Scholar
Digital Library
Index Terms
Typed self-interpretation by pattern matching
Recommendations
Typed self-interpretation by pattern matching
ICFP '11: Proceedings of the 16th ACM SIGPLAN international conference on Functional programmingSelf-interpreters can be roughly divided into two sorts: self-recognisers that recover the input program from a canonical representation, and self-enactors that execute the input program. Major progress for statically-typed languages was achieved in ...
Live Pattern Matching with Typed Holes
Several modern programming systems, including GHC Haskell, Agda, Idris, and Hazel, support typed holes. Assigning static and, to varying degree, dynamic meaning to programs with holes allows program editors and other tools to offer meaningful feedback ...
Embedding Non-linear Pattern Matching with Backtracking for Non-free Data Types into Haskell
AbstractPattern matching is an important language construct for data abstraction. Many pattern-match extensions have been developed for extending the range of data types to which pattern matching is applicable. Among them, the pattern-match system ...







Comments