Results 1 - 10
of
13
Comparing Libraries for Generic Programming in Haskell
, 2008
"... Datatype-generic programming is defining functions that depend on the structure, or “shape”, of datatypes. It has been around for more than 10 years, and a lot of progress has been made, in particular in the lazy functional programming language Haskell. There are more than 10 proposals for generic p ..."
Abstract
-
Cited by 12 (7 self)
- Add to MetaCart
Datatype-generic programming is defining functions that depend on the structure, or “shape”, of datatypes. It has been around for more than 10 years, and a lot of progress has been made, in particular in the lazy functional programming language Haskell. There are more than 10 proposals for generic programming libraries or language extensions for Haskell. To compare and characterize the many generic programming libraries in a typed functional language, we introduce a set of criteria and develop a generic programming benchmark: a set of characteristic examples testing various facets of datatype-generic programming. We have implemented the benchmark for nine existing Haskell generic programming libraries and present the evaluation of the libraries. The comparison is useful for reaching a common standard for generic programming, but also for a programmer who has to choose a particular approach for datatype-generic programming.
The NetherlandsOptimizing Generics Is Easy!
, 2009
"... Datatype-generic programming increases program reliability by reducing code duplication and enhancing reusability and modularity. Several generic programming libraries for Haskell have been developed in the past few years. These libraries have been compared in detail with respect to expressiveness, ..."
Abstract
-
Cited by 1 (0 self)
- Add to MetaCart
Datatype-generic programming increases program reliability by reducing code duplication and enhancing reusability and modularity. Several generic programming libraries for Haskell have been developed in the past few years. These libraries have been compared in detail with respect to expressiveness, extensibility, typing issues, etc., but performance comparisons have been brief, limited, and preliminary. It is widely believed that generic programs run slower than hand-written code. In this paper we present an extensive benchmarking suite for generic functions and analyze the potential for automatic code optimization at compilation time. Our benchmark confirms that generic programs, when compiled with the standard optimization flags of the Glasgow Haskell Compiler, are substantially slower than their hand-written counterparts. However, we also find that more advanced optimization capabilities of GHC can be used to further optimize generic functions, sometimes achieving the same efficiency as hand-written code. D.1.1 [Programming Tech-
A Lightweight Approach to Datatype-Generic Rewriting
"... Previous implementations of generic rewriting libraries have a number of limitations: they require the user to either adapt the datatype on which rewriting is applied, or the rewriting rules are specified as functions, which makes it hard or impossible to document, test, and analyse them. We describ ..."
Abstract
- Add to MetaCart
Previous implementations of generic rewriting libraries have a number of limitations: they require the user to either adapt the datatype on which rewriting is applied, or the rewriting rules are specified as functions, which makes it hard or impossible to document, test, and analyse them. We describe a library that demonstrates how to overcome these limitations by defining rules in terms of datatypes, and show how to use a type-indexed datatype to automatically extend a datatype for syntax trees with a case for metavariables. We then show how rewrite rules can be implemented without any knowledge of how the datatype is extended with metavariables. We use Haskell, extended with associated type synonyms, to implement both type-indexed datatypes and generic functions. We analyse the performance of our library and compare it with other approaches to generic rewriting.
The NetherlandsPull-Ups, Push-Downs, and Passing It Around Exercises in Functional Incrementalization
, 2009
"... Abstract. Programs in functional programming languages with algebraic datatypes are often datatype-centric and use folds or fold-like functions. Incrementalization of such a program can significantly improve its performance. Functional incrementalization separates the recursion from the calculation ..."
Abstract
- Add to MetaCart
Abstract. Programs in functional programming languages with algebraic datatypes are often datatype-centric and use folds or fold-like functions. Incrementalization of such a program can significantly improve its performance. Functional incrementalization separates the recursion from the calculation and significantly reduces redundant computation. In this paper, we motivate incrementalization with a simple example and present a library for transforming programs using upwards, downwards, and circular incrementalization. We also give a datatype-generic implementation for the library and demonstrate the incremental zipper, a zipper extended with attributes. 1
Generic Programming for Domain Reasoners
, 2009
"... Abstract: An exercise assistant is a tool that supports students learning procedural skills, such as solving systems of linear equations, or rewriting a logic expression to disjunctive normal form. The domain reasoner is the component of an exercise assistant that deals with tasks that depend on the ..."
Abstract
- Add to MetaCart
Abstract: An exercise assistant is a tool that supports students learning procedural skills, such as solving systems of linear equations, or rewriting a logic expression to disjunctive normal form. The domain reasoner is the component of an exercise assistant that deals with tasks that depend on the semantics of a particular domain, for example the rules that may be applied, or the procedure that should be followed when solving an exercise. An exercise assistant typically has multiple domain reasoners, and the behavior of each of these is, to a large extent, determined by the domain. Generic programming techniques claim to reduce code duplication, to make it easier to change the structure of data, and to provide implementations of many useful functions on most datatypes. There are many libraries for generic programming, all with different datatype support, expressiveness, and ease of use. While a lot of effort has been put into developing new libraries in the past few years, there are few examples of real-life applications of generic programming. In this paper we describe our experience with applying generic programming techniques to our domain reasoners implemented in Haskell. We have used the Uniplate, Multirec, and Regular generic programming libraries. We assess and compare the resulting generic domain reasoners with each other and with the initial, non-generic version, using the software quality factors of the ISO 9126 international standard.
Chapter 1 Generic Programming for Domain Reasoners
"... Abstract: An exercise assistant is a tool that supports students learning procedural skills, such as solving systems of linear equations, or rewriting a logic expression to disjunctive normal form. The domain reasoner is the component of an exercise assistant that deals with tasks that depend on the ..."
Abstract
- Add to MetaCart
Abstract: An exercise assistant is a tool that supports students learning procedural skills, such as solving systems of linear equations, or rewriting a logic expression to disjunctive normal form. The domain reasoner is the component of an exercise assistant that deals with tasks that depend on the semantics of a particular domain, for example the rules that may be applied, or the procedure that should be followed when solving an exercise. An exercise assistant typically has multiple domain reasoners, and the behavior of each of these is, to a large extent, determined by the domain. Generic programming techniques claim to reduce code duplication, to make it easier to change the structure of data, and to provide implementations of many useful functions on most datatypes. There are many libraries for generic programming, all with different datatype support, expressiveness and ease of use. While a lot of effort has been put into developing new libraries in the past few years, there are few examples of real-life applications of generic programming. In this paper we describe our experience with applying generic programming techniques to our domain reasoners implemented in Haskell. We have used the Uniplate, Multirec, and Regular generic programming libraries. We assess and compare the resulting generic domain reasoners with each other and with the initial, non-generic version, using the software quality factors of the ISO 9126 international standard.
Languages
, 2010
"... Tools for computer languages need position information: compilers for providing better error messages, structure editors for mapping between structural and textual views, and debuggers for navigating through a term, for instance. Manually adding position information to an abstract syntax tree is ted ..."
Abstract
- Add to MetaCart
Tools for computer languages need position information: compilers for providing better error messages, structure editors for mapping between structural and textual views, and debuggers for navigating through a term, for instance. Manually adding position information to an abstract syntax tree is tedious and requires pervasive changes: the original tree becomes verbose and every function operating on it needs to be adapted. In this paper, we describe how to automatically extend datatypes with position information using datatype-generic programming techniques. Furthermore, we show examples of how to use this position information: parsers that automatically construct trees annotated with positions, catamorphisms that deal with failure by reporting error locations, and zippers that efficiently navigate annotated trees. The generic programming technique we describe is applicable to a wide range of domains. D.1.1 [Programming Tech-
Pull-Ups, Push-Downs, and Passing It Around Exercises in Functional Incrementalization
"... Abstract. Programs in languages such as Haskell are often datatypecentric and make extensive use of folds on that datatype. Incrementalization of such a program can significantly improve its performance by transforming monolithic atomic folds into incremental computations. Functional incrementalizat ..."
Abstract
- Add to MetaCart
Abstract. Programs in languages such as Haskell are often datatypecentric and make extensive use of folds on that datatype. Incrementalization of such a program can significantly improve its performance by transforming monolithic atomic folds into incremental computations. Functional incrementalization separates the recursion from the application of the algebra in order to reduce redundant computations and reuse intermediate results. In this paper, we motivate incrementalization with a simple example and present a library for transforming programs using upwards, downwards, and circular incrementalization. Our benchmarks show that incrementalized computations using the library are nearly as fast as handwritten atomic functions. 1
General Terms
"... Datatype-generic programming increases program reliability by reducing code duplication and enhancing reusability and modularity. Several generic programming libraries for Haskell have been developed in the past few years. These libraries have been compared in detail with respect to expressiveness, ..."
Abstract
- Add to MetaCart
Datatype-generic programming increases program reliability by reducing code duplication and enhancing reusability and modularity. Several generic programming libraries for Haskell have been developed in the past few years. These libraries have been compared in detail with respect to expressiveness, extensibility, typing issues, etc., but performance comparisons have been brief, limited, and preliminary. It is widely believed that generic programs run slower than hand-written code. In this paper we present an extensive benchmark suite for generic functions and analyze the potential for automatic code optimization at compilation time. Our benchmark confirms that generic programs, when compiled with the standard optimization flags of the Glasgow Haskell Compiler (GHC), are substantially slower than their hand-written counterparts. However, we also find that more advanced optimization capabilities of GHC can be used to further optimize generic functions, sometimes achieving the same efficiency as hand-written code.
– Generic programming at Utrecht –
, 2009
"... Generic programs are programs that abstract over types. Generic programs can be used to address several common programming patterns. This paper discusses why generic programming is useful, gives applications of generic programming, and discusses the history of generic programming and current generic ..."
Abstract
- Add to MetaCart
Generic programs are programs that abstract over types. Generic programs can be used to address several common programming patterns. This paper discusses why generic programming is useful, gives applications of generic programming, and discusses the history of generic programming and current generic programming activities at Utrecht University. Constructing software.

