## Polytypic programming (2000)

### Cached

### Download Links

- [www.cs.chalmers.se]
- [www.cs.uu.nl]
- [www.math.chalmers.se]
- DBLP

### Other Repositories/Bibliography

Citations: | 93 - 12 self |

### BibTeX

@MISC{Jansson00polytypicprogramming,

author = {Patrik Jansson},

title = {Polytypic programming},

year = {2000}

}

### Years of Citing Articles

### OpenURL

### Abstract

... PolyP extends a functional language (a subset of Haskell) with a construct for defining polytypic functions by induction on the structure of user-defined datatypes. Programs in the extended language are translated to Haskell. PolyLib contains powerful structured recursion operators like catamorphisms, maps and traversals, as well as polytypic versions of a number of standard functions from functional programming: sum, length, zip, (==), (6), etc. Both the specification of the library and a PolyP implementation are presented.

### Citations

5948 |
Design Patterns: Elements of Reusable Object-Oriented Software
- Gamma, Helm, et al.
- 1994
(Show Context)
Citation Context ...], and Jansson and Jeuring [16]. Our extension of Haskell is based on the type system described in [16]. In object-oriented programming polytypic programming appears under the names `design patterns' =-=[12]-=-, and `adaptive object-oriented programming' [27, 36]. In adaptive object-oriented programming methods are attached to groups of classes that usually satisfy certain constraints. The adaptive object-o... |

1354 | Introduction to Functional Programming
- Bird
- 1998
(Show Context)
Citation Context ...ee, amongst others, Lehmann and Smyth [26], Manes and Arbib [29], and Hagino [13]. Polytypic functions are widely used in the Squiggol community, see [10, 28, 30, 31, 33], where the `Theory of Lists' =-=[4, 5, 19]-=- is extended to datatypes that can be defined by means of a regular functor. The polytypic functions used in Squiggol are general recursive combinators such as catamorphisms (generalised folds), param... |

582 | Term rewriting systems
- Klop
- 1992
(Show Context)
Citation Context ...ose we want to write a term rewriting module. An example of a term rewriting system is the algebra of numbers constructed with Zero, Succ, :+:, and :*:, together with the following term rewrite rules =-=[24]-=-. x :+: Zero -? x x :+: Succ y -? Succ (x :+: y) x :*: Zero -? Zero x :*: Succ y -? (x :*: y) :+: x where x and y are variables. For confluent and normalising term rewriting systems, the relation !, w... |

467 | Comprehending monads - Wadler - 1990 |

424 | Deforestation: Transforming programs to eliminate trees - Wadler - 1990 |

381 |
Types, abstraction and parametric polymorphism
- Reynolds
- 1983
(Show Context)
Citation Context ... in Section 5 for a function that behaves differently for different constructor names. 4 Parametricity for polytypic functions In `Theorems for free!' [44], Wadler shows how the parametricity theorem =-=[37]-=- can be used to construct `free theorems' for polymorphic functions. This free theorem is obtained by just looking at the type of the function. For example, function head of type [a] -? a satisfies th... |

345 | Denotational semantics: A methodology for language development - Schmidt - 1988 |

