A higher-order removal method

A major attraction of functional languages is their support for higher-order functions. This facility increases the expressive power of functional languages by allowing concise and reusable programs to be written. However, higher-order functions are more expensive to execute and to analyse for optimisations.To reduce the performance penalties of using higher-order functions, this paper proposes two transformation algorithms which could automatically removemost higher-order functions from functional programs. The first algorithm uses aneta-expansion technique to eliminate expressions which return function-type results. The second algorithm uses afunction specialisation technique to eliminate expressions with function-type arguments. Together, they remove higher-order functions by transforming each higher-order program to an equivalent first-order (or lower-order) program. We shall prove that the two algorithms areterminating (when applied to well-typed programs) and alsototally-correct (preserving non-strict semantics).

[1]  Thomas Johnsson,et al.  Lambda Lifting: Treansforming Programs to Recursive Equations , 1985, FPCA.

[2]  Wei-Ngan Chin Fully Lazy Higher-Order Removal , 1992, PEPM.

[3]  John Hughes,et al.  Why Functional Programming Matters , 1989, Comput. J..

[4]  Wei-Ngan Chin,et al.  Safe fusion of functional expressions II: Further improvements , 1994, Journal of Functional Programming.

[5]  Neil D. Jones,et al.  Mix: A self-applicable partial evaluator for experiments in compiler generation , 1989, LISP Symb. Comput..

[6]  R. J. M. Hughes,et al.  Super-combinators a new implementation method for applicative languages , 1982, LFP '82.

[7]  Philip Wadler,et al.  Deforestation: Transforming Programs to Eliminate Trees , 1990, Theor. Comput. Sci..

[8]  Philip Wadler,et al.  Theorems for free! , 1989, FPCA.

[9]  Simon L. Peyton Jones,et al.  Report on the programming language Haskell: a non-strict, purely functional language version 1.2 , 1992, SIGP.

[10]  Peter Sestoft,et al.  An experiment in partial evaluation: the generation of a compiler generator , 1985, SIGP.

[11]  James Hook,et al.  Defunctionalization of Typed Programs , 1994 .

[12]  Daniel Le Métayer,et al.  Computer-Time Garbage Collection by Sharing Analysis , 1989, FPCA.

[13]  David Sands,et al.  Total correctness by local improvement in program transformation , 1995, POPL '95.

[14]  Flemming Nielson,et al.  Transformations on higher-order functions , 1989, FPCA.

[15]  Michael P. Georgeff,et al.  Transformations and reduction strategies for typed lambda expressions , 1984, ACM Trans. Program. Lang. Syst..

[16]  Philip Wadler,et al.  The essence of functional programming , 1992, POPL '92.

[17]  Colin Runciman,et al.  Transformation in a Non-Strict Language: An Approach to Instantiation , 1989, Functional Programming.

[18]  John Darlington,et al.  A Transformation System for Developing Recursive Programs , 1977, J. ACM.

[19]  Wei-Ngan Chin Safe fusion of functional expressions , 1992, LFP '92.

[20]  J. Goguen Higher-order functions considered unnecessary for higher-order programming , 1990 .

[21]  Thomas Johnsson,et al.  The Chalmers Lazy-ML Compiler , 1989, Computer/law journal.

[22]  John C. Reynolds,et al.  Definitional Interpreters for Higher-Order Programming Languages , 1972, ACM '72.

[23]  Egidio Astesiano,et al.  Languages with Reducing Reflective Types , 1980, ICALP.

[24]  Robin Milner,et al.  A Theory of Type Polymorphism in Programming , 1978, J. Comput. Syst. Sci..

[25]  Olivier Danvy,et al.  Abstracting control , 1990, LISP and Functional Programming.

[26]  Carsten Kehler Holst,et al.  Finiteness Analysis , 1991, Conference on Functional Programming Languages and Computer Architecture.