Results 11 - 20
of
32
Monadic augment and generalised short cut fusion
- Journal of Functional Programming
, 2005
"... Monads are commonplace programming devices that are used to uniformly structure computations with effects such as state, exceptions, and I/O. This paper further develops the monadic programming paradigm by investigating the extent to which monadic computations can be optimised by using generalisatio ..."
Abstract
-
Cited by 9 (5 self)
- Add to MetaCart
Monads are commonplace programming devices that are used to uniformly structure computations with effects such as state, exceptions, and I/O. This paper further develops the monadic programming paradigm by investigating the extent to which monadic computations can be optimised by using generalisations of short cut fusion to eliminate monadic structures whose sole purpose is to “glue together ” monadic program components. We make several contributions. First, we show that every inductive type has an associated build combinator and an associated short cut fusion rule. Second, we introduce the notion of an inductive monad to describe those monads that give rise to inductive types, and we give examples of such monads which are widely used in functional programming. Third, we generalise the standard augment combinators and cata/augment fusion rules for algebraic data types to types induced by inductive monads. This allows us to give the first cata/augment rules for some common data types, such as rose trees. Fourth, we demonstrate the practical applicability of our generalisations by providing Haskell implementations for all concepts and examples in the paper. Finally, we offer deep theoretical insights by showing that the augment combinators are monadic in nature, and thus that our cata/build and cata/augment rules are arguably the best generally applicable fusion rules obtainable.
Better Consumers for Program Specializations
, 1996
"... It is well known that not all programs are susceptible to automatic program specialization. Traditionally, complicated analyses are performed before actual specialization, in order to uncover as much of the useful program properties as possible. This is particularly the case for automatic program tr ..."
Abstract
-
Cited by 8 (0 self)
- Add to MetaCart
It is well known that not all programs are susceptible to automatic program specialization. Traditionally, complicated analyses are performed before actual specialization, in order to uncover as much of the useful program properties as possible. This is particularly the case for automatic program transformers that specialize function calls with arguments containing only constructors and variables. We describe a novel approach for achieving better program specialization by preprocessing a program before subjecting it to actual specialization. The preprocessing phase involves simple syntactic analyses and program transformation, which is based on the well-understood fold/unfold strategy with generalization on terms. We ensure the termination of the transformation used in this phase, and outline a proof of its total correctness. Our approach greatly simplifies the task of program specialization in the later stage. Compared to other existing semantics-based approaches, our syntax-based method is considerably simpler, yet still widely applicable. Our approach is formulated for nonstrict first-order programs. It can help obtain programs that are more susceptible to a variety of program specializers, including partial evaluation, deforestation, and the elimination of repeated pattern testing.
When is a function a fold or an unfold
- Coalgebraic Methods in Computer Science, number 44.1 in Electronic Notes in Theoretical Computer Science
, 2001
"... We give a necessary and sufficient condition for when a set-theoretic function can be written using the recursion operator fold, and a dual condition for the recursion operator unfold. The conditions are simple, practically useful, and generic in the underlying datatype. 1 ..."
Abstract
-
Cited by 8 (3 self)
- Add to MetaCart
We give a necessary and sufficient condition for when a set-theoretic function can be written using the recursion operator fold, and a dual condition for the recursion operator unfold. The conditions are simple, practically useful, and generic in the underlying datatype. 1
Point-free Program Transformation
- Fundamenta Informaticae
, 2005
"... Abstract. The subject of this paper is functional program transformation in the so-called point-free style. By this we mean first translating programs to a form consisting only of categorically-inspired combinators, algebraic data types defined as fixed points of functors, and implicit recursion thr ..."
Abstract
-
Cited by 7 (4 self)
- Add to MetaCart
Abstract. The subject of this paper is functional program transformation in the so-called point-free style. By this we mean first translating programs to a form consisting only of categorically-inspired combinators, algebraic data types defined as fixed points of functors, and implicit recursion through the use of type-parameterized recursion patterns. This form is appropriate for reasoning about programs equationally, but difficult to actually use in practice for programming. In this paper we present a collection of libraries and tools developed at Minho with the aim of supporting the automatic conversion of programs to point-free (embedded in Haskell), their manipulation and rule-driven simplification, and the (limited) automatic application of fusion for program transformation. 1
Construction of List Homomorphisms by Tupling and Fusion
, 1996
"... List homomorphisms are functions which can be efficiently computed in parallel since they ideally suit the divide-and-conquer paradigm. However, some interesting functions, e.g., the maximum segment sum problem, are not list homomorphisms. In this paper, we propose a systematic way of embedding them ..."
Abstract
-
Cited by 5 (4 self)
- Add to MetaCart
List homomorphisms are functions which can be efficiently computed in parallel since they ideally suit the divide-and-conquer paradigm. However, some interesting functions, e.g., the maximum segment sum problem, are not list homomorphisms. In this paper, we propose a systematic way of embedding them into list homomorphisms so that parallel programs are derived. We show, with an example, how a simple, and "obviously" correct, but possibly inefficient solution to the problem can be successfully turned into a semantically equivalent almost homomorphism by means of two transformations: tupling and fusion.
Program Transformation in Calculational Form
, 1998
"... Correctness-preserving program transformation has recently received a particular attention for compiler optimization in functional programming [Kelsey and Hudak 1989; Appel 1992; Peyton Jones 1996]. By implementing a compiler using many passes, each of which is a transformation for a particular opti ..."
Abstract
-
Cited by 4 (4 self)
- Add to MetaCart
Correctness-preserving program transformation has recently received a particular attention for compiler optimization in functional programming [Kelsey and Hudak 1989; Appel 1992; Peyton Jones 1996]. By implementing a compiler using many passes, each of which is a transformation for a particular optimization, one can attain a modular compiler. It is no surprise that the modularity would increase if transformations are structured, i.e. constructed in a modular way. Indeed, the program transformation in calculational form (or program calculation) can help us to attain this goal.
Deriving Parallel Codes via Invariants
"... . Systematic parallelization of sequential programs remains a major challenge in parallel computing. Traditional approaches using program schemes tend to be narrower in scope, as the properties which enable parallelism are difficult to capture via ad-hoc schemes. In [CTH98], a systematic approac ..."
Abstract
-
Cited by 4 (3 self)
- Add to MetaCart
. Systematic parallelization of sequential programs remains a major challenge in parallel computing. Traditional approaches using program schemes tend to be narrower in scope, as the properties which enable parallelism are difficult to capture via ad-hoc schemes. In [CTH98], a systematic approach to parallelization based on the notion of preserving the context of recursive sub-terms has been proposed. This approach can be used to derive a class of divide-and-conquer algorithms. In this paper, we enhance the methodology by using invariants to guide the parallelization process. The enhancement enables the parallelization of a class of recursive functions with conditional and tupled constructs, which were not possible previously. We further show how such invariants can be discovered and verified systematically, and demonstrate the power of our methodology by deriving a parallel code for maximum segment product. To the best of our knowledge, this is the first systematic parall...
Short cut fusion: Proved and improved
- Pages 47–71 of: Semantics, Applications, and Implementation of Program Generation
, 2001
"... Abstract. Short cut fusion is a particular program transformation technique which uses a single, local transformation — called the foldr-build rule — to remove certain intermediate lists from modularly constructed functional programs. Arguments that short cut fusion is correct typically appeal eithe ..."
Abstract
-
Cited by 3 (1 self)
- Add to MetaCart
Abstract. Short cut fusion is a particular program transformation technique which uses a single, local transformation — called the foldr-build rule — to remove certain intermediate lists from modularly constructed functional programs. Arguments that short cut fusion is correct typically appeal either to intuition or to “free theorems ” — even though the latter have not been known to hold for the languages supporting higher-order polymorphic functions and fixed point recursion in which short cut fusion is usually applied. In this paper we use Pitts ’ recent demonstration that contextual equivalence in such languages is relationally parametric to prove that programs in them which have undergone short cut fusion are contextually equivalent to their unfused counterparts. The same techniques in fact yield a much more general result. For each algebraic data type we define a generalization augment of build which constructs substitution instances of its associated data structures. Together with the well-known generalization cata of foldr to arbitrary algebraic data types, this allows us to formulate and prove correct for each a contextual equivalence-preserving cata-augment fusion rule. These rules optimize compositions of functions that uniformly consume algebraic data structures with functions that uniformly produce substitution instances of them. 1
An Extension Of The Acid Rain Theorem
- In T Ida, A Ohori, and M Takeichi, eds, Proceedings 2nd Fuji Int Workshop on Functional and Logic Programming, Shonan Village
, 1996
"... Program fusion (or deforestation) is a well-known transformation whereby compositions of several pieces of code are fused into a single one, resulting in an efficient functional program without intermediate data structures. Recent work has made it clear that fusion transformation is especially succe ..."
Abstract
-
Cited by 3 (2 self)
- Add to MetaCart
Program fusion (or deforestation) is a well-known transformation whereby compositions of several pieces of code are fused into a single one, resulting in an efficient functional program without intermediate data structures. Recent work has made it clear that fusion transformation is especially successful if recursions are expressed in terms of hylomorphisms . The point of this success is that fusion transformation proceeds merely based on a simple but effective rule called Acid Rain Theorem [10]. However, there remains a problem. The Acid Rain Theorem can only handle hylomorphisms inducting over a single data structure. For hylomorphisms, like zip, which induct over multiple data structures, it will leave some of the data structures remained which should be removed. In this paper, we extend the Acid Rain Theorem so that it can deal with such hylomorphisms, enabling more intermediate data structures to be eliminated. 1. Introduction Functional programming constructs a complex program ...
Deriving animations from recursive definitions
- In Draft Proceedings of the 14th International Workshop on the Implementation of Functional Languages (IFL’02
, 2002
"... Abstract. This paper describes a generic method to derive an animation from a recursive definition, with the objective of debugging and understanding this definition by expliciting its control structure. This method is based on a well known algorithm of factorizing a recursive function into the comp ..."
Abstract
-
Cited by 2 (1 self)
- Add to MetaCart
Abstract. This paper describes a generic method to derive an animation from a recursive definition, with the objective of debugging and understanding this definition by expliciting its control structure. This method is based on a well known algorithm of factorizing a recursive function into the composition of the producer and the consumer of its call tree. We developed a systematic method to transform both the resulting functions in order to draw the tree step by step. The theory of data types as fixed points of functors, generic recursion patterns, and monads, are fundamental to our work and are briefly presented. Using polytypic implementations of monadic recursion patterns and an application to manipulate and generate graph layouts we developed a prototype that, given a recursive function written in a subset of Haskell, returns a function whose execution yields the desired animation. 1

