Type Specialisation for the Lambda-Calculus; or, A New Paradigm for Partial Evaluation based on Type Inference.

John Hughes

Abstract

We present a new paradigm for partial evaluation, inspired by type inference. Our partial evaluator is specified in terms of specialisation rules that prescribe how a source expression and type should be transformed into a residual expression and type. Static information is represented in the residual types, in contrast to traditional partial evaluators which effectively represent it in the transformed expression. Thus we break the link between staticness and unfolding: a variable can be static even if the specialiser does not substitute a value for it; static information is propagated by unification, not by substitution. As a result we obtain better static information flow, and consequently stronger specialisation, than traditional partial evaluators.

Our specialiser is very modular: each specialisation feature is tied to a particular type in the source language, with associated introduction and elimination rules. Each feature is specified independently, and features can be combined in arbitrary ways. This has led to a number of new results:

Finally, although we describe our approach in terms of the lambda-calculus, the basic idea is quite general. Similar results should be obtainable for other typed languages, including imperative ones.

The paper is available here.