Results 1 -
9 of
9
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 so-called 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 102 (20 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 so-called 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 higher-order functors. Polytypic values enjoy polytypic properties. Using kind-indexed logical relations we prove...
A New Approach to Generic Functional Programming
- In The 27th Annual ACM SIGPLAN-SIGACT 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 84 (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 complexity---a 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...
Language Independent Traversals for Program Transformation
- Universiteit Utrecht
, 2000
"... syntax representation in which variables are not leaves and extraction of variable names from expressions. strategies free-vars2(getvars, boundvars) = rec x(split(getvars <+ ![], split(collect-kids(x), boundvars <+ ![]); diff); union) Figure 15: Algorithm for collecting free variables that tak ..."
Abstract
-
Cited by 24 (7 self)
- Add to MetaCart
syntax representation in which variables are not leaves and extraction of variable names from expressions. strategies free-vars2(getvars, boundvars) = rec x(split(getvars <+ ![], split(collect-kids(x), boundvars <+ ![]); diff); union) Figure 15: Algorithm for collecting free variables that takes variables in subterms of variables into account. A variant of this algorithm taking into account binding positions can be created analogously to Figure 13 11 Section: Case Studies RENAMING BOUND VARIABLES Renaming of bound variables depends on the shape of variables and the shape of binding constructs. For binding constructs, in addition to determining what variables are bound and in which arguments they are binding, it is necessary to declare where new variables should be pasted. In order to keep track of renamings it is also required to distribute an environment along with the renaming traversal. Renaming of bound variables is used to prevent name clashes between variables, for exa...
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 22 (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, 2-3 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...
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 well-kno...
Typed Logical Variables in Haskell
- In Proceedings Haskell Workshop
, 2000
"... We describe how to embed a simple typed functional logic programming language in Haskell. The embedding is a natural extension of the Prolog embedding by Seres and Spivey [16]. To get full static typing we need to use the Haskell extensions of quantified types and the ST-monad. 1 Introduction O ..."
Abstract
-
Cited by 13 (0 self)
- Add to MetaCart
We describe how to embed a simple typed functional logic programming language in Haskell. The embedding is a natural extension of the Prolog embedding by Seres and Spivey [16]. To get full static typing we need to use the Haskell extensions of quantified types and the ST-monad. 1 Introduction Over the last ten to twenty years, there have been many attempts to combine the flavours of logic and functional programming [3]. Among these, the most well-known ones are the programming languages Curry [4], Escher [13], and Mercury [14]. Curry and Escher can be seen as variations on Haskell, where logic programming features are added. Mercury can be seen as an improvement of Prolog, where types and functional programming features are added. All three are completely new and autonomous languages. Defining a new programming language has as a drawback for the developer to build a new compiler, and for the user to learn a new language. A different approach which has gained a lot of popularity ...
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 9 (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 so-called 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, rank-2 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...
Initial algebra semantics is enough
- Proceedings, Typed Lambda Calculus and Applications
, 2007
"... Abstract. Initial algebra semantics is a cornerstone of the theory of modern functional programming languages. For each inductive data type, it provides a fold combinator encapsulating structured recursion over data of that type, a Church encoding, a build combinator which constructs data of that ty ..."
Abstract
-
Cited by 5 (2 self)
- Add to MetaCart
Abstract. Initial algebra semantics is a cornerstone of the theory of modern functional programming languages. For each inductive data type, it provides a fold combinator encapsulating structured recursion over data of that type, a Church encoding, a build combinator which constructs data of that type, and a fold/build rule which optimises modular programs by eliminating intermediate data of that type. It has long been thought that initial algebra semantics is not expressive enough to provide a similar foundation for programming with nested types. Specifically, the folds have been considered too weak to capture commonly occurring patterns of recursion, and no Church encodings, build combinators, or fold/build rules have been given for nested types. This paper overturns this conventional wisdom by solving all of these problems. 1
Substitution in non-wellfounded . . .
- ELECTRONIC NOTES IN THEORETICAL COMPUTER SCIENCE 82 NO. 1 (2003)
, 2003
"... Inspired from the recent developments in theories of non-wellfounded syntax (coinductively defined languages) and of syntax with binding operators, the structure of algebras of wellfounded and non-wellfounded terms is studied for a very general notion of signature permitting both simple variable bin ..."
Abstract
- Add to MetaCart
Inspired from the recent developments in theories of non-wellfounded syntax (coinductively defined languages) and of syntax with binding operators, the structure of algebras of wellfounded and non-wellfounded terms is studied for a very general notion of signature permitting both simple variable binding operators as well as operators of explicit substitution. This is done in an extensional mathematical setting of initial algebras and final coalgebras of endofunctors on a functor category. In the non-wellfounded case, the fundamental operation of substitution is more beneficially defined in terms of primitive corecursion than coiteration.

