Results 1 - 10
of
23
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...
Generic programming: An introduction
- 3rd International Summer School on Advanced Functional Programming
, 1999
"... ..."
The Essence of the Visitor Pattern
, 1997
"... . For object-oriented programming, the Visitor pattern enables the definition of a new operation on an object structure without changing the classes of the objects. The price has been that the set of classes must be fixed in advance, and they must each have a so-called accept method. In this paper w ..."
Abstract
-
Cited by 72 (4 self)
- Add to MetaCart
. For object-oriented programming, the Visitor pattern enables the definition of a new operation on an object structure without changing the classes of the objects. The price has been that the set of classes must be fixed in advance, and they must each have a so-called accept method. In this paper we demonstrate how to program visitors without relying on accept methods and without knowing all classes of the objects in advance. The idea, derived from related work on shape polymorphism in functional programming, is to separate (1) accessing subobjects, and (2) acting on them. In the object-oriented setting, reflection techniques support access to sub-objects, as demonstrated in our Java class, Walkabout. It supports all visitors as subclasses, and they can be programmed without any further use of reflection. Thus a program using the Visitor pattern can now be understood as a specialized version of a program using the Walkabout class. 1 Introduction Design patterns [3] aim to make object...
A Generic Programming Extension for Haskell
- Utrecht University
, 1999
"... Many functions can be dened completely generically for all datatypes. Examples include pretty printers (eg show), parsers (eg read), data converters, equality and comparison functions, mapping functions, and so forth. This paper proposes a generic programming extension that enables the user to dene ..."
Abstract
-
Cited by 39 (5 self)
- Add to MetaCart
Many functions can be dened completely generically for all datatypes. Examples include pretty printers (eg show), parsers (eg read), data converters, equality and comparison functions, mapping functions, and so forth. This paper proposes a generic programming extension that enables the user to dene such functions in Haskell. In particular, the proposal aims at generalizing Haskell's deriving construct, which is commonly considered decient since instance declarations can only be derived for a few predened classes. Using generic denitions derived instances can be specied for arbitrary user-dened type classes and for classes that abstract over type constructors of rst-order kind. 1 Introduction Generic or polytypic programming aims at relieving the programmer from repeatedly writing functions of similar functionality for dierent datatypes. Typical examples for socalled generic functions include pretty printers (eg show), parsers (eg read), functions that convert data into a u...
Shape Checking of Array Programs
- In Computing: the Australasian Theory Seminar, Proceedings
, 1997
"... Shape theory provides a framework for the study of data types in which shape and data can be manipulated separately. This paper is concerned with shape checking, i.e. the detection of shape errors, such as array bound errors, without handling the data stored within. It can be seen as a form of parti ..."
Abstract
-
Cited by 22 (5 self)
- Add to MetaCart
Shape theory provides a framework for the study of data types in which shape and data can be manipulated separately. This paper is concerned with shape checking, i.e. the detection of shape errors, such as array bound errors, without handling the data stored within. It can be seen as a form of partial evaluation in which data computations are ignored. We construct a simply-typed lambda-calculus that supports a vector type constructor, whose iteration yields types of arrays. It is expressive enough to construct all of the usual linear algebra operations. All shape errors in a term t can be detected by evaluating its shape #t. Evaluation of #t will terminate if that of t does. Keywords shape analysis, partial evaluation, arrays, higher-order. 1 Introduction Shape theory explores the consequences of manipulating shape and data separately (Jay [14]). Shape refers to the data structure in which the data is stored. For example, the shape of a three-dimensional regular array is a tuple of...
The Functional Imperative: Shape!
- 7th European Symposium on Programming, ESOP'98 Held as part of the joint european conferences on theory and practice of software, ETAPS'98
, 1997
"... Introduction FiSh is a new programming language for array computation that compiles higher-order polymorphic programs into simple imperative programs expressed in a sub-language Turbot, which can then be translated into, say, C. Initial tests show that the resulting code is extremely fast: two orde ..."
Abstract
-
Cited by 20 (7 self)
- Add to MetaCart
Introduction FiSh is a new programming language for array computation that compiles higher-order polymorphic programs into simple imperative programs expressed in a sub-language Turbot, which can then be translated into, say, C. Initial tests show that the resulting code is extremely fast: two orders of magnitude faster than Haskell, and two to four times faster than Objective Caml, one of the fastest ML variants for array programming. Every functional program must ultimately be converted into imperative code, but the mechanism for this is often hidden. FiSh achieves this transparently, using the "equation" from which it is named: Functional = Imperative + Shape Shape here refers to the structure of data, e.g. the length of a vector, or the number of rows and columns of a matrix. The FiSh compiler reads the equation from left to right: it converts functions into procedures by using
Transformation-by-example for XML
- PADL 2000, LNCS 1753
, 2000
"... Abstract. xml is a language for describing markup languages for structured data. A growing number of applications that process xml documents are transformers, i.e., programs that convert documents between xml languages. Unfortunately, the current proposals for transformers are complex general-purpos ..."
Abstract
-
Cited by 7 (2 self)
- Add to MetaCart
Abstract. xml is a language for describing markup languages for structured data. A growing number of applications that process xml documents are transformers, i.e., programs that convert documents between xml languages. Unfortunately, the current proposals for transformers are complex general-purpose languages, which will be unappealing as the xml user base broadens and thus decreases in technical sophistication. We have designed and implemented xt3d, a highly declarative xml specification language. It demands little more from users than a knowledge of the expected input and desired output. We illustrate the power of xt3d with several examples, including one reminiscent of polytypic programming that greatly simplifies the import of xml values into general-purpose languages. 1 XML and Transformations xml [3] is a simplified version of the markup description language sgml. Because of xml’s syntactic simplicity, it is easy to implement rudimentary xml processors and embed them in a variety of devices. As a result, a wide variety of applications are adopting xml as a data representation standard. Declarative programming languages must therefore provide support for xml. They can do better; as this paper demonstrates, ideas from declarative programming can strongly enhance the toolkit that supports xml. Syntactically, xml has a structure similar to other sgml-style markup languages such as html. The difference between xml and a language like html is that xml really represents a family of languages. Concretely, xml provides two levels of specification: – An xml element defines a tree-structured representation of terms. This representation is rich enough to express a wide variety of data. A sample element, which might represent information about music albums, is <album title="everybody else is doing it, so why can’t we?"> <catalog><num>A043</num><fmt>CD</fmt></catalog>
PolyLib - a library of polytypic functions
- In Workshop on Generic Programming (WGP'98), Marstrand
, 1998
"... This paper describes the polytypic functions in PolyLib, motivates their presence in the library, and gives a rationale for their design. Thus we hope to share our experience with other researchers in the field. We will assume the reader has some familiarity with the field of polytypic programming. ..."
Abstract
-
Cited by 4 (0 self)
- Add to MetaCart
This paper describes the polytypic functions in PolyLib, motivates their presence in the library, and gives a rationale for their design. Thus we hope to share our experience with other researchers in the field. We will assume the reader has some familiarity with the field of polytypic programming. Of course, a library is an important part of a programming language. Languages like Java, Delphi, Perl and Haskell are popular partly because of their useful and extensive libraries. For a polytypic programming language it is even more important to have a clear and well-designed library: writing polytypic programs is difficult, and we do not expect many programmers to write polytypic programs. On the other hand, many programmers use polytypic programs such as parser generators, equality functions, etc. This is a first attempt to describe the library of PolyP; we expect that both the form and content of this description will change over time. One of the goals of this paper is to obtain feedback on the library design from other researchers working within the field. At the moment the library only contains the basic
Monads, Shapely Functors and Traversals
, 1999
"... This paper demonstrates the potential for combining the polytypic and monadic programming styles, by introducing a new kind of combinator, called a traversal. The natural setting for dening traversals is the class of shapely data types. This result reinforces the view that shapely data types form a ..."
Abstract
-
Cited by 3 (0 self)
- Add to MetaCart
This paper demonstrates the potential for combining the polytypic and monadic programming styles, by introducing a new kind of combinator, called a traversal. The natural setting for dening traversals is the class of shapely data types. This result reinforces the view that shapely data types form a natural domain for polytypism: they include most of the data types of interest, while to exceed them would sacrice a very smooth interaction between polytypic and monadic programming. Keywords: functional/monadic/polytypic programming, shape theory. 1 Introduction Monadic programming has proved itself extremely useful as a means of encapsulating state and other computational eects in a functional programming setting (see e.g. [12,14]). Recently, interactions between monads and data structures have been studied as a further way for structuring programs. Initially focusing on lists, the studies have been extended to the class of regular datatypes (see e.g. [4,11,1]), with the aim to embo...

