Deforesting in Accumulating Parameters via Type-Directed Transformations

Classical deforestation methods fail to compose functions with accumulating parameters, which are function arguments to which intermediate result accumulates. This paper proposes a new deforestation method which solves this problem. The method is comprised of a few transformation steps, each of which is guided by type information. Though our solution draws its fundamental idea from a deforestation method that has been developed for attribute grammars, it is not merely a recast of an existing technique to another formalism. The new method provides a type-based account for the existing attribute grammar deforestation process. Further, it can deforest a class of functions that the attribute grammar deforestation cannot. These advantages are demonstrated by a few examples. It is also shown that the new method is as powerful as another method that has been developed for macro tree transducer composition.

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

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

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

[4]  Janis Voigtländer Using circular programs to deforest in accumulating parameters , 2002, ASIA-PEPM '02.

[5]  Harald Ganzinger Increasing Modularity and Language-Independency in Automatically Generated Compilers , 1983, Sci. Comput. Program..

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

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

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

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

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

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

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

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

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

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

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

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

[18]  Robert Giegerich,et al.  Attribute coupled grammars , 1984, SIGPLAN '84.