Results 1 
5 of
5
A New Approach to Generic Functional Programming
 In The 27th Annual ACM SIGPLANSIGACT Symposium on Principles of Programming Languages
, 1999
"... This paper describes a new approach to generic functional programming, which allows us to define functions generically for all datatypes expressible in Haskell. A generic function is one that is defined by induction on the structure of types. Typical examples include pretty printers, parsers, and co ..."
Abstract

Cited by 96 (13 self)
 Add to MetaCart
This paper describes a new approach to generic functional programming, which allows us to define functions generically for all datatypes expressible in Haskell. A generic function is one that is defined by induction on the structure of types. Typical examples include pretty printers, parsers, and comparison functions. The advanced type system of Haskell presents a real challenge: datatypes may be parameterized not only by types but also by type constructors, type definitions may involve mutual recursion, and recursive calls of type constructors can be arbitrarily nested. We show that despite this complexitya generic function is uniquely defined by giving cases for primitive types and type constructors (such as disjoint unions and cartesian products). Given this information a generic function can be specialized to arbitrary Haskell datatypes. The key idea of the approach is to model types by terms of the simply typed calculus augmented by a family of recursion operators. While co...
De Bruijn notation as a nested datatype
 Journal of Functional Programming
, 1999
"... “I have no data yet. It is a capital mistake to theorise before one has data.” ..."
Abstract

Cited by 68 (2 self)
 Add to MetaCart
“I have no data yet. It is a capital mistake to theorise before one has data.”
Generalised Folds for Nested Datatypes
 Formal Aspects of Computing
, 1999
"... Nested datatypes generalise regular datatypes in much the same way that contextfree languages generalise regular ones. Although the categorical semantics of nested types turns out to be similar to the regular case, the fold functions are more limited because they can only describe natural transform ..."
Abstract

Cited by 34 (1 self)
 Add to MetaCart
Nested datatypes generalise regular datatypes in much the same way that contextfree languages generalise regular ones. Although the categorical semantics of nested types turns out to be similar to the regular case, the fold functions are more limited because they can only describe natural transformations. Practical considerations therefore dictate the introduction of a generalised fold function in which this limitation can be overcome. In the paper we show how to construct generalised folds systematically for each nested datatype, and show that they possess a uniqueness property analogous to that of ordinary folds. As a consequence, generalised folds satisfy fusion properties similar to those developed for regular datatypes. Such properties form the core of an effective calculational theory of inductive datatypes.
Efficient Generalized Folds
, 1999
"... Fold operators capture a common recursion pattern over algebraic datatypes. A fold essentially replaces constructors by functions. However, if the datatype is parameterized, the corresponding fold operates on polymorphic functions which severely limits its applicability. In order to overcome this li ..."
Abstract

Cited by 11 (0 self)
 Add to MetaCart
Fold operators capture a common recursion pattern over algebraic datatypes. A fold essentially replaces constructors by functions. However, if the datatype is parameterized, the corresponding fold operates on polymorphic functions which severely limits its applicability. In order to overcome this limitation R. Bird and R. Paterson (Bird & Paterson, 1999b) have proposed socalled generalized folds. We show how to define a variation of these folds by induction on the structure of datatype definitions. Unfortunately, for some datatypes generalized folds are less efficient than one would expect. We identify the source of inefficiency and explain how to remedy this shortcoming. While conceptually simple, our approach places high demands on the type system: it requires polymorphic recursion, rank2 types, and a strong form of type constructor polymorphism. 1 Introduction Fold operators are in every functional programmer's toolbox. In essence, a fold operator replaces constructors by functi...
Perfect Trees and Bitreversal Permutations
, 1999
"... A famous algorithm is the Fast Fourier Transform, or FFT. An efficient iterative version of the FFT algorithm performs as a first step a bitreversal permutation of the input list. The bitreversal permutation swaps elements whose indices have binary representations that are the reverse of each othe ..."
Abstract

Cited by 4 (2 self)
 Add to MetaCart
A famous algorithm is the Fast Fourier Transform, or FFT. An efficient iterative version of the FFT algorithm performs as a first step a bitreversal permutation of the input list. The bitreversal permutation swaps elements whose indices have binary representations that are the reverse of each other. Using an amortized approach this operation can be made to run in linear time on a randomaccess machine. An intriguing question is whether a lineartime implementation is also feasible on a pointer machine, that is in a purely functional setting. We show that the answer to this question is in the affirmative. In deriving a solution we employ several advanced programming language concepts such as nested datatypes, associated fold and unfold operators, rank2 types, and polymorphic recursion. 1 Introduction A bitreversal permutation operates on lists whose length is n = 2 k for some natural number k and swaps elements whose indices have binary representations that are the reverse of eac...