### Adjoint Folds and Unfolds Or: Scything Through the Thicket of Morphisms

"... Abstract. Folds and unfolds are at the heart of the algebra of programming. They allow the cognoscenti to derive and manipulate programs rigorously and effectively. Fundamental laws such as fusion codify basic optimisation principles. However, most, if not all, programs require some tweaking to be g ..."

Abstract
- Add to MetaCart

Abstract. Folds and unfolds are at the heart of the algebra of programming. They allow the cognoscenti to derive and manipulate programs rigorously and effectively. Fundamental laws such as fusion codify basic optimisation principles. However, most, if not all, programs require some tweaking to be given the form of an (un-) fold, and thus make them amenable to formal manipulation. In this paper, we remedy the situation by introducing adjoint folds and unfolds. We demonstrate that most programs are already of the required form and thus are directly amenable to manipulation. Central to the development is the categorical notion of an adjunction, which links adjoint (un-) folds to standard (un-) folds. We discuss a number of adjunctions and show that they are directly relevant to programming.

### PURe Program Understanding and Re-engineering: Calculi and Applications

, 2003

"... In this paper we show how some of the recursion patterns typically used in algebraic programming can be defined using hylomorphisms. Most of these definitions were previously known. However, unlike previous approaches that use fixpoint induction, we show how to derive the standard laws of each recur ..."

Abstract
- Add to MetaCart

In this paper we show how some of the recursion patterns typically used in algebraic programming can be defined using hylomorphisms. Most of these definitions were previously known. However, unlike previous approaches that use fixpoint induction, we show how to derive the standard laws of each recursion pattern by using just the basic laws of hylomorphisms. We also define the accumulation recursion pattern introduced by Pardo using a hylomorphism, and use this definition to derive the strictness conditions that characterize this operator in the presence of partiality. All definitions are implemented and exemplified in Haskell. 1

### An Analytical Method For Parallelization Of Recursive Functions

, 2000

"... Programming with parallel skeletons is an attractive framework because it encourages programmers to develop efficient and portable parallel programs. However, extracting parallelism from sequential specifications and constructing efficient parallel programs using the skeletons are still difficult ..."

Abstract
- Add to MetaCart

Programming with parallel skeletons is an attractive framework because it encourages programmers to develop efficient and portable parallel programs. However, extracting parallelism from sequential specifications and constructing efficient parallel programs using the skeletons are still difficult tasks. In this paper, we propose an analytical approach to transforming recursive functions on general recursive data structures into compositions of parallel skeletons. Using static slicing, wehave defined a classification of subexpressions based on their data-parallelism. Then, skeleton-based parallel programs are generated from the classification. To extend the scope of parallelization, wehave adopted more general parallel skeletons which do not require the associativity of argument functions. In this way, our analytical method can parallelize recursive functions with complex data flows. Keywords: data parallelism, parallelization, functional languages, parallel skeletons, data flow analysis, static slice 1.

### Jorge Sousa Pinto

"... Abstract. Functional programs are particularly well suited to formal manipulation by equational reasoning. In particular, it is straightforward to use calculational methods for program transformation. Well-known transformation techniques, like tupling or the introduction of accumulating parameters, ..."

Abstract
- Add to MetaCart

Abstract. Functional programs are particularly well suited to formal manipulation by equational reasoning. In particular, it is straightforward to use calculational methods for program transformation. Well-known transformation techniques, like tupling or the introduction of accumulating parameters, can be implemented using calculation through the use of the fusion (or promotion) strategy. In this paper we revisit this transformation method, but, unlike most of the previous work on this subject, we adhere to a pure point-free calculus that emphasizes the advantages of equational reasoning. We focus on the accumulation strategy initially proposed by Bird, where the transformed programs are seen as higher-order folds calculated systematically from a specification. The machinery of the calculus is expanded with higher-order point-free operators that simplify the calculations. A substantial number of examples (both classic and new) are fully developed, and we introduce several shortcut optimization rules that capture typical transformation patterns. 1.

### Streaming Algorithms (Extended Abstract)

"... Unfolds generate data structures, and folds consume them. ..."

### Generic Accumulations for Program Calculation

, 2004

"... Accumulations are recursive functions widely used in the context of functional programming. They maintain intermediate results in additional parameters, called accumulators, that may be used in later stages of computing. In a former work [Par02] a generic recursion operator named afold was presented ..."

Abstract
- Add to MetaCart

Accumulations are recursive functions widely used in the context of functional programming. They maintain intermediate results in additional parameters, called accumulators, that may be used in later stages of computing. In a former work [Par02] a generic recursion operator named afold was presented. Afold makes it possible to write accumulations defined by structural recursion for a wide spectrum of datatypes (lists, trees, etc.). Also, a number of algebraic laws were provided that served as a formal tool for reasoning about programs with accumulations. In this work, we present an extension to afold that allows a greater flexibility in the kind of accumulations that may be represented. This extension, in essence, provides the expressive power to allow accumulations to have more than one recursive call in each subterm, with different accumulator values —something that was not previously possible. The extension is conservative, in the sense that we obtain similar algebraic laws for the extended operator. We also present a case study that illustrates the use of the algebraic laws in a calculational setting and a technique for the improvement of fused programs

### Submitted to ICFP’13 Unifying Recursion Schemes

"... Folds over inductive datatypes are well understood and widely used. In their plain form, they are quite restricted; but many disparate generalisations have been proposed that enjoy similar calculational benefits. There have also been attempts to unify the various generalisations: two prominent such ..."

Abstract
- Add to MetaCart

Folds over inductive datatypes are well understood and widely used. In their plain form, they are quite restricted; but many disparate generalisations have been proposed that enjoy similar calculational benefits. There have also been attempts to unify the various generalisations: two prominent such unifications are the ‘recursion schemes from comonads ’ of Uustalu, Vene and Pardo, and our own ‘adjoint folds’. Until now, these two unified schemes have appeared incompatible. We show that this appearance is illusory: in fact, adjoint folds subsume recursion schemes from comonads. The proof of this claim involves standard constructions in category theory that are nevertheless not well known in functional programming: Eilenberg-Moore categories and bialgebras. The link between the two schemes is provided by the fusion rule of categorical fixedpoint calculus.