Results 1 
3 of
3
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 15 (7 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.
Algebraic fusion of functions with an accumulating parameter and its improvement
 In Proc. ACM International Conference on Functional Programming
, 2006
"... We present a unifying solution to the problem of fusion of functions, where both the producer function and the consumer function have one accumulating parameter. The key idea in this development is to formulate the producer function as a function which computes over a monoid of data contexts. Upon t ..."
Abstract

Cited by 1 (0 self)
 Add to MetaCart
We present a unifying solution to the problem of fusion of functions, where both the producer function and the consumer function have one accumulating parameter. The key idea in this development is to formulate the producer function as a function which computes over a monoid of data contexts. Upon this formulation, we develop a fusion method called algebraic fusion based on the elementary theory of universal algebra and monoids. The producer function is fused with a monoid homomorphism that is derived from the definition of the consumer function, and is turned into a higherorder function f that computes over the monoid of endofunctions. We then introduce a general concept called improvement, in order to reduce the cost of computing over the monoid of endofunctions (i.e., function closures). An improvement of the function f via a monoid homomorphism h is a function g that satisfies f = h ◦ g. This provides a principled way of finding a firstorder function representing a solution to the fusion problem. It also presents a clean and unifying account for varying fusion methods that have been proposed so far. Furthermore, we show that our method extends to support partial and infinite data structures, by means of an appropriate monoid structure. Categories and Subject Descriptors D.3.2 [Programming Languages]: Language Classifications—Applicative (functional) languages;
Explicit Binds: Effortless Efficiency with and without Trees
"... Abstract. We demonstrate a simple and robust program transformation technique that can improve asymptotic time complexity of datamanipulating programs (e.g., produce a lineartime list reversal function from the obvious quadratic one). In the version of the present paper, it applies to monadic induc ..."
Abstract
 Add to MetaCart
Abstract. We demonstrate a simple and robust program transformation technique that can improve asymptotic time complexity of datamanipulating programs (e.g., produce a lineartime list reversal function from the obvious quadratic one). In the version of the present paper, it applies to monadic inductive datatypes and can be stated in two flavors, through a datatype representation, with an explicit (“frozen”) bind constructor and a special associated defining clause for the fold function, and in a functional form (generalized Church numerals), with a special definition of the bind function in terms of the build constructor. The technique explicates, systematizes, combines and scales a number of ideas known from the literature, achieving a new level of generality. 1