The second Futamura projection describes the automatic generation of non-trivial generating extensions by applying a partial evaluator to itself. We derive an ML implementation of the second •tamura projection for Type-Directed Partial Evaluation (TDPE). Due to the differences between 'traditional', syntax-directed partial evaluation and TDPE, this derivation involves several conceptual and technical steps. These include a suitable formulation of the second Futamura projection and techniques for using TDPE to specialize typeindexed programs. In the context of the second Futamura projection, we also compare and relate TDPE with conventional offiine partial evaluation. We demonstrate our, technique with several examples, including compiler generation for Tiny, a prototypical imperative language.Permission to make digital or hard copies of all o r part of this work for personal or classroom use is granted without fee provided that copies are not made or distributed for profit or commercial edvant -age and that copies bear this notice and the full citation on the first page. To copy otherwise, to republish, t o post on servers or t o redistribute to lists, requires prior specific permission and/or a fee.