339 | Theorems for free
- Wadler
- 1989
(Show Context)
Citation Context ... under which intermediate values produced by the catamorphism can be eliminated. h \Delta cata f = cata g ( (Fusion) h \Delta f = g \Delta fmap id h Fusion is a direct consequence of the free theorem =-=[44]-=- of the functional cata. It can also be proved using induction over lists. If we allow partial or infinite lists we get the extra requirement that h be strict. We use Fusion to prove that the composit... |

308 | Functional programming with bananas, lenses, envelopes and barbed wire
- Meijer, Paterson
- 1991
(Show Context)
Citation Context ...ell that can be used in the deriving construct, and users cannot add new classes to be used in it. The functions in these classes are easily written as polytypic functions. -- Implementing Squiggol's =-=[28, 30, 31, 33]-=- general purpose datatype independent functions such as cata, map, zip, para etc. -- Implementing general purpose, datatype independent programs for unification [14, 15], pattern matching [20], data c... |

262 | The Standard Template Library - Stepanov, Lee - 1995 |

221 | An introduction to the theory of lists
- Bird
- 1987
(Show Context)
Citation Context ...ee, amongst others, Lehmann and Smyth [26], Manes and Arbib [29], and Hagino [13]. Polytypic functions are widely used in the Squiggol community, see [10, 28, 30, 31, 33], where the `Theory of Lists' =-=[4, 5, 19]-=- is extended to datatypes that can be defined by means of a regular functor. The polytypic functions used in Squiggol are general recursive combinators such as catamorphisms (generalised folds), param... |

112 | Unification: "A Multidisciplinary Survey
- Knight
- 1989
(Show Context)
Citation Context ...for the variables such that the two expressions are equal after performing the substitution. Use of unification is widespread, such as in type inference algorithms, rewriting systems, compilers, etc. =-=[25]-=-. The datatypes of the expressions to be unified in the different examples are all different, so a polytypic unification function is desirable. This section describes a polytypic unification algorithm... |

107 |
Data structures and program transformation
- Malcolm
- 1990
(Show Context)
Citation Context ...ell that can be used in the deriving construct, and users cannot add new classes to be used in it. The functions in these classes are easily written as polytypic functions. -- Implementing Squiggol's =-=[28, 30, 31, 33]-=- general purpose datatype independent functions such as cata, map, zip, para etc. -- Implementing general purpose, datatype independent programs for unification [14, 15], pattern matching [20], data c... |

99 |
and Order in Algorithms
- Law
- 1992
(Show Context)
Citation Context ...a, on which a large amount of literature exists, see, amongst others, Lehmann and Smyth [26], Manes and Arbib [29], and Hagino [13]. Polytypic functions are widely used in the Squiggol community, see =-=[10, 28, 30, 31, 33]-=-, where the `Theory of Lists' [4, 5, 19] is extended to datatypes that can be defined by means of a regular functor. The polytypic functions used in Squiggol are general recursive combinators such as ... |

96 | Bananas in Space: Extending Fold and Unfold to Exponential Types
- Meijer, Hutton
- 1995
(Show Context)
Citation Context ...ns all conventional recursive datatypes, such as Int, List a, and different kinds of trees. Polytypic functions can be defined on a larger class of datatypes, including datatypes with function spaces =-=[32, 11]-=-, but regular datatypes suffice for our purposes. 1.5 Background and related work The basic idea behind polytypic programming is the idea of modelling datatypes as initial functor-algebras. This is a ... |

93 | Shortcut deforestation in calculational form
- Takano, Meijer
- 1995
(Show Context)
Citation Context ...e type of a function. Some free theorems have proven to be very useful in transforming programs, such as for example the fusion law [28], the free theorem of function foldr, and the acid-rain theorem =-=[43]-=-. In this paper we have generalised function length to the function size of type Mu f a -? Int. From the type of function size we can derive the following free theorem: size = size . pmap f where pmap... |

90 |
Algebraic approaches to program semantics
- Arbib, Manes
- 1986
(Show Context)
Citation Context ... the idea of modelling datatypes as initial functor-algebras. This is a relatively old idea, on which a large amount of literature exists, see, amongst others, Lehmann and Smyth [26], Manes and Arbib =-=[29]-=-, and Hagino [13]. Polytypic functions are widely used in the Squiggol community, see [10, 28, 30, 31, 33], where the `Theory of Lists' [4, 5, 19] is extended to datatypes that can be defined by means... |

78 | Adaptive object-oriented programming using graph-based customization
- Lieberherr, Silva-Lepe, et al.
- 1994
(Show Context)
Citation Context ... Haskell is based on the type system described in [16]. In object-oriented programming polytypic programming appears under the names `design patterns' [12], and `adaptive object-oriented programming' =-=[27, 36]-=-. In adaptive object-oriented programming methods are attached to groups of classes that usually satisfy certain constraints. The adaptive object-oriented programming style is very different from poly... |

74 | Functional programming with overloading and higher-order polymorphism
- Jones
- 1995
(Show Context)
Citation Context ...re, different people will use different universal datatypes, which will make program reuse more difficult. If we use higher-order polymorphism and constructor classes for defining polytypic functions =-=[22, 15]-=-, type information is preserved, and we can use current functional languages such as Gofer and Haskell for implementing polytypic functions. However, writing such programs is rather cumbersome: progra... |

70 |
Recursive types reduced to inductive types
- Freyd
- 1990
(Show Context)
Citation Context ...ns all conventional recursive datatypes, such as Int, List a, and different kinds of trees. Polytypic functions can be defined on a larger class of datatypes, including datatypes with function spaces =-=[32, 11]-=-, but regular datatypes suffice for our purposes. 1.5 Background and related work The basic idea behind polytypic programming is the idea of modelling datatypes as initial functor-algebras. This is a ... |

64 | Efcient implementation of adaptive software
- Palsberg, Xiao, et al.
- 1995
(Show Context)
Citation Context ... Haskell is based on the type system described in [16]. In object-oriented programming polytypic programming appears under the names `design patterns' [12], and `adaptive object-oriented programming' =-=[27, 36]-=-. In adaptive object-oriented programming methods are attached to groups of classes that usually satisfy certain constraints. The adaptive object-oriented programming style is very different from poly... |

63 | A semantics for shape
- Jay
- 1995
(Show Context)
Citation Context ...first given by Bird et al. [3] and Jeuring [20]. Special purpose polytypic functions such as the generalised version of function length and the operator (==) can be found in [30, 34, 35, 40, 14]. Jay =-=[18]-=- has developed an alternative theory for polytypic functions, in which values are represented by their structure and their contents. Type systems for languages with constructs for writing polytypic fu... |

56 | Revisiting catamorphisms over datatypes with embedded functions (or, Programs from outer space
- Fegaras, Sheard
- 1996
(Show Context)
Citation Context ...ll elements from the list that do not satisfy p, by means of function cata. (end of exercise) Exercise Haskell's list selection operation as !! n selects the n-th element of the list as, for example, =-=[1,9,9,5]-=- !! 3 = 5. Using explicit recursion it reads: (!!) :: [a] -? Int -? a (a: )!!0 = a (:as)!!(n+1) = as!!n Give an equivalent definition of (!!) on the datatype Mu FList a using cata. Note that the resul... |

50 | Merging monads and folds for functional programming
- Meijer, Jeuring
- 1995
(Show Context)
Citation Context ...ell that can be used in the deriving construct, and users cannot add new classes to be used in it. The functions in these classes are easily written as polytypic functions. -- Implementing Squiggol's =-=[28, 30, 31, 33]-=- general purpose datatype independent functions such as cata, map, zip, para etc. -- Implementing general purpose, datatype independent programs for unification [14, 15], pattern matching [20], data c... |

44 |
Automatic synthesis of typed #-programs on term algebras
- ohm, Berarducci
- 1985
(Show Context)
Citation Context ...a regular functor. The polytypic functions used in Squiggol are general recursive combinators such as catamorphisms (generalised folds), paramorphisms, maps, etc. Sheard [42], and Bohm and Berarducci =-=[2]-=- give programs that automatically synthesise these functions. In the language Charity [6] polytypic functions like the catamorphism and map are automatically provided for each user-defined datatype. P... |

37 |
Algebraic specifications of data types: a synthetic approach
- Lehmann, Smyth
- 1981
(Show Context)
Citation Context ...lytypic programming is the idea of modelling datatypes as initial functor-algebras. This is a relatively old idea, on which a large amount of literature exists, see, amongst others, Lehmann and Smyth =-=[26]-=-, Manes and Arbib [29], and Hagino [13]. Polytypic functions are widely used in the Squiggol community, see [10, 28, 30, 31, 33], where the `Theory of Lists' [4, 5, 19] is extended to datatypes that c... |

32 |
Category theoretic approach to data types
- Hagino
- 1987
(Show Context)
Citation Context ...lling datatypes as initial functor-algebras. This is a relatively old idea, on which a large amount of literature exists, see, amongst others, Lehmann and Smyth [26], Manes and Arbib [29], and Hagino =-=[13]-=-. Polytypic functions are widely used in the Squiggol community, see [10, 28, 30, 31, 33], where the `Theory of Lists' [4, 5, 19] is extended to datatypes that can be defined by means of a regular fun... |

31 |
O.: Categories, relations and dynamic programming
- Moor
- 1992
(Show Context)
Citation Context ...ern matching problem were first given by Bird et al. [3] and Jeuring [20]. Special purpose polytypic functions such as the generalised version of function length and the operator (==) can be found in =-=[30, 34, 35, 40, 14]-=-. Jay [18] has developed an alternative theory for polytypic functions, in which values are represented by their structure and their contents. Type systems for languages with constructs for writing po... |

28 | Polytypic pattern matching
- Jeuring
- 1995
(Show Context)
Citation Context ... polymorphic in a, but also in the type constructor; we want to be able to write something like length :: D a -? Int, where D ranges over type constructors. We call such functions polytypic functions =-=[20]-=-. Once we have a polytypic length function, function length can be applied to values of any datatype. If a datatype is changed, length still behaves as expected. For example, the datatype List a has t... |

25 |
Automatic Generation and Use of Abstract Structure Operators
- Sheard
- 1991
(Show Context)
Citation Context ...at can be defined by means of a regular functor. The polytypic functions used in Squiggol are general recursive combinators such as catamorphisms (generalised folds), paramorphisms, maps, etc. Sheard =-=[42]-=-, and Bohm and Berarducci [2] give programs that automatically synthesise these functions. In the language Charity [6] polytypic functions like the catamorphism and map are automatically provided for ... |

19 |
Polytypic unification
- Jansson, Jeuring
- 1998
(Show Context)
Citation Context ...mplementing Squiggol's [28, 30, 31, 33] general purpose datatype independent functions such as cata, map, zip, para etc. -- Implementing general purpose, datatype independent programs for unification =-=[14, 15]-=-, pattern matching [20], data compression [21], etc. 1.4 Writing polytypic programs There exist various ways to implement polytypic programs. Three possibilities are: -- using a universal datatype; --... |

16 |
Analytical and Structural Polymorphism Expressed Using Patterns Over Types
- Ruehr
- 1992
(Show Context)
Citation Context ...pic functions, in which values are represented by their structure and their contents. Type systems for languages with constructs for writing polytypic functions have been developed by Jay [17], Ruehr =-=[38, 39]-=-, Sheard and Nelson [41], and Jansson and Jeuring [16]. Our extension of Haskell is based on the type system described in [16]. In object-oriented programming polytypic programming appears under the n... |

16 | Type safe abstractions using program generators
- Sheard, Nelson
(Show Context)
Citation Context ...es are represented by their structure and their contents. Type systems for languages with constructs for writing polytypic functions have been developed by Jay [17], Ruehr [38, 39], Sheard and Nelson =-=[41]-=-, and Jansson and Jeuring [16]. Our extension of Haskell is based on the type system described in [16]. In object-oriented programming polytypic programming appears under the names `design patterns' [... |

11 | Polynomial polymorphism
- Jay
- 1995
(Show Context)
Citation Context ...y for polytypic functions, in which values are represented by their structure and their contents. Type systems for languages with constructs for writing polytypic functions have been developed by Jay =-=[17]-=-, Ruehr [38, 39], Sheard and Nelson [41], and Jansson and Jeuring [16]. Our extension of Haskell is based on the type system described in [16]. In object-oriented programming polytypic programming app... |

11 | Algorithms from theorems
- Jeuring
- 1990
(Show Context)
Citation Context ...ee, amongst others, Lehmann and Smyth [26], Manes and Arbib [29], and Hagino [13]. Polytypic functions are widely used in the Squiggol community, see [10, 28, 30, 31, 33], where the `Theory of Lists' =-=[4, 5, 19]-=- is extended to datatypes that can be defined by means of a regular functor. The polytypic functions used in Squiggol are general recursive combinators such as catamorphisms (generalised folds), param... |

11 | Polytypic proof construction - Pfeifer, Ruess - 1999 |

3 |
Polytypic unification --- implementing polytypic functions with constructor classes
- Jansson, Jeuring
- 1996
(Show Context)
Citation Context ...mplementing Squiggol's [28, 30, 31, 33] general purpose datatype independent functions such as cata, map, zip, para etc. -- Implementing general purpose, datatype independent programs for unification =-=[14, 15]-=-, pattern matching [20], data compression [21], etc. 1.4 Writing polytypic programs There exist various ways to implement polytypic programs. Three possibilities are: -- using a universal datatype; --... |

3 |
Type inference for polytypic functions
- Jansson, Jeuring
- 1996
(Show Context)
Citation Context ...l with mutual recursive datatypes. Since the first two solutions to writing polytypic functions are dissatisfying, we have extended Haskell with a syntactic construct for defining polytypic functions =-=[16]-=-. Thus polytypic functions can be implemented and type checked. The resulting language is called Polyp. Consult the page http://www.cs.chalmers.se/~johanj/polytypism/ to obtain a compiler that compile... |

2 |
A polytypic rewriting system
- Berglund
- 1996
(Show Context)
Citation Context ...ll elements from the list that do not satisfy p, by means of function cata. (end of exercise) Exercise Haskell's list selection operation as !! n selects the n-th element of the list as, for example, =-=[1,9,9,5]-=- !! 3 = 5. Using explicit recursion it reads: (!!) :: [a] -? Int -? a (a: )!!0 = a (:as)!!(n+1) = as!!n Give an equivalent definition of (!!) on the datatype Mu FList a using cata. Note that the resul... |

2 |
Oege de Moor, and Paul Hoogendijk. Generic programming with relations and functors
- Bird
- 1993
(Show Context)
Citation Context ...omatically provided for each user-defined datatype. Polytypic functions for specific problems, such as the maximum segment sum problem and the pattern matching problem were first given by Bird et al. =-=[3]-=- and Jeuring [20]. Special purpose polytypic functions such as the generalised version of function length and the operator (==) can be found in [30, 34, 35, 40, 14]. Jay [18] has developed an alternat... |

2 |
About charity. Unpublished article, see http://www.cpsc.ucalgary.ca/projects/charity/home.html
- Cockett, Fukushima
- 1992
(Show Context)
Citation Context ...tors such as catamorphisms (generalised folds), paramorphisms, maps, etc. Sheard [42], and Bohm and Berarducci [2] give programs that automatically synthesise these functions. In the language Charity =-=[6]-=- polytypic functions like the catamorphism and map are automatically provided for each user-defined datatype. Polytypic functions for specific problems, such as the maximum segment sum problem and the... |

2 |
et al. Domains and denotational semantics: History, accomplishments and open problems. Available via WWW: http://www.cs.bham.ac.uk/~axj/papers.html
- Fiore
- 1996
(Show Context)
Citation Context ...latten Function flatten takes a value v of a datatype Mu f a, and returns the list containing all elements of type a occurring in v. For example, flatten (Bin (Bin (Leaf 1) (Leaf 3)) (Leaf 7)) equals =-=[1,3,7]-=-. This function is the central function in Jay's [18] representation of values of shapely types: a value of a shapely type is represented by its contents, obtained by flattening the value, and its str... |

2 | Polytypic data compression
- Jeuring
- 1997
(Show Context)
Citation Context ...rpose datatype independent functions such as cata, map, zip, para etc. -- Implementing general purpose, datatype independent programs for unification [14, 15], pattern matching [20], data compression =-=[21]-=-, etc. 1.4 Writing polytypic programs There exist various ways to implement polytypic programs. Three possibilities are: -- using a universal datatype; -- using higher-order polymorphism and construct... |

2 | Available via ftp on ftp.cs.nott.ac.uk - Gofer - 1995 |

2 |
Type parametric programming. Oregon Graduate Institute of Science and
- Sheard
- 1993
(Show Context)
Citation Context ...ern matching problem were first given by Bird et al. [3] and Jeuring [20]. Special purpose polytypic functions such as the generalised version of function length and the operator (==) can be found in =-=[30, 34, 35, 40, 14]-=-. Jay [18] has developed an alternative theory for polytypic functions, in which values are represented by their structure and their contents. Type systems for languages with constructs for writing po... |

1 |
Analytical and structural polymorphism. Unpublished manuscript
- Ruehr
- 1992
(Show Context)
Citation Context ...pic functions, in which values are represented by their structure and their contents. Type systems for languages with constructs for writing polytypic functions have been developed by Jay [17], Ruehr =-=[38, 39]-=-, Sheard and Nelson [41], and Jansson and Jeuring [16]. Our extension of Haskell is based on the type system described in [16]. In object-oriented programming polytypic programming appears under the n... |

1 | Available from the Polytypic programming WWW - University, Gothenburg - 1997 |