## Program fusion with paramorphisms (2006)

Venue: | In Mathematically Structured Functional Programming, Proceedings, Electronic Workshops in Computing. British Computer Society |

Citations: | 2 - 1 self |

### BibTeX

@INPROCEEDINGS{Domínguez06programfusion,

author = {Facundo Domínguez and Alberto Pardo},

title = {Program fusion with paramorphisms},

booktitle = {In Mathematically Structured Functional Programming, Proceedings, Electronic Workshops in Computing. British Computer Society},

year = {2006}

}

### OpenURL

### Abstract

The design of programs as the composition of smaller ones is a wide spread approach to programming. In functional programming, this approach raises the necessity of creating a good amount of intermediate data structures with the only aim of passing data from one function to another. Using program fusion techniques, it is possible to eliminate many of those intermediate data structures by an appropriate combination of the codes of the involved functions. In the standard case, no mention to the eliminated data structure remains in the code obtained from fusion. However, there are situations in which parts of that data structure becomes an internal value manipulated by the fused program. This happens, for example, when primitive recursive functions (socalled paramorphisms) are involved. We show, for example, that the result of fusing a primitive recursive function p with another function f may give as result a function that contains calls to f. Moreover, we show that in some cases the result of fusion may be less efficient than the original composition. We also investigate a general recursive version of paramorphism. This study is strongly motivated by the development of a fusion tool for Haskell programs called HFUSION.

### Citations

429 | Deforestation: transforming programs to eliminate trees
- Wadler
- 1990
(Show Context)
Citation Context ...cing the composition by an equivalent function which does not construct the data structure. Intermediate data structures can be eliminated by a program transformation technique known as deforestation =-=[16, 9]-=-. In this paper, we follow an approach to deforestation based on recursion program schemes associated with recursive types [14, 13]. Program schemes have associated algebraic laws, which are useful fo... |

342 | Theorems for free - Wadler - 1989 |

311 | Functional programming with bananas, lenses, envelopes and barbed wire
- Meijer, Fokkinga, et al.
- 1991
(Show Context)
Citation Context ...ry. This section summarizes the relevant concepts of this approach to recursive types and the generic definition and standard laws of three well-known schemes: fold, unfold and hylomorphism (see e.g. =-=[12, 4, 5, 14, 6]-=-). Throughout the paper the working category will be Cpo, the category of pointed cpos (complete partial orders with a least element ⊥) and continuous functions. The choice of this category 1 http://w... |

237 |
Introduction to Functional Programming using Haskell. 2nd edn
- Bird
- 1998
(Show Context)
Citation Context ...ion f :: a → b such that f ◦ φ = φ ′ ◦ F f. The least homomorphism between inF and any other algebra φ :: F a → a gives rise to a recursion scheme, denoted by (|φ|)F :: µF → a and usually called fold =-=[2]-=- or catamorphism [12], which captures definitions by structural recursion. That is, fold is defined as the least function that satisfies the equation f ◦ inF = φ ◦ F f. Therefore, (|φ|)F ◦ inF = φ ◦ F... |

203 | A short cut to deforestation
- Gill, Launchbury, et al.
- 1993
(Show Context)
Citation Context ...cing the composition by an equivalent function which does not construct the data structure. Intermediate data structures can be eliminated by a program transformation technique known as deforestation =-=[16, 9]-=-. In this paper, we follow an approach to deforestation based on recursion program schemes associated with recursive types [14, 13]. Program schemes have associated algebraic laws, which are useful fo... |

99 |
and Order in Algorithmics
- Law
- 1992
(Show Context)
Citation Context ...ry. This section summarizes the relevant concepts of this approach to recursive types and the generic definition and standard laws of three well-known schemes: fold, unfold and hylomorphism (see e.g. =-=[12, 4, 5, 14, 6]-=-). Throughout the paper the working category will be Cpo, the category of pointed cpos (complete partial orders with a least element ⊥) and continuous functions. The choice of this category 1 http://w... |

94 | Shortcut to Deforestation in Calculational Form
- Takano, Meijer
- 1995
(Show Context)
Citation Context ...iminated by a program transformation technique known as deforestation [16, 9]. In this paper, we follow an approach to deforestation based on recursion program schemes associated with recursive types =-=[14, 13]-=-. Program schemes have associated algebraic laws, which are useful for reasoning about programs as well as for program transformation purposes. In connection with deforestation, there is a particularl... |

