Results 1  10
of
38
Scrap Your Boilerplate: A Practical Design Pattern for Generic Programming
 Proc. of the ACM SIGPLAN Workshop on Types in Language Design and Implementation (TLDI 2003
, 2003
"... We describe a design pattern for writing programs that traverse data structures built from rich mutuallyrecursive data types. Such programs often have a great deal of "boilerplate" code that simply walks the structure, hiding a small amount of "real" code that constitutes the reason for the travers ..."
Abstract

Cited by 137 (12 self)
 Add to MetaCart
We describe a design pattern for writing programs that traverse data structures built from rich mutuallyrecursive data types. Such programs often have a great deal of "boilerplate" code that simply walks the structure, hiding a small amount of "real" code that constitutes the reason for the traversal. Our technique allows most...
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 socalled 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 107 (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 socalled 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 higherorder functors. Polytypic values enjoy polytypic properties. Using kindindexed logical relations we prove...
How to Declare an Imperative
, 1995
"... How can we integrate interaction into a purely declarative language? This tutorial describes a solution to this problem based on a monad. The solution has been implemented in the functional language Haskell and the declarative language Escher. Comparisons are given to other approaches to interaction ..."
Abstract

Cited by 96 (3 self)
 Add to MetaCart
How can we integrate interaction into a purely declarative language? This tutorial describes a solution to this problem based on a monad. The solution has been implemented in the functional language Haskell and the declarative language Escher. Comparisons are given to other approaches to interaction based on synchronous streams, continuations, linear logic, and side effects.
Polytypic programming
, 2000
"... ... PolyP extends a functional language (a subset of Haskell) with a construct for defining polytypic functions by induction on the structure of userdefined datatypes. Programs in the extended language are translated to Haskell. PolyLib contains powerful structured recursion operators like catamorp ..."
Abstract

Cited by 93 (12 self)
 Add to MetaCart
... PolyP extends a functional language (a subset of Haskell) with a construct for defining polytypic functions by induction on the structure of userdefined datatypes. Programs in the extended language are translated to Haskell. PolyLib contains powerful structured recursion operators like catamorphisms, maps and traversals, as well as polytypic versions of a number of standard functions from functional programming: sum, length, zip, (==), (6), etc. Both the specification of the library and a PolyP implementation are presented.
Controlling Rewriting by Rewriting
"... In this paper, we investigate the idea of controlling rewriting by strategies and we develop a strategy language whose operational semantics is also based on rewriting. This language is described in ELAN, a language based on computational systems that are simply rewriting theories controlled by stra ..."
Abstract

Cited by 43 (10 self)
 Add to MetaCart
In this paper, we investigate the idea of controlling rewriting by strategies and we develop a strategy language whose operational semantics is also based on rewriting. This language is described in ELAN, a language based on computational systems that are simply rewriting theories controlled by strategies. We illustrate the syntax, semantics and different features of this strategy language. Finally, we sketch its bootstrapping implementation by a transformation into a computational system, whose heart is a rewrite theory controlled by a lowerlevel strategy of ELAN. 1 Introduction Elegance and expressiveness of rewriting as a computational paradigm are no more to be stressed. What might be less evident, is the weakness that comes from the absence of controlling mechanism over rewriting. In many existing term rewriting systems, the term reduction strategy is hardwired and is not accessible to the designer of an application. The results of [KKV95a] and some experiences show that even f...
Dealing with Large Bananas
 Universiteit Utrecht
, 2000
"... Abstract. Many problems call for a mixture of generic and speci c programming techniques. We propose a polytypic programming approach based on generalised (monadic) folds where a separation is made between basic fold algebras that model generic behaviour and updates on these algebras that model spec ..."
Abstract

Cited by 29 (12 self)
 Add to MetaCart
Abstract. Many problems call for a mixture of generic and speci c programming techniques. We propose a polytypic programming approach based on generalised (monadic) folds where a separation is made between basic fold algebras that model generic behaviour and updates on these algebras that model speci c behaviour. We identify particular basic algebras as well as some algebra combinators, and we show how these facilitate structured programming with updatable fold algebras. This blend of genericity and speci city allows programming with folds to scale up to applications involving large systems of mutually recursive datatypes. Finally, we address the possibility of providing generic de nitions for the functions, algebras, and combinators that we propose. 1
Recursion Schemes from Comonads
, 2001
"... . Within the setting of the categorical approach to programming with total functions, a \manyinone" recursion scheme is introduced that neatly unies a variety of recursion schemes looking as diverging generalizations of the basic recursion scheme of iteration. The scheme is doubly generic: in addi ..."
Abstract

Cited by 21 (4 self)
 Add to MetaCart
. Within the setting of the categorical approach to programming with total functions, a \manyinone" recursion scheme is introduced that neatly unies a variety of recursion schemes looking as diverging generalizations of the basic recursion scheme of iteration. The scheme is doubly generic: in addition to behaving uniformly with respect to a functor determining an inductive type, it is also uniform in a comonad and a distributive law which together determine a particular recursion scheme for this inductive type. By way of examples, it is shown to subsume iteration, a scheme subsuming primitive recursion, and a scheme subsuming courseofvalue iteration.
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.
Fusion of Recursive Programs with Computational Effects
 Theor. Comp. Sci
, 2000
"... Fusion laws permit to eliminate various of the intermediate data structures that are created in function compositions. The fusion laws associated with the traditional recursive operators on datatypes cannot in general be used to transform recursive programs with effects. Motivated by this fact, t ..."
Abstract

Cited by 14 (4 self)
 Add to MetaCart
Fusion laws permit to eliminate various of the intermediate data structures that are created in function compositions. The fusion laws associated with the traditional recursive operators on datatypes cannot in general be used to transform recursive programs with effects. Motivated by this fact, this paper addresses the definition of two recursive operators on datatypes that capture functional programs with effects. Effects are assumed to be modeled by monads. The main goal is thus the derivation of fusion laws for the new operators. One of the new operators is called monadic unfold. It captures programs (with effects) that generate a data structure in a standard way. The other operator is called monadic hylomorphism, and corresponds to programs formed by the composition of a monadic unfold followed by a function defined by structural induction on the data structure that the monadic unfold generates. 1 Introduction A common approach to program design in functional programmin...