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

被引:149
作者
Carette, Jacques [1 ]
Kiselyov, Oleg
Shan, Chung-Chieh [2 ]
机构
[1] McMaster Univ, Hamilton, ON L8S 4L8, Canada
[2] Rutgers State Univ, Piscataway, NJ 08855 USA
关键词
COMPUTATION;
D O I
10.1017/S0956796809007205
中图分类号
TP31 [计算机软件];
学科分类号
081202 ; 0835 ;
摘要
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 lambda-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.
引用
收藏
页码:509 / 543
页数:35
相关论文
共 81 条
[1]  
[Anonymous], 1995, C RECORD POPL 95 22, DOI [DOI 10.1145/199448.199507, 10.1145/199448.199507]
[2]   Binding-time analysis for both static and dynamic expressions [J].
Asai, K .
NEW GENERATION COMPUTING, 2002, 20 (01) :27-51
[3]  
BAARS AI, 2002, ICFP, P157
[4]  
Balat Vincent., 2004, Proceedings of the 31st ACM SIGPLAN-SIGACT Symposium on Principles of Programming Languages, POPL 2004, Venice, Italy, January 14-16, P64, DOI [10.1145/964001.964007, DOI 10.1145/964001.964007]
[5]  
Bawden A., 1999, Proceedings of the 1999 ACM SIGPLAN. Workshop on Partial Evaluation and Semantics-Based Program Manipulation (PEPM'99), P4
[6]   Embedded interpreters [J].
Benton, N .
JOURNAL OF FUNCTIONAL PROGRAMMING, 2005, 15 :503-542
[7]  
Berarducci A, 1996, LECT NOTES PURE APPL, V180, P339
[8]  
BIRKEDAL L, 1993, 9322 DIKU U COP
[9]  
BJESSE P, 1998, ICFP P ACM INT C FUN, V34, P174
[10]  
BOHM C, 1985, THEOR COMPUT SCI, V39, P135, DOI 10.1016/0304-3975(85)90135-5