Typed Tagless Final Interpreters [chapter]

Oleg Kiselyov
2012 Lecture Notes in Computer Science  
The so-called 'typed tagless final' approach of Carette et al. [6] has collected and polished a number of techniques for representing typed higher-order languages in a typed metalanguage, along with typepreserving interpretation, compilation and partial evaluation. The approach is an alternative to the traditional, or 'initial' encoding of an object language as a (generalized) algebraic data type. Both approaches permit multiple interpretations of an expression, to evaluate it, prettyprint,
more » ... The final encoding represents all and only typed object terms without resorting to generalized algebraic data types, dependent or other fancy types. The final encoding lets us add new language forms and interpretations without breaking the existing terms and interpreters. These lecture notes introduce the final approach slowly and in detail, highlighting extensibility, the solution to the expression problem, and the seemingly impossible pattern-matching. We develop the approach further, to type-safe cast, run-time-type representation, Dynamics, and type reconstruction. We finish with telling examples of type-directed partial evaluation and encodings of type-and-effect systems and linear lambda-calculus.
doi:10.1007/978-3-642-32202-0_3 fatcat:aq2fpvjxljc37eglbbagj55liq