Cheap deforestation for non-strict functional languages

In functional languages intermediate data structures are often used as glue to connect separate parts of a program together. Deforestation is the process of automatically removing intermediate data structures. In this thesis we present and analyse a new approach to deforestation. This new approach is both practical and general. We analyse in detail the problem of list removal rather than the more general problem of arbitrary data structure removal. This more limited scope allows a complete evaluation of the pragmatic aspects of using our deforestation technology. We have implemented our list deforestation algorithm in the Glasgow Haskell compiler. Our implementation has allowed practical feedback. One important conclusion is that a new analysis is required to infer function arities and the linearity of lambda abstractions. This analysis renders the basic deforestation algorithm far more effective. We give a detailed assessment of our implementation of deforestation. We measure the effectiveness of our deforestation on a suite of real application programs. We also observe the costs of our deforestation algorithm.

[1]  Paul Hudak,et al.  Compilation of Haskell array comprehensions for scientific computing , 1990, PLDI '90.

[2]  Philip Wadler The Concatenate Vanishes , 1987 .

[3]  Philip Wadler A new array operation , 1986, Graph Reduction.

[4]  Philip Wadler,et al.  Monads for functional programming , 1995, NATO ASI PDC.

[5]  Simon L. Peyton Jones,et al.  Cheap Deforestation in Practice: An Optimizer for Haskell , 1994, IFIP Congress.

[6]  Valentin F. Turchin,et al.  The concept of a supercompiler , 1986, TOPL.

[7]  Pieter H. Hartel Benchmarking implementations of lazy functional languages II -- Two years later , 1995 .

[8]  Nancy McCracken,et al.  The Typechecking of Programs with Implicit Type Structure , 1984, Semantics of Data Types.

[9]  Wei-Ngan Chin,et al.  Automatic methods for program transformation , 1990 .

[10]  Philip Wadler,et al.  How to make ad-hoc polymorphism less ad hoc , 1989, POPL '89.

[11]  D. A. Turner,et al.  Miranda: A Non-Strict Functional language with Polymorphic Types , 1985, FPCA.

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

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

[14]  Paul Hudak Raman S. Sundaresh On the Expressiveness of Purely Functional I/O Systems , 1989 .

[15]  Cordelia V. Hall Using Hindley-Milner type inference to optimise list representation , 1994, LFP '94.

[16]  Tim Sheard,et al.  A fold for all seasons , 1993, FPCA '93.

[17]  Alfred V. Aho,et al.  Compilers: Principles, Techniques, and Tools , 1986, Addison-Wesley series in computer science / World student series edition.

[18]  Richard S. Bird,et al.  Introduction to functional programming , 1988, Prentice Hall International series in computer science.

[19]  Philip Wadler,et al.  Deforestation: Transforming Programs to Eliminate Trees , 1988, Theoretical Computer Science.

[20]  Bjarne Stroustrup,et al.  C++ Programming Language , 1986, IEEE Softw..

[21]  Maarten M. Fokkinga,et al.  Functional Programming with Bananas, Lenses, Envelopes and Barbed Wire , 1991, FPCA.

[22]  Richard S. Bird,et al.  Algebraic Identities for Program Calculation , 1989, Comput. J..

[23]  Luca Cardelli,et al.  A semantic basis for quest , 1990, Journal of Functional Programming.

[24]  John C. Reynolds,et al.  Types, Abstraction and Parametric Polymorphism , 1983, IFIP Congress.

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

[26]  Pascal Fradet,et al.  Compilation of functional languages by program transformation , 1991, TOPL.

[27]  Jan-Willem Maessen,et al.  Eliminating Intermediate Lists in pH using Local Transformations , 1994 .

[28]  Geoff W. Hamilton,et al.  Compile-time optimisation of store usage in lazy functional programs , 1993 .

[29]  D. J Collington Functional programming: Application and implementation: Peter Henderson Prentice-Hall International, 1980, £13.95 , 1981 .

[30]  Richard Andrews Kelsey,et al.  Compilation by program transformation , 1989 .

[31]  Simon L. Peyton Jones,et al.  Unboxed Values as First Class Citizens in a Non-Strict Functional Language , 1991, FPCA.

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

[33]  Grant Malcolm Homomorphisms and Promotability , 1989, MPC.

[34]  Philip Wadler,et al.  Deforestation for Higher-Order Functions , 1992, Functional Programming.

[35]  Jon Fairbairn,et al.  Design and implementation of a simple typed language based on the lambda-calculus , 1984 .

[36]  Philip J. Fleming,et al.  How not to lie with statistics: the correct way to summarize benchmark results , 1986, CACM.

[37]  Paul Hudak,et al.  Arrays, non-determinism, side-effects, and parallelism: A functional perspective , 1987, Graph Reduction.

[38]  Pieter H. Hartel,et al.  Benchmarking implementations of lazy functional languages , 1993, FPCA '93.

[39]  Simon L. Peyton Jones,et al.  On Program Transformation in the Glasgow Haskell Compiler , 1992, Functional Programming.

[40]  Johan Jeuring,et al.  Merging Monads and Folds for Functional Programming , 1995, Advanced Functional Programming.

[41]  Andrew W. Appel,et al.  Compiling with Continuations , 1991 .

[42]  Philip Wadler,et al.  Applicative style programming, program transformation, and list operators , 1981, FPCA '81.

[43]  Akihiko Takano,et al.  Shortcut deforestation in calculational form , 1995, FPCA '95.

[44]  Simon L. Peyton Jones,et al.  Implementing lazy functional languages on stock hardware: the Spineless Tagless G-machine , 1992, Journal of Functional Programming.

[45]  André L. M. Santos,et al.  Compilation by transformation in non-strict functional languages , 1995 .

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

[47]  Richard C. Waters,et al.  Automatic transformation of series expressions into loops , 1991, TOPL.

[48]  John Launchbury,et al.  Warm fusion: deriving build-catas from recursive definitions , 1995, FPCA '95.

[49]  Mark P. Jones,et al.  Functional Programming with Overloading and Higher-Order Polymorphism , 1995, Advanced Functional Programming.

[50]  John Hughes,et al.  A Novel Representation of Lists and its Application to the Function "reverse" , 1986, Inf. Process. Lett..

[51]  Simon L. Peyton Jones,et al.  The spineless tagless G-machine , 1989, FPCA.

[52]  Simon L. Peyton Jones,et al.  The Implementation of Functional Programming Languages , 1987 .

[53]  Simon L. Peyton Jones,et al.  Parallel Implementations of Functional Programming Languages , 1989, Comput. J..

[54]  Simon L. Peyton Jones,et al.  A short cut to deforestation , 1993, FPCA '93.