## Revisiting Catamorphisms over Datatypes with Embedded Functions (or, Programs from Outer Space) (1996)

Venue: | In Conf. Record 23rd ACM SIGPLAN/SIGACT Symp. on Principles of Programming Languages, POPL’96, St. Petersburg Beach |

Citations: | 55 - 3 self |

### BibTeX

@INPROCEEDINGS{Fegaras96revisitingcatamorphisms,

author = {Leonidas Fegaras and Tim Sheard},

title = {Revisiting Catamorphisms over Datatypes with Embedded Functions (or, Programs from Outer Space)},

booktitle = {In Conf. Record 23rd ACM SIGPLAN/SIGACT Symp. on Principles of Programming Languages, POPL’96, St. Petersburg Beach},

year = {1996},

pages = {284--294},

publisher = {ACM Press}

}

### Years of Citing Articles

### OpenURL

### Abstract

We revisit the work of Paterson and of Meijer & Hutton, which describes how to construct catamorphisms for recursive datatype definitions that embed contravariant occurrences of the type being defined. Their construction requires, for each catamorphism, the definition of an anamorphism that has an inverse-like relationship to that catamorphism. We present an alternative construction, which replaces the stringent requirement that an inverse anamorphism be defined for each catamorphism with a more lenient restriction. The resulting construction has a more efficient implementation than that of Paterson, Meijer, and Hutton and the relevant restriction can be enforced by a HindleyMilner type inference algorithm. We provide numerous examples illustrating our method. 1 Introduction Functional programmers often use catamorphisms (or fold functions) as an elegant means of expressing algorithms over algebraic datatypes. Catamorphisms have also been used by functional programmers as a medium in ...

### Citations

851 |
A formulation of the simple theory of types
- Church
- 1940
(Show Context)
Citation Context ... the lambda term (x:1 + x) 1 is represented by the Term construction Appl(Abs(fn x ) Appl(Succ,x)),Const 1) This term representation can be traced back to Church's seminal work on the lambda calculus =-=[2]-=-, in which universal quantification 8x:A is modeled by the addition of a constant \Pi and by writing \Pi(x:A). This representation is also similar to the higher-order abstract syntax representation of... |

367 |
ML for the Working Programmer
- Paulson
- 1991
(Show Context)
Citation Context ...as structures with embedded functions in a manner similar to the higher-order abstract syntax representation of programs by Pfenning and Elliot [12] (all our examples are written in Standard ML (SML) =-=[11]-=-): datatype Term = Const of int j Succ j Appl of Term \Theta Term j Abs of Term !Term For example, the lambda term (x:1 + x) 1 is represented by the Term construction Appl(Abs(fn x ) Appl(Succ,x)),Con... |

330 | Theorems for Free
- WADLER
- 1989
(Show Context)
Citation Context ...by structures with embedded functions, we construct the parametricity theorem for a polymorphic function. To understand this section, the reader must be familiar with Wadler's theorems-for-free paper =-=[15]-=-. Any function f of typessatisfies a parametricity theorem, which is derived directly from the types. For firstorder functions, this theorem states that any strict polymorphic function is a natural tr... |

303 |
Higher-order abstract syntax
- Pfenning, Elliott
- 1988
(Show Context)
Citation Context ...d terms in a simple lambda calculus. We represent terms as structures with embedded functions in a manner similar to the higher-order abstract syntax representation of programs by Pfenning and Elliot =-=[12]-=- (all our examples are written in Standard ML (SML) [11]): datatype Term = Const of int j Succ j Appl of Term \Theta Term j Abs of Term !Term For example, the lambda term (x:1 + x) 1 is represented by... |

301 | Functional Programming with Bananas, Lenses, Envelopes and Barbed Wire
- MEIJER, FOKKINGA, et al.
- 1991
(Show Context)
Citation Context ... as an elegant means of expressing algorithms over algebraic datatypes. Catamorphisms have also been used by functional programmers as a medium in which programs can be calculated from specifications =-=[7, 6, 5]-=- and as a good intermediate representation of programs that supports optimization [14, 3, 4, 1]. It is, thus, truly ironic that these functions apply only to first order datatypes. Until recently, it ... |

