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 CPS transformers.
Our main idea is to encode HOAS de Bruijn or higher-order abstract syntax using cogen 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 over the various ways to interpret it, yet statically assures that the interpreters never get stuck. To achieve self hyp interpretation and show Jones hyp optimality, we relate this exemplar of higher-rank and higher-kind polymorphism (provided by ML functors and Haskell 98 constructor classes) to plugging a term into a context of let hyp polymorphic bindings.
We thank Martin Sulzmann and Walid Taha for helpful discussions. Sam Staton, Pieter Hofstra, and Bart Jacobs kindly provided some useful references. We thank anonymous reviewers for pointers to related work.
This is a preview of subscription content, log in via an institution.
Buying options
Tax calculation will be finalised at checkout
Purchases are for personal use only
Learn about institutional subscriptionsPreview
Unable to display preview. Download preview PDF.
References
Asai, K.: Binding-time analysis for both static and dynamic expressions. New Generation Computing 20(1), 27–52 (2001)
Baars, A.I., Swierstra, S.D.: Typing dynamic typing. In: ICFP, pp. 157–166 (2002)
Balat, V., Di Cosmo, R., Fiore, M.P.: Extensional normalisation and type-directed partial evaluation for typed lambda calculus with sums. In: POPL, pp. 64–76 (2004)
Benton, P.N.: Embedded interpreters. JFP 15(4), 503–542 (2005)
Bjesse, P., Claessen, K., Sheeran, M., Singh, S.: Lava: Hardware design in Haskell. In: ICFP, pp. 174–184 (1998)
Calcagno, C., Moggi, E., Taha, W.: ML-like inference for classifiers. In: Schmidt, D. (ed.) ESOP 2004. LNCS, vol. 2986, pp. 79–93. Springer, Heidelberg (2004)
Danvy, O.: Type-directed partial evaluation. In: POPL, pp. 242–257 (1996)
Danvy, O., López, P.E.M.: Tagging, encoding, and Jones optimality. In: Degano, P. (ed.) ESOP 2003 and ETAPS 2003. LNCS, vol. 2618, pp. 335–347. Springer, Heidelberg (2003)
Davies, R., Pfenning, F.: A modal analysis of staged computation. J. ACM 48(3), 555–604 (2001)
Fiore, M.P.: Semantic analysis of normalisation by evaluation for typed lambda calculus. In: PPDP, pp. 26–37 (2002)
Fogarty, S., Pasalic, E., Siek, J., Taha, W.: Concoqtion: Indexed types now! In: PEPM (2007)
Glück, R.: Jones optimality, binding-time improvements, and the strength of program specializers. In: ASIA-PEPM, pp. 9–19 (2002)
Harper, R., Morrisett, J.G.: Compiling polymorphism using intensional type analysis. In: POPL, pp. 130–141 (1995)
Hinze, R., Jeuring, J., Löh, A.: Type-indexed data types. Science of Computer Programming 51(1–2), 117–151 (2004)
Honsell, F., Lenisa, M.: Coinductive characterizations of applicative structures. Math. Structures in Comp. Sci. 9(4), 403–435 (1999)
Hudak, P.: Building domain-specific embedded languages. ACM Comp. Surv. 28(4es), 196 (1996)
Jones, N.D., Gomard, C.K., Sestoft, P.: Partial Evaluation and Automatic Program Generation. Prentice Hall, Englewood Cliffs (1993)
Läufer, K., Odersky, M.: Self-interpretation and reflection in a statically typed language. In: OOPSLA\(\slash\)ECOOP Workshop on Object-Oriented Reflection and Metalevel Architectures (1993)
MetaOCaml http://www.metaocaml.org
Miller, D., Nadathur, G.: A logic programming approach to manipulating formulas and programs. In: IEEE Symp. on Logic Programming, pp. 379–388 (1987)
Nanevski, A., Pfenning, F.: Staged computation with names and necessity. JFP 15(6), 893–939 (2005)
Oliveira, B.C.d.S., Gibbons, J.: TypeCase: A design pattern for type-indexed functions. In: Haskell Workshop, pp. 98–109 (2005)
Pašalić, E., Taha, W., Sheard, T.: Tagless staged interpreters for typed languages. In: ICFP, pp. 157–166 (2002)
Peyton Jones, S.L., Vytiniotis, D., Weirich, S., Washburn, G.: Simple unification-based type inference for GADTs. In: ICFP, pp. 50–61 (2006)
Pfenning, F., Elliott, C.: Higher-order abstract syntax. In: PLDI, pp. 199–208 (1988)
Pfenning, F., Lee, P.: Metacircularity in the polymorphic λ-calculus. Theor. Comp. Sci. 89(1), 137–159 (1991)
Ramsey, N.: ML module mania: A type-safe, separately compiled, extensible interpreter. In: ML Workshop (2005)
Reynolds, J.C.: Definitional interpreters for higher-order programming languages. In: Proc. ACM Natl. Conf. vol. 2, 717–740 Repr. with a foreword in HOSC 11(4) 363–397 (1972)
Rhiger, M.: Higher-Order Program Generation. PhD thesis, BRICS, Denmark (2001)
Shao, Z.: Typed cross-module compilation. In: ICFP, pp. 141–152 (1998)
Sperber, M., Thiemann, P.: Two for the price of one: Composing partial evaluation and compilation. In: PLDI, pp. 215–225 (1997)
Sumii, E., Kobayashi, N.: A hybrid approach to online and offline partial evaluation. HOSC 14(2–3), 101–142 (2001)
Taha, W., Makholm, H., Hughes, J.: Tag elimination and Jones-optimality. In: Danvy, O., Filinski, A. (eds.) PADO 2001. LNCS, vol. 2053, pp. 257–275. Springer, Heidelberg (2001)
Taha, W., Nielsen, M.F.: Environment classifiers. In: POPL, pp. 26–37 (2003)
Thiemann, P.: Cogen in six lines. In: ICFP, pp. 180–189 (1996)
Washburn, G., Weirich, S.: Boxes go bananas: Encoding higher-order abstract syntax with parametric polymorphism. In: ICFP, pp. 249–262 (2003)
Xi, H., Chen, C., Chen, G.: Guarded recursive datatype constructors. In: POPL, pp. 224–235 (2003)
Yang, Z.: Encoding types in ML-like languages. In: ICFP, pp. 289–300 (1998)
Author information
Authors and Affiliations
Editor information
Rights and permissions
Copyright information
© 2007 Springer-Verlag Berlin Heidelberg
About this paper
Cite this paper
Carette, J., Kiselyov, O., Shan, Cc. (2007). Finally Tagless, Partially Evaluated. In: Shao, Z. (eds) Programming Languages and Systems. APLAS 2007. Lecture Notes in Computer Science, vol 4807. Springer, Berlin, Heidelberg. https://doi.org/10.1007/978-3-540-76637-7_15
Download citation
DOI: https://doi.org/10.1007/978-3-540-76637-7_15
Publisher Name: Springer, Berlin, Heidelberg
Print ISBN: 978-3-540-76636-0
Online ISBN: 978-3-540-76637-7
eBook Packages: Computer ScienceComputer Science (R0)