## Shortcut Deforestation in Calculational Form (1995)

Venue: | In Proc. Conference on Functional Programming Languages and Computer Architecture |

Citations: | 92 - 3 self |

### BibTeX

@INPROCEEDINGS{Takano95shortcutdeforestation,

author = {Akihiko Takano and Erik Meijer},

title = {Shortcut Deforestation in Calculational Form},

booktitle = {In Proc. Conference on Functional Programming Languages and Computer Architecture},

year = {1995},

pages = {306--313},

publisher = {ACM Press}

}

### OpenURL

### Abstract

In functional programming, intermediate data structures are often used to "glue" together small programs. Deforestation is a program transformation to remove these intermediate data structures automatically. We present a simple algorithm for deforestation based on two fusion rules for hylomorphism, an expressive recursion pattern. A generic notation for hylomorphisms is introduced, where natural transformations are explicitly factored out, and it is used to represent programs. Our method successfully eliminates intermediate data structures of any algebraic type from a much larger class of compositional functional programs than previous techniques. 1 Introduction In functional programming, programs are often constructed by "gluing" together small components, using intermediate data structures to convey information between them. Such data are constructed in one component and later consumed in another component, but never appear in the result of the whole program. The compositional styl...

### Citations

579 | A transformation system for developing recursive programs
- Burstall, Darlington
- 1977
(Show Context)
Citation Context ...eep track of all function calls occurred previously, and suitably introduce a definition of recursive function on detecting a repetition. This corresponds to the fold step of Burstall and Darlington (=-=[BD77]-=-). The process of keeping track of function calls and the clever control to avoid infinite unfolding introduces substantial cost and complexity in algorithms, which prevent deforestation to be adopted... |

334 | Theorems for free
- Wadler
- 1989
(Show Context)
Citation Context ...em The analysis in the previous section suggests that the following theorem holds in general([Mei94]). Theorem 3.1 (Acid Rain) g : 8A : (F A ! A) ! A ) (j'j) F (g in F ) = g ' Proof The free theorem (=-=[Wad89]-=-) associated with the type of g is f ffi / = ' ffi F f ) f (g /) = g ' In case g is defined using recursion, f needs to be strict as well. By taking f := (j'j) F ; /:=in F , this rule is instantiated ... |

303 | Functional programming with bananas, lenses, envelopes and barbed wire
- Meijer, Fokkinga, et al.
- 1991
(Show Context)
Citation Context ...of the catamorphism, we get the definition of map function on lists. 2.4 Hylomorphisms A hylomorphism [['; /]] F is what you get by composing a fold with an unfold: (j'j) F ffi [(/)] F . Equivalently =-=[MFP91]-=-, a hylomorphism is the fixed shape of recursion that comes with a particular functor. [[ ; ]] F : (FA ! A) \Theta (B ! FB) ! B ! A [['; /]] F = (f : ' ffi Ff ffi /) It is obvious from definitions tha... |

198 | A short-cut to deforestation
- Gill, Launchbury, et al.
- 1993
(Show Context)
Citation Context ...theoretical basis can be found in the study on Constructive Algorithmics 1 ([Mee86, MFP91, Mee92, Mei92, Fok92, Jeu93]), we baptise them as deforestation in calculational form. Although the method in =-=[GLPJ93]-=- is limited to the specific data structure of lists, it was shown clearly that this calculation-based deforestation is more practical than the original style deforestation and its extensions. By using... |

171 | The concept of a supercompiler - Turchin - 1986 |

111 | A fold for all seasons
- Sheard, Fegaras
- 1993
(Show Context)
Citation Context ...ension to the other data structures is simply suggested. Once embedded in the proper theoretical framework it becomes clear how to generalize their method to other data structures. Sheard and Fegaras =-=[SF93]-=- demonstrated that folding can be defined for many algebraic types definable in languages like ML (i.e. mutually recursive sumof -product types). Their normalization algorithm automatically calculates... |

97 | and Order in Algorithmics - Law - 1992 |

95 | Algorithmics –towards programming as a mathematical activity - Meertens - 1986 |

60 |
Safe fusion of functional expressions
- Chin
- 1992
(Show Context)
Citation Context ...grams, and it need not expand to firstorder forms. It is also easy to control what types of intermediate data structures are to be removed with our method. The fusion transformation proposed by Chin (=-=[Chi92]-=-) generalizes deforestation to make it applicable to all first-order programs. Combining it with his higherorder removal technique, his algorithm can take any first-order and higher-order program as i... |

50 | Essence of generalized partial computation - Futamura, Nogi, et al. - 1991 |

43 | Calculating Compilers - Meijer - 1992 |

37 | Theories for Algorithm Calculation - Jeuring - 1993 |

25 | Improving programs which recurse over multiple inductive structures
- Fegaras, Sheard, et al.
(Show Context)
Citation Context ... as length ffi flatten on binary tree), which cannot be handled with Chin's method without assuming an extra law on length and append, naturally be deforested by our method without any extra laws. In =-=[FSZ94]-=- Fegaras, Sheard and Zhou extend their normalization algorithm in [SF93] to the more general fold programs which recurse over multiple inductive structures simultaneously, such as zip or nth. Because ... |

24 | Towards unifying partial evaluation, deforestation, supercompilation, and GPC
- Sørensen, Glück, et al.
(Show Context)
Citation Context ... set of terms that the deforestation algorithm encounters, and successfully locates the increasing (accumulating) parameters which could be the source of infinite unfolding. Srensen, Gluck and Jones (=-=[SGJ94]-=-) pick up four different transformation methods (Partial Evaluation, Deforestation, Supercompilation and Generalized Partial Computation [FNT91, Tak91]) and discuss the difference of transformational ... |

17 | Experiments with a supercompiler - Nirenberg, \mathrmV - 1982 |

15 | Generalized partial computation for a lazy functional language - Takano - 1991 |

14 |
A grammar-based dataflow analysis to stop deforestation
- S��rensen
- 1994
(Show Context)
Citation Context ...usly, such as zip or nth. Because our method always works on the function level and explicitly manipulates the functors, it is easy to give symmetric definitions to those functions like zip. Srensen (=-=[Sr94]-=-), applies a tree grammar-based data-flow analysis to put annotations on programs that guarantee termination of deforestation for the wider class of first-order programs than Chin's method. The gramma... |

1 |
and Oege Moor. Relational program derivation and context-free language recognition
- Bird
- 1994
(Show Context)
Citation Context ...[(/)] F = [[in F ; /]] F . Hylomorphism [['; /]] F is a recursive function whose call graph is isomorphic to the data type F. It is known most practical functions can be represented as hylomorphisms (=-=[BM94]-=-). Meertens proved in [Mee92] that every primitive recursive function on an algebraic type can be represented as a hylomorphism on some algebraic type. Hylomorphisms enjoy many useful laws for program... |

1 |
Acid rain theorem
- Meijer
- 1994
(Show Context)
Citation Context ... corresponding fusion theorems. The normalization algorithms for these recursive patterns were not given. In this paper we show that a single transformation rule (and its dual), the Acid Rain Theorem =-=[Mei94]-=-, elegantly generalizes the foldr/build to any algebraic 1 For more info check out the WWW page http://www.cs.utwente.nl/~fokkinga/algorithmics.html data types. We introduce a generic notation for hyl... |

1 | The concept of a supercompiler - \mathrmF - 1986 |