87 |
Algebraic Data Types and Program Transformation
- Malcolm
- 1990
(Show Context)
Citation Context ...c ◦ inF = φ ◦ F c The two functions are defined simultaneously in an asymmetric way. That is, p depends on c while c does not depend on p. Definitions following this pattern are called a zygomorphism =-=[10]-=-. From the definition of p and c, it can be derived that [5]: 〈p, c〉 = (|〈π1 ◦ ψ, φ ◦ F π2〉|)F In the context of Cpo this equation is proved by fixed point induction. If we call pc the split 〈p, c〉, t... |

50 | The Under-Appreciated Unfold
- Gibbons, Jones
- 1998
(Show Context)
Citation Context ...n this categoty. This means that there exists a unique homomorphism from any coalgebra ψ :: a → F a to outF , which is denoted by [(ψ)]F :: a → µF . It gives rise to a recursion scheme, called unfold =-=[8]-=- or anamorphism [12], which satisfies the equation: outF ◦ [(ψ)]F = F [(ψ)]F ◦ ψ (5) Unfold captures definitions by structural corecursion. It satisfies the following laws: Unfold identity Unfold fusi... |

33 | Calculating Functional Programs
- Gibbons
- 2002
(Show Context)
Citation Context ...ry. This section summarizes the relevant concepts of this approach to recursive types and the generic definition and standard laws of three well-known schemes: fold, unfold and hylomorphism (see e.g. =-=[12, 4, 5, 14, 6]-=-). Throughout the paper the working category will be Cpo, the category of pointed cpos (complete partial orders with a least element ⊥) and continuous functions. The choice of this category 1 http://w... |

33 | A calculational fusion system hylo
- Onoue, Hu, et al.
- 1997
(Show Context)
Citation Context ...iminated by a program transformation technique known as deforestation [16, 9]. In this paper, we follow an approach to deforestation based on recursion program schemes associated with recursive types =-=[14, 13]-=-. Program schemes have associated algebraic laws, which are useful for reasoning about programs as well as for program transformation purposes. In connection with deforestation, there is a particularl... |

30 | Sorting morphisms
- Augusteijn
- 1998
(Show Context)
Citation Context ...tain the equation �φ, ψ�F = φ ◦ F �φ, ψ�F ◦ ψ (10) which expresses the shape of recursion that comes with each datatype. Two well-known examples of hylomorphisms are quicksort and merge sort (see e.g =-=[1, 6]-=-). The expressiveness of hylomorphisms is very rich. In practice, almost every interesting recursive function can be expressed as a hylomorphism. Applying the identity laws corresponding to fold and u... |

25 |
Introduction to Functional Programming using
- BIRD
- 1998
(Show Context)
Citation Context ...ion f :: a → b such that f ◦ φ = φ ′ ◦ F f. The least homomorphism between inF and any other algebra φ :: F a → a gives rise to a recursion scheme, denoted by (|φ|)F :: µF → a and usually called fold =-=[2]-=- or catamorphism [12], which captures definitions by structural recursion. That is, fold is defined as the least function that satisfies the equation f ◦ inF = φ ◦ F f. Therefore, (|φ|)F ◦ inF = φ ◦ F... |

17 | Program calculation properties of continuous algebras
- Fokkinga, Meijer
- 1991
(Show Context)
Citation Context |

11 | Recursive coalgebras from comonads
- Capretta, Uustalu, et al.
(Show Context)
Citation Context ...ion that makes the following diagram commute: a ψ ❄ F a f ✲ b ✻ φ F 〈f, id〉 ✲ F (b × a) The notion of generalized paramorphism is in some sense related with that of parametrically recursive coalgebra =-=[3]-=-. Example 4.1 Consider the functor La that captures the signature of lists. For φ1 :: () → b and φ2 :: a × (c × b) → c, the paramorphism f = {|φ1▽φ2, ψ|}La :: b → c is the least function such that f b... |

7 |
Fission for program comprehension
- Gibbons
- 2006
(Show Context)
Citation Context ...op on Mathematically Structured Functional Programming, MSFP 2006 7sProgram Fusion with Paramorphisms Function wc is a paramorphism. It is inspired in one of the word counting algorithms described in =-=[7]-=-. This function adds one each time the end of a word is detected, and for this it uses the current character c and the next one d (except at the end). By para-fold fusion we obtain as result a paramor... |