Results 1 -
8 of
8
Type-Indexed Data Types
- SCIENCE OF COMPUTER PROGRAMMING
, 2004
"... A polytypic function is a function that can be instantiated on many data types to obtain data type specific functionality. Examples of polytypic functions are the functions that can be derived in Haskell, such as show , read , and ` '. More advanced examples are functions for digital searching, patt ..."
Abstract
-
Cited by 53 (19 self)
- Add to MetaCart
A polytypic function is a function that can be instantiated on many data types to obtain data type specific functionality. Examples of polytypic functions are the functions that can be derived in Haskell, such as show , read , and ` '. More advanced examples are functions for digital searching, pattern matching, unification, rewriting, and structure editing. For each of these problems, we not only have to define polytypic functionality, but also a type-indexed data type: a data type that is constructed in a generic way from an argument data type. For example, in the case of digital searching we have to define a search tree type by induction on the structure of the type of search keys. This paper shows how to define type-indexed data types, discusses several examples of type-indexed data types, and shows how to specialize type-indexed data types. The approach has been implemented in Generic Haskell, a generic programming extension of the functional language Haskell.
Generic Haskell: applications
- In Generic Programming, Advanced Lectures, volume 2793 of LNCS
, 2003
"... Generic Haskell is an extension of Haskell that supports the construction of generic programs. These lecture notes discuss three advanced generic programming applications: generic dictionaries, compressing XML documents, and the zipper: a data structure used to represent a tree together with a s ..."
Abstract
-
Cited by 28 (15 self)
- Add to MetaCart
Generic Haskell is an extension of Haskell that supports the construction of generic programs. These lecture notes discuss three advanced generic programming applications: generic dictionaries, compressing XML documents, and the zipper: a data structure used to represent a tree together with a subtree that is the focus of attention, where that focus may move left, right, up or down the tree. When describing and implementing these examples, we will encounter some advanced features of Generic Haskell, such as type-indexed data types, dependencies between and generic abstractions of generic functions, adjusting a generic function using a default case, and generic functions with a special case for a particular constructor.
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...
Generic Unification via Two-Level Types and Parameterized Modules - Functional Pearl
, 2001
"... As a functional pearl we describe an e#cient, modulMM0$y implMM0 tation of unification using the state of mutabl reference cele to encode substitutions. We abstract oural13 rithms alms two dimensions, first abstracting awa from the structure of the terms to be unified, and second over the monad in w ..."
Abstract
-
Cited by 12 (1 self)
- Add to MetaCart
As a functional pearl we describe an e#cient, modulMM0$y implMM0 tation of unification using the state of mutabl reference cele to encode substitutions. We abstract oural13 rithms alms two dimensions, first abstracting awa from the structure of the terms to be unified, and second over the monad in which the mutabl state is encapsulLJ0M We choose thisexampl to ilfljflLCy# two important techniques that we belLj e man functional programmers woul finduseful The first of these is the definition of recursive data t pes using twol evelfl a structure definingln el and a recursive knot-t ingl evel The second is the use of rank-2 pol morphism inside Haskelky record t pes to implM3C t a form of t pe parameterized moduljC Keywords Generic programs, unification, parameterized modulM 1.
Programming With Types
- CORNELL UNIVERSITY
, 2002
"... Run-time type analysis is an increasingly important linguistic mechanism in modern programming languages. Language runtime systems use it to implement services such as accurate garbage collection, serialization, cloning and structural equality. Component frameworks rely on it to provide reflection m ..."
Abstract
-
Cited by 10 (1 self)
- Add to MetaCart
Run-time type analysis is an increasingly important linguistic mechanism in modern programming languages. Language runtime systems use it to implement services such as accurate garbage collection, serialization, cloning and structural equality. Component frameworks rely on it to provide reflection mechanisms so they may discover and interact with program interfaces dynamically. Run-time type analysis is also crucial for large, distributed systems that must be dynamically extended, because it allows those systems to check program invariants when new code and new forms of data are added. Finally, many generic user-level algorithms for iteration, pattern matching, and unification can be defined through type analysis mechanisms. However, existing frameworks for run-time type analysis were designed for simple type systems. They do not scale well to the sophisticated type systems of modern and next-generation programming languages that include complex constructs such as first-class abstract types, recursive types, objects, and type parameterization. In addition, facilities to support type analysis often require complicated
Two-level 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 7 (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 knot-tying level. Second, the use of rank-2 polymorphism inside Haskell’s record types to implement a kind of type-parameterized modules. Finally, we explore techniques that allow us to combine already existing recursive Haskell data-types with the highly modular style of programming proposed here. 1
Two-Level 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.
Chapter 22 Matching and Modifying with
"... Abstract: Haskell has powerful features such as pattern matching and recursive data types for building tree structures easily. These features are not without problems, however: patterns are not composable and cannot be abbreviated; it can be hard to modify a specific part of a large tree structure w ..."
Abstract
- Add to MetaCart
Abstract: Haskell has powerful features such as pattern matching and recursive data types for building tree structures easily. These features are not without problems, however: patterns are not composable and cannot be abbreviated; it can be hard to modify a specific part of a large tree structure without unique identifiers. This paper explains how a particular Haskell generics approach, Scrap Your Boilerplate, can be used to solve both of these problems in Haskell, without the need for meta-programming or new language features. Haskell allows programmers to use pattern matching in several contexts, most notably function equations, to match data structures and bind variables. One problem with Haskell’s pattern matching is that the entirety of a pattern must be written together; patterns are not composable or reusable. In addition, pattern

