Results 1 - 10
of
32
Scrap More Boilerplate: Reflection, Zips, and Generalised Casts
, 2004
"... Writing boilerplate code is a royal pain. Generic programming promises to alleviate this pain by allowing the programmer to write a generic "recipe" for boilerplate code, and use that recipe in many places. In earlier work we introduced the "Scrap your boilerplate " approach to generic programming, ..."
Abstract
-
Cited by 49 (3 self)
- Add to MetaCart
Writing boilerplate code is a royal pain. Generic programming promises to alleviate this pain by allowing the programmer to write a generic "recipe" for boilerplate code, and use that recipe in many places. In earlier work we introduced the "Scrap your boilerplate " approach to generic programming, which cunningly exploits Haskell's existing type-class mechanism to support generic transformations and queries.
Concatenate, Reverse and Map Vanish For Free
, 2002
"... We introduce a new transformation method to eliminate intermediate data structures occurring in functional programs due to repeated list concatenations and other data manipulations (additionally exemplified with list reversal and mapping of functions over lists). The general idea is to uniformly abs ..."
Abstract
-
Cited by 23 (9 self)
- Add to MetaCart
We introduce a new transformation method to eliminate intermediate data structures occurring in functional programs due to repeated list concatenations and other data manipulations (additionally exemplified with list reversal and mapping of functions over lists). The general idea is to uniformly abstract from data constructors and manipulating operations by means of rank-2 polymorphic combinators that exploit algebraic properties of these operations to provide an optimized implementation. The correctness of transformations is proved by using the free theorems derivable from parametric polymorphic types.
Naive Reverse can be Linear
- 8th Int. Conf. Logic Programming
, 1991
"... We propose a new implementation of logic programming with higher-order terms. In order to illustrate the properties of our implementation, we apply the coding of lists as functions to the context of logic programming. As a side-effect, we show that higher-order unification is a good tool for manipul ..."
Abstract
-
Cited by 18 (5 self)
- Add to MetaCart
We propose a new implementation of logic programming with higher-order terms. In order to illustrate the properties of our implementation, we apply the coding of lists as functions to the context of logic programming. As a side-effect, we show that higher-order unification is a good tool for manipulating the function-lists. It appears that the efficiency of the program thus obtained relies critically upon the implementation of higher-order operations (unification and reduction). In particular, we show that a good choice for data-structures and reduction strategy yields a linear naive reverse. 1 Introduction The extension of Prolog to higher-order terms has been proposed by Miller and Nadathur[6]. The prototypal system is Prolog, of which we know two implementations: a Prolog based implementation and a Lisp based one. The first one was intended for experimental use and is very inefficient. We shall only refer to the Lisp based implementation. We propose another implementation in which ...
Aspect-Oriented Compilers
, 1999
"... . Aspect-oriented programming provides the programmer with means to cross-cut conventional program structures, in particular the class hierarchies of object-oriented programming. This paper studies the use of aspect orientation in structuring syntax directed compilers implemented as attribute gr ..."
Abstract
-
Cited by 17 (2 self)
- Add to MetaCart
. Aspect-oriented programming provides the programmer with means to cross-cut conventional program structures, in particular the class hierarchies of object-oriented programming. This paper studies the use of aspect orientation in structuring syntax directed compilers implemented as attribute grammars. Specifically, it describes a method for specifying definitions of related attributes as `aspects' and treating them as first-class objects, that can be stored, manipulated and combined. It is hoped that this embedding of an aspect-oriented programming style in Haskell provides a stepping stone towards a more general study of the semantics of aspect-oriented programming. 1 Introduction Compilers are often structured by recursion over the abstract syntax of the source language. For each production in the abstract syntax, one defines a function that specifies how a construct is to be translated. The method of structuring compilers in this syntax--directed manner underlies the for...
Deforestation for Higher-Order Functional Programs
, 1995
"... Functional programming languages are an ideal medium for program optimisations based on source-to-source transformation techniques. Referential transparency affords opportunities for a wide range of correctness-preserving transformations leading to potent optimisation strategies. This thesis builds ..."
Abstract
-
Cited by 17 (0 self)
- Add to MetaCart
Functional programming languages are an ideal medium for program optimisations based on source-to-source transformation techniques. Referential transparency affords opportunities for a wide range of correctness-preserving transformations leading to potent optimisation strategies. This thesis builds on deforestation, a program transformation technique due to Wadler that removes intermediate data structures from first-order functional programs. Our contribution is to reformulate deforestation for higher-order functional programming languages, and to show that the resulting algorithm terminates given certain syntactic and typing constraints on the input. These constraints are entirely reasonable, indeed it is possible to translate any typed program into the required syntactic form. We show how this translation can be performed automatically and optimally. The higher-order deforestation algorithm is transparent. That is, it is possible to determine by examination of the source program w...
Calculating Accumulations
, 1999
"... this paper, we shall formulate accumulations as higher order catamorphisms , and propose several general transformation rules for calculating accumulations (i.e., finding and manipulating accumulations) by calculation-based (rather than a search-based) program transformation methods. Some examples ..."
Abstract
-
Cited by 16 (6 self)
- Add to MetaCart
this paper, we shall formulate accumulations as higher order catamorphisms , and propose several general transformation rules for calculating accumulations (i.e., finding and manipulating accumulations) by calculation-based (rather than a search-based) program transformation methods. Some examples are given for illustration.
XML goes native: Run-time representations for Xtatic
- In 14th International Conference on Compiler Construction
, 2004
"... Abstract. Xtatic is a lightweight extension of C ♯ offering native support for statically typed XML processing. XML trees are built-in values in Xtatic, and static analysis of the trees manipulated by programs is part of the ordinary job of the typechecker. “Tree grep ” pattern matching is used to i ..."
Abstract
-
Cited by 15 (6 self)
- Add to MetaCart
Abstract. Xtatic is a lightweight extension of C ♯ offering native support for statically typed XML processing. XML trees are built-in values in Xtatic, and static analysis of the trees manipulated by programs is part of the ordinary job of the typechecker. “Tree grep ” pattern matching is used to investigate and transform XML trees. Xtatic’s surface syntax and type system are tightly integrated with those of C ♯. Beneath the hood, however, an implementation of Xtatic must address a number of issues common to any language supporting a declarative style of XML processing (e.g., XQuery, XSLT, XDuce, CDuce, Xact, Xen, etc.). In particular, it must provide representations for XML tags, trees, and textual data that use memory efficiently, support efficient pattern matching, allow maximal sharing of common substructures, and permit separate compilation. We analyze these representation choices in detail and describe the solutions used by the Xtatic compiler. 1
The Concatenate Vanishes
, 1987
"... This note presents a trivial transformation that can eliminate many calls of the concatenate (or “append”) operator from a program. The general form of the transformation is well known, and one of the examples, transforming the reverse function, is a classic. However, so far as I am aware, this styl ..."
Abstract
-
Cited by 14 (0 self)
- Add to MetaCart
This note presents a trivial transformation that can eliminate many calls of the concatenate (or “append”) operator from a program. The general form of the transformation is well known, and one of the examples, transforming the reverse function, is a classic. However, so far as I am aware, this style of transformation has not previously been systematised in the way done here. The transformation is suitable for incorporation in a compiler, and improves the asymptotic time complexity of some programs from quadratic to linear. There is a syntactic test that determines when the transformation will succeed in eliminating a concatenate operation. Section 1 describes the transformation. Section 2 presents examples. Section 3 characterises the transformation’s benefits. Section 4 describes related work. Section 5 concludes. 1 The transformation First, some notational preliminaries. We write concatenate as infix +, list construction (cons) as infix:, and the empty list as []. We write [x, y, z] as an abbreviation for x: (y: (z: [])). We will make use of the following laws: (1) [ ] + x = x (2) (x: y) + z = x: (y + z) (3) (x + y) + z = x + (y + z) Laws (1) and (2) provide a recursive definition of concatenate. Law (3) states that concatenate is associative; it may be proved from laws (1) and (2). We now describe the transformation. The key idea is that whenever an application of a function f may appear as the left argument of a concatenation, then we introduce a new function f ′ , satisfying the property
The Compilation of Prolog and its Execution with MALI
, 1993
"... We present a compiled implementation of Prolog that uses the abstract memory MALI for representing the execution state. Prolog is a logic programming language allowing a more general clause form than Standard Prolog 's (namely hereditary Harrop formulas instead of Horn formulas) and using simply ty ..."
Abstract
-
Cited by 11 (8 self)
- Add to MetaCart
We present a compiled implementation of Prolog that uses the abstract memory MALI for representing the execution state. Prolog is a logic programming language allowing a more general clause form than Standard Prolog 's (namely hereditary Harrop formulas instead of Horn formulas) and using simply typed -terms as a term domain instead of first order terms. The augmented clause form causes the program (a set of clauses) and the signature (a set of constants) to be changeable in a very disciplined way. The new term domain has a semi-decidable and infinitary unification theory, and it introduces the need for a fi-reduction operation at run-time. MALI is an abstract memory that is suitable for storing the search-state of depth-first search processes. Its main feature is its efficient memory management. We have used an original Prolog-to-C translation along which predicates are transformed into functions operating on continuations for handling failure and success in unifications, and change...

