Results 1  10
of
10
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 94 (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...
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 31 (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...
Embedded Interpreters
 UNDER CONSIDERATION FOR PUBLICATION IN J. FUNCTIONAL PROGRAMMING
, 2003
"... This is a tutorial on using typeindexed embedding/projection pairs when writing interpreters in staticallytyped functional languages. The method allows (higherorder) values in the interpreting language to be embedded in the interpreted language and values from the interpreted language may be proj ..."
Abstract

Cited by 19 (1 self)
 Add to MetaCart
This is a tutorial on using typeindexed embedding/projection pairs when writing interpreters in staticallytyped functional languages. The method allows (higherorder) values in the interpreting language to be embedded in the interpreted language and values from the interpreted language may be projected back into the interpreting one. This is particularly useful when adding commandline interfaces or scripting languages to applications written in functional languages. We first
FUNCTIONAL PEARLS  Polytypic Unification
 Journal of Functional Programming
, 1998
"... Unification, or twoway pattern matching, is the process of solving an equation involving two firstorder terms with variables. Unification is used in type inference in many programming languages and in the execution of logic programs. This means that unification algorithms have to be written over a ..."
Abstract

Cited by 13 (3 self)
 Add to MetaCart
Unification, or twoway pattern matching, is the process of solving an equation involving two firstorder terms with variables. Unification is used in type inference in many programming languages and in the execution of logic programs. This means that unification algorithms have to be written over and over again for different termtypes. Many other functions also make sense for a large class of datatypes  examples are pretty printers, equality checks, maps etc. They can be defined by induction on the structure of userdefined datatypes. Implementations of these functions for different datatypes are closely related to the structure of the datatypes. We call such functions polytypic. This paper describes a unification algorithm parametrised on the type of the terms and shows how to use polytypism to obtain a unification algorithm that works for all regular term types.
Polytypic Programming With Ease
, 1999
"... A functional polytypic program is one that is parameterised by datatype. Since polytypic functions are defined by induction on types rather than by induction on values they typically operate on a higher level of abstraction than their monotypic counterparts. However, polytypic programming is not nec ..."
Abstract

Cited by 13 (5 self)
 Add to MetaCart
A functional polytypic program is one that is parameterised by datatype. Since polytypic functions are defined by induction on types rather than by induction on values they typically operate on a higher level of abstraction than their monotypic counterparts. However, polytypic programming is not necessarily more complicated than conventional programming. We show that a polytypic function is uniquely defined by its action on constant functors, projection functors, sums, and products. This information is sufficient to specialize a polytypic function to arbitrary polymorphic datatypes, including mutually recursive datatypes and nested datatypes. The key idea is to use infinite trees as index sets for polytypic functions and to interpret datatypes as algebraic trees. This approach appears both to be simpler, more general, and more efficient than previous ones which are based on the initial algebra semantics of datatypes. Polytypic functions enjoy polytypic properties. We show that wellkno...
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 definition: a ..."
Abstract

Cited by 12 (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...
Twolevel types and parameterized modules
 Journal of Functional Programming
, 2003
"... In this paper, we describe two techniques for the efficient, modularized implementation of a large class of algorithms. We illustrate these techniques using several examples, including efficient generic unification algorithms that use reference cells to encode substitutions, and highly modular langu ..."
Abstract

Cited by 8 (0 self)
 Add to MetaCart
In this paper, we describe two techniques for the efficient, modularized implementation of a large class of algorithms. We illustrate these techniques using several examples, including efficient generic unification algorithms that use reference cells to encode substitutions, and highly modular language implementations. We chose these examples to illustrate the following important techniques that we believe many functional programmers would find useful. First, defining recursive data types by splitting them into two levels: a structure defining level, and a recursive knottying level. Second, the use of rank2 polymorphism inside Haskellâ€™s record types to implement a kind of typeparameterized modules. Finally, we explore techniques that allow us to combine already existing recursive Haskell datatypes with the highly modular style of programming proposed here. 1
Functorial ML
, 1998
"... We present an extension of the HindleyMilner type system that supports a generous class of type constructors called functors, and provide a parametrically polymorphic algorithm for their mapping, i.e. for applying a function to each datum appearing in a value of constructed type. The algorithm come ..."
Abstract
 Add to MetaCart
We present an extension of the HindleyMilner type system that supports a generous class of type constructors called functors, and provide a parametrically polymorphic algorithm for their mapping, i.e. for applying a function to each datum appearing in a value of constructed type. The algorithm comes from shape theory, which provides a uniform method for locating data within a shape. The resulting system is ChurchRosser and strongly normalizing, and supports type inference. Several dierent semantics are possible, which aects the choice of constants in the language, and are used to illustrate the relationship to polytypic programming. Capsule Review A wide class of type constructors (functions producing types from types) used in functional programming are functorial, in the sense that they can be extended to mappings from functions to functions satisfying a few simple laws. The `map' functional for lists is the prototypic example. Moreover, this additional structure for type constru...
Polytypic Unification
, 1993
"... Unification, or twoway pattern matching, is the process of solving an equation involving two firstorder terms with variables. Unification is used in type inference in many programming languages and in the execution of logic programs. This means that unification algorithms have to be written over a ..."
Abstract
 Add to MetaCart
Unification, or twoway pattern matching, is the process of solving an equation involving two firstorder terms with variables. Unification is used in type inference in many programming languages and in the execution of logic programs. This means that unification algorithms have to be written over and over again for different term types. Many other functions also make sense for a large class of datatypes, examples are pretty printers, equality checks, maps etc. They can be defined by induction on the structure of userdefined datatypes. Implementations of these functions for different datatypes are closely related to the structure of the datatypes. We call such functions polytypic. This paper describes a unification algorithm parametrised by the type of the terms and shows how to use polytypism to obtain a unification algorithm that works for all regular term types. 1 Introduction In simple pattern matching, a pattern (a string containing wild cards) is matched with a normal string...
TwoLevel Types and Parameterized Modules (Functional Pearls)
, 2002
"... In this functional pearl, we describe two techniques for the efficient, modularized implementation of a large class of algorithms. We illustrate these techniques using several examples, including efficient generic unification algorithms that use reference cells to encode substitutions, and highly mo ..."
Abstract
 Add to MetaCart
In this functional pearl, we describe two techniques for the efficient, modularized implementation of a large class of algorithms. We illustrate these techniques using several examples, including efficient generic unification algorithms that use reference cells to encode substitutions, and highly modular language implementations.