153 | Higher-order logic programming
- Miller
- 1990
(Show Context)
Citation Context ... representation is also similar to the higher-order abstract syntax representation of programs, formulas, and rules by Pfenning and Elliot [12], and is also related to the work of Nadathur and Miller =-=[9]-=- on higher-order logic programming. The datatype definition for Term differs from most in that in most lambda term representations, lambda abstractions are constructed by value constructors of type va... |

112 | A fold for all seasons
- Sheard, Fegaras
- 1993
(Show Context)
Citation Context ...also been used by functional programmers as a medium in which programs can be calculated from specifications [7, 6, 5] and as a good intermediate representation of programs that supports optimization =-=[14, 3, 4, 1]-=-. It is, thus, truly ironic that these functions apply only to first order datatypes. Until recently, it was not known how to express catamorphisms for datatypes with embedded function types. The work... |

110 |
Elements of Functional Programming
- READE
- 1989
(Show Context)
Citation Context ...uage is to use a vector of adjacency lists. But, this approach is not really different from using pointers in a procedural language, since permits ad-hoc constructions and manipulations of graphs. In =-=[13]-=- a graph type is defined as: datatype ff graph = Graph of ff ! ff list Here a graph consists of a function that computes the successors of each node. This definition requires special care while progra... |

105 |
Data structures and program transformation
- Malcolm
- 1990
(Show Context)
Citation Context ... as an elegant means of expressing algorithms over algebraic datatypes. Catamorphisms have also been used by functional programmers as a medium in which programs can be calculated from specifications =-=[7, 6, 5]-=- and as a good intermediate representation of programs that supports optimization [14, 3, 4, 1]. It is, thus, truly ironic that these functions apply only to first order datatypes. Until recently, it ... |

95 | Bananas in space: extending fold and unfold to exponential types
- Meijer, Hutton
- 1995
(Show Context)
Citation Context ... functions apply only to first order datatypes. Until recently, it was not known how to express catamorphisms for datatypes with embedded function types. The work by Paterson [10] and Meijer & Hutton =-=[8]-=- finally provided a method for doing so. While elegant and theoretically sound, their solution suffers from the disadvantage of being somewhat inefficient. This paper extends their technique using a s... |

35 |
Homomorphisms and promotability
- Malcolm
- 1989
(Show Context)
Citation Context ... as an elegant means of expressing algorithms over algebraic datatypes. Catamorphisms have also been used by functional programmers as a medium in which programs can be calculated from specifications =-=[7, 6, 5]-=- and as a good intermediate representation of programs that supports optimization [14, 3, 4, 1]. It is, thus, truly ironic that these functions apply only to first order datatypes. Until recently, it ... |

25 | Improving programs which recurse over multiple inductive structures
- Fegaras, Sheard, et al.
- 1994
(Show Context)
Citation Context ...also been used by functional programmers as a medium in which programs can be calculated from specifications [7, 6, 5] and as a good intermediate representation of programs that supports optimization =-=[14, 3, 4, 1]-=-. It is, thus, truly ironic that these functions apply only to first order datatypes. Until recently, it was not known how to express catamorphisms for datatypes with embedded function types. The work... |

11 | O.: Solving Optimisation Problems with Catamorphisms
- Bird, Moor
(Show Context)
Citation Context ...also been used by functional programmers as a medium in which programs can be calculated from specifications [7, 6, 5] and as a good intermediate representation of programs that supports optimization =-=[14, 3, 4, 1]-=-. It is, thus, truly ironic that these functions apply only to first order datatypes. Until recently, it was not known how to express catamorphisms for datatypes with embedded function types. The work... |

1 |
Control Structures from Types. Unpublished draft. Available by anonymous ftp from ftp-ala.doc.ic.ac.uk/pub/papers/R.Paterson/folds.dvi
- Paterson
- 1994
(Show Context)
Citation Context ..., truly ironic that these functions apply only to first order datatypes. Until recently, it was not known how to express catamorphisms for datatypes with embedded function types. The work by Paterson =-=[10]-=- and Meijer & Hutton [8] finally provided a method for doing so. While elegant and theoretically sound, their solution suffers from the disadvantage of being somewhat inefficient. This paper extends t... |

1 | Control Structures from Types. Submitted to - Paterson - 1994 |