## Distinguishing Data Structures and Functions: the Constructor Calculus and Functorial Types (2001)

Venue: | Typed Lambda Calculi and Applications: 5th International Conference TLCA 2001 |

Citations: | 8 - 1 self |

### BibTeX

@INPROCEEDINGS{Jay01distinguishingdata,

author = {C. Barry Jay},

title = {Distinguishing Data Structures and Functions: the Constructor Calculus and Functorial Types},

booktitle = {Typed Lambda Calculi and Applications: 5th International Conference TLCA 2001},

year = {2001},

pages = {217--239},

publisher = {Springer-Verlag}

}

### OpenURL

### Abstract

The expressive power of functional programming can be improved by identifying and exploiting the characteristics that distinguish data types from function types. Data types support generic functions for equality, mapping, folding, etc. that do not apply to functions. Such generic functions require case analysis, or pattern-matching, where the branches may have incompatible types, e.g. products or sums. This is handled in the constructor calculus where specialisation of program extensions is governed by constructors for data types. Typing of generic functions employs polymorphism over functors in a functorial type system. The expressive power is greatly increased by allowing the functors to be polymorphic in the number of arguments they take, i.e. in their arities. The resulting system can define and type the fundamental examples above. Some basic properties are established, namely subject reduction, the Church-Rosser property, and the existence of a practical type inference algorithm.

### Citations

1658 | The Definition of Standard ML
- Milner, Tofte, et al.
- 1990
(Show Context)
Citation Context ...s but are familiar terms that will serve here to illustrate the principles. The actual program for equality is given in Figure 6. Some such algorithm is supported by the equality types in Standard ML =-=[MT91]-=-. It is not, however, typable as a program in ML because the patterns for un, pair and inl have incompatible types. Generic pattern-matching must be able to branch on any constructor, of any type. Thi... |

1008 | A theory of type polymorphism in programming
- Milner
- 1978
(Show Context)
Citation Context ...ity substitution oe : A ! A 0 such that oek = k 0 . Theorem 2. If an unkinded functor F has a kinding then it has a principal kinding. Proof. The kind inference algorithm W follows Milner's algorithm =-=[Mil78]-=-. Algorithm W takes a four-tuple (A; \Delta; F; k) and tries to produce an arity substitutionsoe : A ! A 0 such that A 0 ; oe\Delta ` F :: oek. We initialise the choices of A; \Delta and k with fresh ... |

394 |
Types, abstraction, and parametric polymorphism
- Reynolds
- 1983
(Show Context)
Citation Context ... F; G : C ! D is given by a family of arrows ff X : FX ! GX indexed by the objects of C such that for each arrow f : X ! Y of C we have Gf:ff X = ff Y :F f . This is a kind of parametricity condition =-=[Rey85]-=-. The definition of the exponential, or function object, in a category can be generalised to define an object in D that represents the natural transformations from F to G [Jay96]. Thus, if F; G :: m !... |

313 | Functional programming with bananas, lenses, envelopes and barbed wire
- Meijer, Fokkinga, et al.
- 1991
(Show Context)
Citation Context ...ata manipulation, so that any improvement here can have a major impact on the size of programs and the cost of their construction. Most treatments of generic programming either focus on the semantics =-=[MFP91]-=-, or use type information to drive the evaluation [JJ97,Jan00,Hin00]. Functorial ML (fml) [JBM98] showed how evaluation could be achieved parametrically, without reference to types, but was unable to ... |

268 |
Combinatory Reduction Systems
- Klop
- 1980
(Show Context)
Citation Context ...rules for specialisation can be viewed as a finite family of rules, one for each constructor c. Then all the reduction rules are left-linear and non-overlapping, so we can apply Klop's general result =-=[Klo80]-=-. 6 Exceptions Any account of data types must address the issue of missing data. For example, taking the head of an empty list. In imperative languages this often results in a void pointer. In pointer... |

196 |
Initial algebra semantics and continuous algebras
- Goguen, Thatcher, et al.
- 1977
(Show Context)
Citation Context ...t when applying them. 1.2 Functorial types Now let us consider the the data types. It has long been recognised that data types can be understood semantically as the application of a functor to a type =-=[Ga77]-=-. Very briefly, a functor F : C ! D between categories C and D sends each arrow (or function) f : X ! Y of C to an arrow Ff : FX ! FY of D in a way that preserves composition of arrows and their ident... |

183 | PolyP - a polytypic programming language extension - Jansson, Jeuring - 1997 |

137 | Type inference with polymorphic recursion
- Henglein
- 1993
(Show Context)
Citation Context ...ate classes. In other words, data types cannot here be reduced to functions and quantification. Also, the presence of polymorphic recursion means that not every term will have a principal type scheme =-=[Hen93]-=-. As constructors are required to have them it follows that constructors must be distinguishable from terms in general. Concerning type inference, we shall see that there is powerful and practical typ... |

99 | Dynamic typing in polymorphic languages - Abadi, Cardelli, et al. - 1992 |

96 | A new approach to generic functional programming - Hinze - 2000 |

95 | Polytypic programming - Jeuring, Jansson - 1996 |

91 |
The effective topos
- Hyland
- 1981
(Show Context)
Citation Context ...s of these syntactic functors is defined as follows. Let D be a cartesian closed locos [Coc90,Jay95b]. These include all toposes that have a natural numbers object, such as Set or the effective topos =-=[Hyl82]-=-, and also categories used in domain theory such as !-complete partial orders. They can be thought of as a minimal setting in which both lists and functions are definable. Each closed functor F :: m !... |

67 | A semantics for shape
- Jay
- 1995
(Show Context)
Citation Context ...lgebras and objects of natural transformations. For this it suffices that the semantic functors be shapely over lists. They are closed under all the required constructions, including initial algebras =-=[Jay95b]-=- and objects of natural transformations [Jay96]. The denotational semantics of the type schemes has not yet been developed but should prove amenable to the methods developed for fml[JBM98]. 3.2 Kind i... |

16 | List-arithmetic distributive categories: Locoi - Cockett - 1990 |

11 | Polynomial polymorphism - Jay - 1995 |

7 | Data categories
- Jay
- 1996
(Show Context)
Citation Context ...rametricity condition [Rey85]. The definition of the exponential, or function object, in a category can be generalised to define an object in D that represents the natural transformations from F to G =-=[Jay96]-=-. Thus, if F; G :: m ! n are functors in our system then F ! G : 0 ! n is the functor of functions from F to G. When m is not necessarily 0 we may call this the functor of natural transformations from... |

1 |
Report on the functional programming language Haskell: version 1.4
- Augustsson, all
- 1997
(Show Context)
Citation Context ...types. If these contribute new constructors then it is not at all clear how generic functions can be applied to them without additional coding. For example, when a new data type is defined in Haskell =-=[Aa97]-=- then the various fragments of code required for mapping, etc. are added by the programmer. This is better than re-defining the whole function but it is still something less than full genericity. ? \G... |