Skip to main content Accessibility help
×
Home

Finally tagless, partially evaluated: Tagless staged interpreters for simpler typed languages

  • JACQUES CARETTE (a1), OLEG KISELYOV (a2) and CHUNG-CHIEH SHAN (a3)

Abstract

We have built the first family of tagless interpretations for a higher-order typed object language in a typed metalanguage (Haskell or ML) that require no dependent types, generalized algebraic data types, or postprocessing to eliminate tags. The statically type-preserving interpretations include an evaluator, a compiler (or staged evaluator), a partial evaluator, and call-by-name and call-by-value continuation-passing style (CPS) transformers. Our principal technique is to encode de Bruijn or higher-order abstract syntax using combinator functions rather than data constructors. In other words, we represent object terms not in an initial algebra but using the coalgebraic structure of the λ-calculus. Our representation also simulates inductive maps from types to types, which are required for typed partial evaluation and CPS transformations. Our encoding of an object term abstracts uniformly over the family of ways to interpret it, yet statically assures that the interpreters never get stuck. This family of interpreters thus demonstrates again that it is useful to abstract over higher-kinded types.

Copyright

References

Hide All
Ariola, Zena M., Felleisen, Matthias, Maraist, John, Odersky, Martin & Wadler, Philip (1995) The call-by-need lambda calculus. In POPL 95: Conference Record of the Annual ACM Symposium on Principles of Programming Languages. New York: ACM, pp. 233246.
Asai, Kenichi (2001) Binding-time analysis for both static and dynamic expressions. New Generation Comput. 20 (1), 2752.
Baars, Arthur I. & Swierstra, S. Doaitse (2002) Typing dynamic typing. In ICFP 2002; Proceedings of the ACM International Conference on Functional Programming. New York: ACM, pp. 157166.
Balat, Vincent, Di Cosmo, Roberto & Fiore, Marcelo P. (2004) Extensional normalisation and type-directed partial evaluation for typed lambda calculus with sums. In POPL 04: Conference Record of the Annual ACM Symposium on Principles of Programming Languages. New York: ACM, pp. 6476.
Bawden, Alan (1999). Quasiquotation in Lisp. In Proceedings of the 1999 ACM SIGPLAN Workshop on Partial Evaluation and Semantics-Based Program Manipulation, Danvy, Olivier (ed). pp. 412. Note NS-99-1, University of Aarhus: BRICS.
Benton, Nick. P. (2005) Embedded interpreters. J. Func. Prog. 15 (4), 503542.
Berarducci, Alessandro (1996) Infinite lambda-calculus and non-sensible models. In Logic and Algebra, Ursini, A. & Aglianò, P. (eds), vol. 180. Marcel Dekker, pp. 339378.
Birkedal, Lars & Welinder, Morten (1993) Partial evaluation of Standard ML. Master's Thesis, DIKU, University of Copenhagen, Denmark. DIKU Research Report 93/22.
Bjesse, Per, Claessen, Koen, Sheeran, Mary & Singh, Satnam (1998) Lava: Hardware design in Haskell. In ICFP Proceedings of the ACM International Conference on Functional Programming, vol. 34(1) of ACM SIGPLAN Notices. New York: ACM, 1998: pp. 174184.
Böhm, Corrado & Berarducci, Alessandro (1985) Automatic synthesis of typed Λ-programs on term algebras. Theor. Comp. Sci. 39, 135154.
Bondorf, Anders & Danvy, Olivier (1991) Automatic autoprojection of recursive equations with global variables and abstract data types. Sci. Comp. Prog. 16 (2), 151195.
Calcagno, Cristiano, Moggi, Eugenio & Taha, Walid (2004) ML-like inference for classifiers. In Programming Languages and Systems: Proceedings of ESOP 2004, 13th European Symposium on Programming, Schmidt, David A. (ed.). Lecture Notes in Computer Science 2986, Berlin: Springer-Verlag, pp. 7993.
Carette, Jacques & Kiselyov, Oleg (2005) Multi-stage programming with Functors and Monads: Eliminating abstraction overhead from generic code. In Generative Programming and Component Engineering GPCE, Estonia, Lecture Notes in Computer Science, pp. 256274.
Carette, Jacques, Kiselyov, Oleg & Shan, Chung-chieh (2007) Finally tagless, partially evaluated. In APLAS, Shao, Zhong (ed.), vol. 4807. Lecture Notes in Computer Science. Springer, pp. 222238.
Chen, Chiyan & Xi, Hongwei (2003) Implementing typeful program transformations. In Proceedings of the 2003 ACM SIGPLAN Workshop on Partial Evaluation and Semantics-Based Program Manipulation. New York: ACM, pp. 2028.
Consel, Charles (1993) A tour of Schism: A partial evaluation system for higher-order applicative languages. In Proceedings of the 1993 ACM SIGPLAN Workshop on Partial Evaluation and Semantics-Based Program Manipulation. New York: ACM, pp. 145154.
Danvy, Olivier (1996) Type-directed partial evaluation. In POPL 96: Conference record of the Annual ACM Symposium on Principles of Programming Languages. New York: ACM, pp. 242257.
Danvy, Olivier (1998) A simple solution to type specialization. In Proceedings of ICALP 98: 25th International Colloquium on Automata, Languages, and Programming, Larsen, Kim Guldstrand, Skyum, Sven & Winskel, Glynn (ed.). Lecture Notes in Computer Science, vol. 1443. Berlin: Springer-Verlag, pp. 908917.
Danvy, Olivier & Filinski, Andrzej (1992) Representing control: A study of the CPS transformation. Math. Struct. Comp. Sci. 2 (4), 361391.
Danvy, Olivier & López, Pablo E. Martínez (2003) Tagging, encoding, and Jones optimality. In Programming Languages and Systems: Proceedings of ESOP 2003, 12th European Symposium on Programming, Degano, Pierpaolo (ed.). Lecture Notes in Computer Science, vol. 2618, Berlin: Springer-Verlag, pp. 335347.
Davies, Rowan & Pfenning, Frank (2001) A modal analysis of staged computation. J. ACM 48 (3), 555604.
Filinski, Andrzej (1994) Representing monads. In POPL ’94: Conference Record of the Annual ACM Symposium on Principles of Programming Languages. New York: ACM, pp. 446457.
Fiore, Marcelo P. (2002) Semantic analysis of normalisation by evaluation for typed lambda calculus. In Proceedings of the 4th International Conference on Principles and Practice of Declarative Programming. New York: ACM, pp 2637.
Fogarty, Seth, Pasalic, Emir, Siek, Jeremy & Taha, Walid (2007) Concoqtion: Indexed types now! In Proceedings of the 2007 ACM SIGPLAN Workshop on Partial Evaluation and Semantics-Based Program Manipulation. New York: ACM.
Futamura, Yoshihiko (1971) Partial evaluation of computation process–An approach to a compiler-compiler. Sys. Comp. Controls 2 (5), 4550. Reprinted with revisions in Higher-Order Symbol. Comput. 12(4), 381–391.
Gomard, Carsten K. & Jones, Neil D. (1991) A partial evaluator for the untyped lambda calculus. J. Funct. Prog. 1 (1), 2169.
Guillemette, Louis-Julien & Monnier, Stefan (2006) Statically verified type-preserving code transformations in Haskell. In PLPV 2006: Programming Languages Meets Program Verification. Stump, Aaron and Xi, Hongwei. (eds.) Electronic Notes in Theoretical Computer Science, vol. 174(7). Amsterdam: Elsevier Science, pp. 4053.
Harper, Robert & Morrisett, J. Gregory (1995) Compiling polymorphism using intensional type analysis. In POPL 95: Conference Record of the Annual ACM Symposium on Principles of Programming Languages. New York: ACM, pp. 130141.
Hindley, J. Roger (1969) The principal type-scheme of an object in combinatory logic. Trans. Am. Math. Soc. 146, 2960.
Hinze, Ralf, Jeuring, Johan & Löh, Andres (2004) Type-indexed data types. Sci. Comp. Prog. 51 (1–2), 117151.
Hofer, Christian, Ostermann, Klaus, Rendel, Tillmann & Moors, Adriaan (2008) Polymorphic embedding of DSLs. In ACM Conference on Generative Programming and Component Engineering GPCE, Nashville, ACM.
Holst, Carsten Kehler (1988) Language triplets: The AMIX approach. In Partial Evaluation and Mixed Computation. Bjørner, Dines, Ershov, Andrei P. and Jones, Neil D. (eds), Amsterdam: North-Holland, pp. 167186.
Honsell, Furio & Lenisa, Marina (1995) Final semantics for untyped lambda-calculus. In TLCA 95: Proceedings of the 2nd International Conference on Typed Lambda Calculi and Applications, Dezani-Ciancaglini, Mariangiola and Plotkin, Gordon D. (eds), Lecture Notes in Computer Science, vol. 902, Berlin: Springer-Verlag, pp. 249265.
Honsell, Furio & Lenisa, Marina (1999) Coinductive characterizations of applicative structures. Math. Struct. Comp. Sci. 9 (4), 403435.
Hudak, Paul (1996) Building domain-specific embedded languages. ACM Comput. Surv. 28 (4es), 196.
Hughes, John (1998) Type specialization. ACM Comput. Surv. 30 (3es:14), 16.
Jacobs, Bart (2007) Introduction to coalgebra: Towards mathematics of states and observations. http://www.cs.ru.nl/B.Jacobs/CLG/JacobsCoalgebraIntro.pdf. Draft book.
Jones, Neil D., Gomard, Carsten K. & Sestoft, Peter (1993) Partial Evaluation and Automatic Program Generation. Englewood Cliffs, NJ: Prentice-Hall.
Jones, Neil D. & Nielson, Flemming (1994) Abstract interpretation: A semantics-based tool for program analysis. In Handbook of Logic in Computer Science. Oxford University Press, pp. 527629.
Jones, Neil D., Sestoft, Peter & Søndergaard, Harald (1989) Mix: A self-applicable partial evaluator for experiments in compiler generation. Lisp Symbol. Comput. 2 (1), 950.
Landin, Peter J. (1966) The next 700 programming languages. Commun. ACM 9 (3), 157166.
Läufer, Konstantin & Odersky, Martin (1993) Self-interpretation and reflection in a statically typed language. In Proceedings of the 4th Annual OOPSLA/ECOOP Workshop on Object-Oriented Reflection and Metalevel Architectures, Washington, ACM.
Makholm, Henning (2000) On Jones-optimal specialization for strongly typed languages. In Semantics, Applications and Implementation of Program Generation, Taha, Walid (ed). Lecture Notes in Computer Science, vol. 1924 Montreal, Canada: Springer-Verlag, pp. 129148.
Miller, Dale & Nadathur, Gopalan (1987) A logic programming approach to manipulating formulas and programs. In IEEE Symposium on Logic Programming, Haridi, Seif (ed). Washington, DC: IEEE Comp. Society Press, pp. 379388.
Milner, Robin (1978) A theory of type polymorphism in programming. J. Comput. Syst. Sci. 17, 348375.
Mogensen, Torben Æ. (1992) Efficient self-interpretation in lambda calculus. J. Funct. Prog. 2 (3), 345363.
Mogensen, Torben Æ. (1995) Self-applicable online partial evaluation of the pure lambda calculus. In Proceedings of the 1995 ACM SIGPLAN Workshop on Partial Evaluation and Semantics-Based Program manipulation. New York: ACM Press, pp. 3944.
Moggi, Eugenio (1991) Notions of computation and monads. Info. Comput. 93 (1), 5592.
Moors, Adriaan, Piessens, Frank & Odersky, Martin (2008) Generics of a higher kind. In OOPSLA ’08: Proceedings of the 23rd ACM Sigplan Conference on Object Oriented Programming Systems Languages and Applications. New York, NY, ACM, pp. 423438.
Nanevski, Aleksandar (2002) Meta-programming with names and necessity. In ICFP 2002. Proceedings of the ACM International Conference on Functional Programming. New York: ACM, pp. 206217.
Nanevski, Aleksandar & Pfenning, Frank (2005) Staged computation with names and necessity. J. Funct. Prog. 15 (6), 893939.
Nanevski, Aleksandar, Pfenning, Frank & Pientka, Brigitte (to appear). Contextual modal type theory. Trans. Comput. Logic 9 (3), 149.
Nielson, Flemming (1988) Strictness analysis and denotational abstract interpretation. Info. Comput. 76 (1), 2992.
Nielson, Flemming & Nielson, Hanne Riis (1988) Automatic binding time analysis for a typed Λ-calculus. In POPL 88: Conference Record of the Annual ACM Symposium on Principles of Programming Languages. New York: ACM, pp. 98106.
Nielson, Flemming & Nielson, Hanne Riis (1992) Two-Level Functional Languages. Cambridge University Press.
Oliveira, Bruno César dos Santos & Gibbons, Jeremy (2005) TypeCase: A design pattern for type-indexed functions. In Proceedings of the 2005 Haskell Workshop. New York: ACM, pp. 98109.
Pašalić, Emir, Taha, Walid & Sheard, Tim (2002) Tagless staged interpreters for typed languages. In ICFP 2002. Proceedings of the ACM International Conference on Functional Programming. New York: ACM, pp. 157166.
Peyton Jones, Simon L., Vytiniotis, Dimitrios, Weirich, Stephanie & Washburn, Geoffrey (2006) Simple unification-based type inference for GADTs. In ICFP ’06: Proceedings of the ACM International Conference on Functional Programming, New York: ACM, pp. 5061.
Pfenning, Frank & Elliott, Conal (1988) Higher-order abstract syntax. In PLDI 88: Proceedings of the ACM Conference on Programming Language Design and Implementation. ACM SIGPLAN Notices, vol. 23(7). New York: ACM, pp. 199208.
Pfenning, Frank & Lee, Peter (1991) Metacircularity in the polymorphic λ-calculus. Theor. Comp. Sci. 89 (1), 137159.
Plotkin, Gordon D. (1975) Call-by-name, call-by-value and the λ-calculus. Theor. Comp. Sci. 1 (2), 125159.
Plotkin, Gordon D. (1977) LCF considered as a programming language. Theor. Comp. Sci. 5, 223255.
Ramsey, Norman (2005) ML module mania: A type-safe, separately compiled, extensible interpreter. In Proceedings of the 2005 Workshop on ML. Electronic Notes in Theoretical Computer Science. Amsterdam: Elsevier Science.
Reynolds, John C. (1972) Definitional interpreters for higher-order programming languages. In Proceedings of the ACM National Conference, vol. 2. New York: ACM, pp. 717740. Reprinted with a foreword in Higher-Order Symbol. Comput. 11(4), 363–397.
Reynolds, John C. (1974) On the relation between direct and continuation semantics. In Automata, Languages and Programming: 2nd Colloquium. Loeckx, Jacques (ed). Lecture Notes in Computer Science, vol. 14, Berlin: Springer-Verlag, pp. 141156.
Reynolds, John C. (1975) User-defined types and procedural data structures as complementary approaches to data abstraction. In New Directions in Algorithmic Languages 1975. Schuman, Stephen A. (ed). IFIP Working Group 2.1 on Algol, Rocquencourt, France: INRIA, pp. 157168.
Rhiger, Morten (2001) Higher-Order program generation. Ph.D. Thesis, BRICS Ph.D. School. Department of Computer Science, University of Aarhus, Denmark.
Shao, Zhong (1998) Typed cross-module compilation. In ICFP 1998: Proceedings of the ACM International Conference on Functional Programming, vol. 34(1) of ACM SIGPLAN Notices. New York: ACM, pp. 141152.
Shao, Zhong, Trifonov, Valery, Saha, Bratin & Papaspyrou, Nikolaos S. (2005) A type system for certified binaries. ACM Trans. Prog. Lang. Sys. 27 (1): 145.
Sheard, Tim & PeytonJones, Simon L. Jones, Simon L. (2002) Template meta-programming for Haskell. In Proceedings of the 2002 Haskell workshop, Chakravarty, Manuel M. T. (ed). New York: ACM, pp. 116.
Sperber, Michael (1996) Self-applicable online partial evaluation. In Partial Evaluation, Danvy, Olivier, Glück, Robert, and Thiemann, Peter (eds). Lecture Notes in Computer Science, vol. 1110. Schloß Dagstuhl, Germany: Springer-Verlag, pp. 465480.
Sperber, Michael & Thiemann, Peter (1997) Two for the price of one: Composing partial evaluation and compilation. In PLDI 97: Proceedings of the ACM Conference on Programming Language Design and Implementation. New York: ACM, pp. 215225.
Sumii, Eijiro & Kobayashi, Naoki (2001) A hybrid approach to online and offline partial evaluation. Higher-Order Symbol. Comput. 14 (2–3), 101142.
Taha, Walid (1999) A sound reduction semantics for untyped CBN multi-stage computation. or, the theory of MetaML is non-trival (extended abstract). In Proceedings of the 2000 ACM SIGPLAN Workshop on Partial Evaluation and Semantics-Based Program Manipulation, Lawall, Julia L. (ed). ACM SIGPLAN Notices, vol. 34(11) New York: ACM Press, pp. 3443.
Taha, Walid, Makholm, Henning & Hughes, John (2001) Tag elimination and Jones-optimality. In Proceedings of PADO 2001: 2nd Symposium on Programs as Data Objects, Danvy, Olivier and Filinski, Andrzej (eds). Lecture Notes in Computer Science, vol. 2053, Berlin: Springer-Verlag, pp. 257275.
Taha, Walid & Nielsen, Michael Florentin (2003) Environment classifiers. In POPL 03: Conference Record of the Annual ACM Symposium on Principles of Programming Languages. New York: ACM, pp. 2637.
Thiemann, Peter (1999) Combinators for program generation. J. Funct. Prog 9 (5), 483525.
Thiemann, Peter & Sperber, Michael (1997) Program generation with class. In Proceedings Informatik 97, Jarke, M., Pasedach, K., and Pohl, K. (eds). Reihe Informatik aktuell, Aachen: Springer-Verlag, pp. 582592.
Washburn, Geoffrey Alan & Weirich, Stephanie (2008) Boxes go bananas: Encoding higher-order abstract syntax with parametric polymorphism. J. Funct. Prog. 18 (1), 87140.
Xi, Hongwei, Chen, Chiyan & Chen, Gang (2003) Guarded recursive datatype constructors. In POPL 03: Conference Record of the Annual ACM Symposium on Principles of Programming Languages. New York: ACM, pp. 224235.
Yang, Zhe (2004) Encoding types in ML-like languages. Theor. Comp. Sci. 315 (1), 151190.

Metrics

Altmetric attention score

Full text views

Total number of HTML views: 0
Total number of PDF views: 0 *
Loading metrics...

Abstract views

Total abstract views: 0 *
Loading metrics...

* Views captured on Cambridge Core between <date>. This data will be updated every 24 hours.

Usage data cannot currently be displayed

Finally tagless, partially evaluated: Tagless staged interpreters for simpler typed languages

  • JACQUES CARETTE (a1), OLEG KISELYOV (a2) and CHUNG-CHIEH SHAN (a3)
Submit a response

Discussions

No Discussions have been published for this article.

×

Reply to: Submit a response


Your details


Conflicting interests

Do you have any conflicting interests? *