Results 11 - 20
of
57
Functional Binomial Queues
- In Glasgow Workshop on Functional Programming
, 1994
"... Efficient implementations of priority queues can often be clumsy beasts. We express a functional implementation of binomial queues which is both elegant and efficient. We also quantify some of the differences with other functional implementations. The operations decreaseKey and delete always pose a ..."
Abstract
-
Cited by 11 (0 self)
- Add to MetaCart
Efficient implementations of priority queues can often be clumsy beasts. We express a functional implementation of binomial queues which is both elegant and efficient. We also quantify some of the differences with other functional implementations. The operations decreaseKey and delete always pose a problem without destructive update, we show how our implementation may be extended to express these. 1 Functional priority queues A crucial part of many algorithms is the data structure that is used. Frequently, an algorithm needs an abstract data type providing a number of primitive operations on a data structure. A priority queue is one such data structure that is used by a number of algorithms. Applications include, Dijkstra's [4] algorithm for single-source shortest paths, and the minimum cost spanning tree problem (see Tarjan [12] for a discussion of minimumspanning tree algorithms). See Knuth [8] and Aho et al [1] for many other applications of priority queues. A priority queue is a ...
Constraints to Stop Higher-Order Deforestation
- In 24th ACM Symposium on Principles of Programming Languages
, 1997
"... Wadler's deforestation algorithm eliminates intermediate data structures from functional programs. To be suitable for inclusion in a compiler, it must terminate on all programs. Several techniques to ensure termination of deforestation on all first-order programs are known, but a technique for highe ..."
Abstract
-
Cited by 11 (1 self)
- Add to MetaCart
Wadler's deforestation algorithm eliminates intermediate data structures from functional programs. To be suitable for inclusion in a compiler, it must terminate on all programs. Several techniques to ensure termination of deforestation on all first-order programs are known, but a technique for higher-order programs was only recently introduced by Hamilton, and elaborated and implemented in the Glasgow Haskell compiler by Marlow. We introduce a new technique for ensuring termination of deforestation on all higher-order programs that allows useful transformation steps prohibited in Hamilton's and Marlowe's techniques. 1 Introduction Lazy, higher-order, functional programming languages lend themselves to a certain style of programming which uses intermediate data structures [28]. Example 1 Consider the following program. letrec a = x; y:case x of [] ! y (h : t) ! h : a t y in u; v; w: a (a u v) w The term u; v; w:a (a u v) w appends the three lists u, v, and w. Appending u and v ...
The essence of the Iterator pattern
- McBride, Conor, & Uustalu, Tarmo (eds), Mathematically-structured functional programming
, 2006
"... The ITERATOR pattern gives a clean interface for element-by-element access to a collection. Imperative iterations using the pattern have two simultaneous aspects: mapping and accumulating. Various existing functional iterations model one or other of these, but not both simultaneously. We argue that ..."
Abstract
-
Cited by 11 (6 self)
- Add to MetaCart
The ITERATOR pattern gives a clean interface for element-by-element access to a collection. Imperative iterations using the pattern have two simultaneous aspects: mapping and accumulating. Various existing functional iterations model one or other of these, but not both simultaneously. We argue that McBride and Paterson’s idioms, and in particular the corresponding traverse operator, do exactly this, and therefore capture the essence of the ITERATOR pattern. We present some axioms for traversal, and illustrate with a simple example, the repmin problem.
Integer Constraints to Stop Deforestation
, 1996
"... . Deforestation is a transformation of functional programs to remove intermediate data structures. It is based on outermost unfolding of function calls where folding occurs when unfolding takes place within the same nested function call. Since unrestricted unfolding may encounter arbitrarily man ..."
Abstract
-
Cited by 10 (2 self)
- Add to MetaCart
. Deforestation is a transformation of functional programs to remove intermediate data structures. It is based on outermost unfolding of function calls where folding occurs when unfolding takes place within the same nested function call. Since unrestricted unfolding may encounter arbitrarily many terms, a termination analysis has to determine those subterms where unfolding is possibly dangerous. We show that such an analysis can be obtained from a control flow analysis by an extension with integer constraints -- essentially at no loss in efficiency. 1 Introduction The key idea of flow analysis for functional languages is to define an abstract meaning in terms of program points , i.e., subexpressions of the program possibly evaluated during program execution [Pa95]. Such analysises have been invented for tasks like type recovery [Sh91], binding time analysis [Co93], or safety analysis [PS95]. Conceptually, these are closely related to A. Deutsch's store--based alias analysis [D...
Value Recursion in Monadic Computations
- OGI School of Science and Engineering, OHSU
, 2002
"... viii 1 ..."
A Translation from Attribute Grammars to Catamorphisms
, 1994
"... G has a simple form, so that the actual translation can be formulated without too many indices and the like. 1 . The context free grammar G determines a functor F . . Lemma T is a subset of the carrier of the initial F -algebra. . The attribute evaluation rules A determine a function # : (X ..."
Abstract
-
Cited by 10 (2 self)
- Add to MetaCart
G has a simple form, so that the actual translation can be formulated without too many indices and the like. 1 . The context free grammar G determines a functor F . . Lemma T is a subset of the carrier of the initial F -algebra. . The attribute evaluation rules A determine a function # : (X Y ) . . Theorem [[A]](t, x) = ([F| #]) t x . We assume that we are working in the category Set , or in a Set -like category, like CPO . Simplification of the attribute grammar For notational simplicity we make the following three assumptions, without loss of generality. (1) Any terminal a is produced only by rules of the form lhs a where a in the right hand side has no attributes. This can be achieved by the addition of auxiliary nonterminal symbols, say one for each terminal symbol a . (2) Any nonterminal has precisely one inherited and one synthesized attribute. This can be achieved for any AG by tupling the inherited attributes of each nonterminal, and also the synthesized on
A Transformation Method for Dynamic-Sized Tabulation
, 1995
"... Tupling is a transformation tactic to obtain new functions, without redundant calls and/or multiple traversals of common inputs. It achieves this feat by allowing each set (tuple) of function calls to be computed recursively from its previous set. In previous works by Chin and Khoo [8, 9], a safe (t ..."
Abstract
-
Cited by 9 (3 self)
- Add to MetaCart
Tupling is a transformation tactic to obtain new functions, without redundant calls and/or multiple traversals of common inputs. It achieves this feat by allowing each set (tuple) of function calls to be computed recursively from its previous set. In previous works by Chin and Khoo [8, 9], a safe (terminating) fold/unfold transformation algorithm was developed for some classes of functions which are guaranteed to be successfully tupled. However, these classes of functions currently use static-sized tables for eliminating the redundant calls. As shown by Richard Bird in [3], there are also other classes of programs whose redundant calls could only be eliminated by using dynamic-sized tabulation. This paper proposes a new solution to dynamic-sized tabulation by an extension to the tupling tactic. Our extension uses lambda abstractions which can be viewed as either dynamic-sized tables or applications of the higher-order generalisation technique to facilitate tupling. Significant speedups could be obtained after the transformed programs were vectorised, as confirmed by experiment.
There and Back Again
- In ICFP ’02: Proceedings of the seventh ACM SIGPLAN international conference on Functional programming
, 2001
"... We illustrate a variety of programming problems that seemingly require two separate list traversals, but that can be efficiently solved in one recursive descent, without any other auxiliary storage but what can be expected from a control stack. The idea is to perform the second traversal when return ..."
Abstract
-
Cited by 9 (2 self)
- Add to MetaCart
We illustrate a variety of programming problems that seemingly require two separate list traversals, but that can be efficiently solved in one recursive descent, without any other auxiliary storage but what can be expected from a control stack. The idea is to perform the second traversal when returning from the first.
Attribute Grammars and Folds: Generic Control Operators
, 1996
"... Generic control operators, such as fold, have been introduced in functional programming to increase the power and applicability of data-structure-based transformations. This is achieved by making the structure of the data more explicit in program specifications. We argue that this very important pro ..."
Abstract
-
Cited by 9 (5 self)
- Add to MetaCart
Generic control operators, such as fold, have been introduced in functional programming to increase the power and applicability of data-structure-based transformations. This is achieved by making the structure of the data more explicit in program specifications. We argue that this very important property is one of the original concepts of attribute grammars. In this paper, we informally show the similarities between the fold formalism and attribute grammar specifications. We also compare their respective method to eliminate the intermediate data structures introduced by function composition (notion of deforestation or fusion): the normalization algorithm for programs expressed with folds and the descriptional composition of attribute grammars. Rather than identify the best way to achieve deforestation, the main goal of this paper is merely to intuitively present two programming paradigms to each other's supporting community and provide an unbiased account of their similarities and diff...
A Recursive do for Haskell
, 2002
"... Certain programs making use of monads need to perform recursion over the values of monadic actions. Although the do-notation of Haskell provides a convenient framework for monadic programming, it lacks the generality to support such recursive bindings. In this paper, we describe an enhanced translat ..."
Abstract
-
Cited by 9 (1 self)
- Add to MetaCart
Certain programs making use of monads need to perform recursion over the values of monadic actions. Although the do-notation of Haskell provides a convenient framework for monadic programming, it lacks the generality to support such recursive bindings. In this paper, we describe an enhanced translation schema for the donotation and its integration into Haskell. The new translation allows variables to be bound recursively, provided the underlying monad comes equipped with an appropriate fixed-point operator.

