Results 1  10
of
15
Polytypic Values Possess Polykinded Types
, 2000
"... A polytypic value is one that is defined by induction on the structure of types. In Haskell the type structure is described by the socalled kind system, which distinguishes between manifest types like the type of integers and functions on types like the list type constructor. Previous approaches to ..."
Abstract

Cited by 109 (19 self)
 Add to MetaCart
A polytypic value is one that is defined by induction on the structure of types. In Haskell the type structure is described by the socalled kind system, which distinguishes between manifest types like the type of integers and functions on types like the list type constructor. Previous approaches to polytypic programming were restricted in that they only allowed to parameterize values by types of one fixed kind. In this paper we show how to define values that are indexed by types of arbitrary kinds. It appears that these polytypic values possess types that are indexed by kinds. We present several examples that demonstrate that the additional exibility is useful in practice. One paradigmatic example is the mapping function, which describes the functorial action on arrows. A single polytypic definition yields mapping functions for datatypes of arbitrary kinds including first and higherorder functors. Polytypic values enjoy polytypic properties. Using kindindexed logical relations we prove...
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 99 (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...
A Generic Programming Extension for Clean
 The 13th International workshop on the Implementation of Functional Languages, IFL’01, Selected Papers, volume 2312 of LNCS
, 2002
"... Abstract. Generic programming enables the programmer to define functions by induction on the structure of types. Defined once, such a generic function can be used to generate a specialized function for any user defined data type. Several ways to support generic programming in functional languages ha ..."
Abstract

Cited by 58 (29 self)
 Add to MetaCart
(Show Context)
Abstract. Generic programming enables the programmer to define functions by induction on the structure of types. Defined once, such a generic function can be used to generate a specialized function for any user defined data type. Several ways to support generic programming in functional languages have been proposed, each with its own pros and cons. In this paper we describe a combination of two existing approaches, which has the advantages of both of them. In our approach overloaded functions with class variables of an arbitrary kind can be defined generically. A single generic definition defines a kindindexed family of overloaded functions, one for each kind. For instance, the generic mapping function generates an overloaded mapping function for each kind. Additionally, we propose a separate extension that allows to specify a customized instance of a generic function for a type in terms of the generated instance for that type. 1
Generalizing Generalized Tries
, 1999
"... A trie is a search tree scheme that employs the structure of search keys to organize information. Tries were originally devised as a means to represent a collection of records indexed by strings over a fixed alphabet. Based on work by C.P. Wadsworth and others, R.H. Connelly and F.L. Morris generali ..."
Abstract

Cited by 35 (8 self)
 Add to MetaCart
A trie is a search tree scheme that employs the structure of search keys to organize information. Tries were originally devised as a means to represent a collection of records indexed by strings over a fixed alphabet. Based on work by C.P. Wadsworth and others, R.H. Connelly and F.L. Morris generalized the concept to permit indexing by elements of an arbitrary monomorphic datatype. Here we go one step further and define tries and operations on tries generically for arbitrary firstorder polymorphic datatypes. The derivation is based on techniques recently developed in the context of polytypic programming. It is well known that for the implementation of generalized tries nested datatypes and polymorphic recursion are needed. Implementing tries for polymorphic datatypes places even greater demands on the type system: it requires rank2 type signatures and higherorder polymorphic nested datatypes. Despite these requirements the definition of generalized tries for polymorphic datatypes is...
Manufacturing Datatypes
, 1999
"... This paper describes a general framework for designing purely functional datatypes that automatically satisfy given size or structural constraints. Using the framework we develop implementations of different matrix types (eg square matrices) and implementations of several tree types (eg Braun trees, ..."
Abstract

Cited by 23 (3 self)
 Add to MetaCart
This paper describes a general framework for designing purely functional datatypes that automatically satisfy given size or structural constraints. Using the framework we develop implementations of different matrix types (eg square matrices) and implementations of several tree types (eg Braun trees, 23 trees). Consider, for instance, representing square n \Theta n matrices. The usual representation using lists of lists fails to meet the structural constraints: there is no way to ensure that the outer list and the inner lists have the same length. The main idea of our approach is to solve in a first step a related, but simpler problem, namely to generate the multiset of all square numbers. In order to describe this multiset we employ recursion equations involving finite multisets, multiset union, addition and multiplication lifted to multisets. In a second step we mechanically derive datatype definitions from these recursion equations which enforce the `squareness' constraint. The tra...
Memo Functions, Polytypically!
 Proceedings of the 2nd Workshop on Generic Programming, Ponte de
, 2000
"... . This paper presents a polytypic implementation of memo functions that are based on digital search trees. A memo function can be seen as the composition of a tabulation function that creates a memo table and a lookup function that queries the table. We show that tabulation can be derived from ..."
Abstract

Cited by 14 (4 self)
 Add to MetaCart
(Show Context)
. This paper presents a polytypic implementation of memo functions that are based on digital search trees. A memo function can be seen as the composition of a tabulation function that creates a memo table and a lookup function that queries the table. We show that tabulation can be derived from lookup by inverse function construction. The type of memo tables is dened by induction on the structure of argument types and is parametric with respect to the result type of memo functions. A memo table for a xed argument type is then a functor and lookup and tabulation are natural isomorphisms. We provide simple polytypic proofs of these properties. 1 Introduction A memo function [11] is like an ordinary function except that it caches previously computed values. If it is applied a second time to a particular argument, it immediately returns the cached result, rather than recomputing it. For storing arguments and results a memo function internally employs an index structure, the ...
Container Types Categorically
, 2000
"... A program derivation is said to be polytypic if some of its parameters are data types. Often these data types are container types, whose elements store data. Polytypic program derivations necessitate a general, noninductive definition of `container (data) type'. Here we propose such a definiti ..."
Abstract

Cited by 13 (0 self)
 Add to MetaCart
A program derivation is said to be polytypic if some of its parameters are data types. Often these data types are container types, whose elements store data. Polytypic program derivations necessitate a general, noninductive definition of `container (data) type'. Here we propose such a definition: a container type is a relator that has membership. It is shown how this definition implies various other properties that are shared by all container types. In particular, all container types have a unique strength, and all natural transformations between container types are strong. Capsule Review Progress in a scientific dicipline is readily equated with an increase in the volume of knowledge, but the true milestones are formed by the introduction of solid, precise and usable definitions. Here you will find the first generic (`polytypic') definition of the notion of `container type', a definition that is remarkably simple and suitable for formal generic proofs (as is amply illustrated in t...
Yet Another Generic Haskell
"... In previous work, we invented the notion of functional strategies, that is, firstclass generic functions which can traverse into terms of any type while mixing uniform and typespecific behaviour. In the present paper, we reconstruct functional strategies in Haskell in an extremely compact style re ..."
Abstract
 Add to MetaCart
In previous work, we invented the notion of functional strategies, that is, firstclass generic functions which can traverse into terms of any type while mixing uniform and typespecific behaviour. In the present paper, we reconstruct functional strategies in Haskell in an extremely compact style relying on just two combinators: adhoc for typebased function dispatch, and hfoldr for folding over constructor applications. This reconstruction constitutes yet another way to turn Haskell into a (more) generic programming language. Our approach is lightweight (both for language users and implementors) , highly expressive, wellfounded, and has already proven its value in important application domains.