Using circular programs to deforest in accumulating parameters

Functional languages allow a modular programming style by function composition, which however can lead to inefficient runtime behavior due to production and consumption of intermediate results.We present a new mechanizable transformation technique for removing intermediate data structures in the composition of two functions from a class of recursive functions with accumulating parameters, for which classical deforestation techniques fail.In order to avoid multiple traversals of the input data structure, the composition algorithm produces circular programs that make essential use of lazy evaluation and local recursion.The resulting programs are simplified using a post-processing phase presented in the paper.

[1]  Andreas Maletti,et al.  Tree transducer based program transformations for Haskell , 2001 .

[2]  Yoshihiko Futamura,et al.  On Deforesting Parameters of Accumulating Maps , 2001, LOPSTR.

[3]  Didier Parigot,et al.  Declarative Program Transformation: A Deforestation Case-Study , 1999, PPDP.

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

[5]  S. D. Swierstra,et al.  Using attribute grammars to derive efficient functional programs , 1986 .

[6]  S. Doaitse Swierstra,et al.  Virtual Data Structures , 1993, Formal Program Development.

[7]  Geoff W. Hamilton,et al.  Extending Deforestation for First Order functional Programs , 1991, Functional Programming.

[8]  Walid Taha,et al.  Semantics, Applications, and Implementation of Program Generation , 2001, Lecture Notes in Computer Science.

[9]  Josef Svenningsson Shortcut fusion for accumulating parameters & zip-like functions , 2002, ICFP '02.

[10]  Armin Kühnemann,et al.  Comparison of Deforestation Techniques for Functional Programs and for Tree Transducers , 1999, Fuji International Symposium on Functional and Logic Programming.

[11]  Janis Voigtländer Using Circular Programs to Deforest in Accumulating Parameters , 2004, High. Order Symb. Comput..

[12]  Janis Voigtlander Composition of restricted Macro Tree Transducers , 2001 .

[13]  Simon L. Peyton Jones,et al.  Let-floating: moving bindings to give faster programs , 1996, ICFP '96.

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

[15]  Thomas Johnsson,et al.  Attribute grammars as a functional programming paradigm , 1987, FPCA.

[16]  John H. G. van Groningen Optimising Recursive Functions Yielding Multiple Results in Tuples in a Lazy Functional Language , 1999, IFL.

[17]  Zoltán Fülöp On attributed tree transducers , 1981, Acta Cybern..

[18]  A. Pettorossi,et al.  Derivation of programs which traverse their input data only once , 1989 .

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

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

[21]  Janis Voigtländer Conditions for Efficiency Improvement by Tree Transducer Composition , 2002, RTA.

[22]  Patricia Johann A Generalization of Short-Cut Fusion and its Correctness Proof , 2002, High. Order Symb. Comput..

[23]  Armin Kühnemann,et al.  Composition of functions with accumulating parameters , 2004, Journal of Functional Programming.

[24]  Richard S. Bird Using circular programs to eliminate multiple traversals of data , 2004, Acta Informatica.

[25]  Armin Kühnemann,et al.  Benefits of Tree Transducers for Optimizing Functional Programs , 1998, FSTTCS.

[26]  Robert Glück,et al.  A positive supercompiler , 1996, Journal of Functional Programming.

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

[28]  Olaf Chitil,et al.  Type-inference based deforestation of functional programs , 2000 .

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

[30]  Patricia Johann Short Cut Fusion: Proved and Improved , 2001, SAIG.

[31]  Annalisa Bossi Logic-Based Program Synthesis and Transformation , 1999, Lecture Notes in Computer Science.

[32]  Peyton Jones,et al.  Haskell 98 language and libraries : the revised report , 2003 .

[33]  Andrew John Gill,et al.  Cheap deforestation for non-strict functional languages , 1996 .

[34]  Wei-Ngan Chin,et al.  Effective Optimization of Multiple Traversals in Lazy Languages , 1999, PEPM.

[35]  Joost Engelfriet,et al.  Macro Tree Transducers , 1985, J. Comput. Syst. Sci..

[36]  David Sands,et al.  Total correctness by local improvement in the transformation of functional programs , 1996, TOPL.

[37]  Susumu Nishimura Deforesting in Accumulating Parameters via Type-Directed Transformations , 2002, APLAS.

[38]  Simon L. Peyton Jones,et al.  Secrets of the Glasgow Haskell Compiler inliner , 2002, Journal of Functional Programming.