## Chapter 1 Generic Programming for Domain Reasoners

### BibTeX

@MISC{Jeuring_chapter1,

author = {Johan Jeuring and José Pedro Magalhães and Bastiaan Heeren},

title = {Chapter 1 Generic Programming for Domain Reasoners},

year = {}

}

### OpenURL

### Abstract

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.

### Citations

312 | Quickcheck: a lightweight tool for random testing of haskell programs
- Claessen, Hughes
- 2000
(Show Context)
Citation Context ...erically. However, its simplicity limits its functionality. In Uniplate one cannot write generic functions that build values from scratch. In both Multirec and Regular we can write generic QuickCheck =-=[4]-=- Arbitrary instances, which are used to generate exercises and test data, whereas using Uniplate we cannot. Uniplate also cannot define the generic fold, or even top-level equality. Both Multirec and ... |

92 | The zipper
- Huet
- 1997
(Show Context)
Citation Context ...e pretty-printed expressions almost never contain unnecessary parentheses, a user is generally unaware of associativity. For increased reliability in the traversals, we want to use the generic zipper =-=[11]-=-. There is an implementation of a zipper for Multirec using type-indexed datatypes through type families. This implementation can easily be converted to Regular. This would replace the current untyped... |

56 |
et al. Haskell 98 Language and Libraries, the Revised Report
- Jones
- 2003
(Show Context)
Citation Context ... family type has to be propagated through the entire code. This reduces the overall readability and maintainability of the code. Portability The original domain reasoners were developed in Haskell 98 =-=[18]-=-, which made the portability of the domain reasoners good. When we moved to generic domain reasoners we first used an embedded implementation of Uniplate. This implementation was a subset of the Unipl... |

53 |
Scrap your boilerplate: a practical approach to generic programming
- Lämmel, Jones
- 2003
(Show Context)
Citation Context ...ogramming libraries in Haskell that give the user access to the recursive structure of values: Uniplate [15], Regular [16] and Multirec [20] in a straightforward way, and Scrap Your Boilerplate (SYB) =-=[13]-=- in a rather cumbersome way (see the Uniplate module Data.Generics.PlateData which implements Uniplate using SYB). We have three implementations of a generic domain reasoner, one using Uniplate, one u... |

25 | Generic programming with fixed points for mutually recursive datatypes
- Yakushev, Holdermans, et al.
- 2008
(Show Context)
Citation Context ...cursive structure of the domain. There are only a few generic programming libraries in Haskell that give the user access to the recursive structure of values: Uniplate [15], Regular [16] and Multirec =-=[20]-=- in a straightforward way, and Scrap Your Boilerplate (SYB) [13] in a rather cumbersome way (see the Uniplate module Data.Generics.PlateData which implements Uniplate using SYB). We have three impleme... |

24 | A lightweight approach to datatype-generic rewriting
- Noort, Rodriguez, et al.
- 2008
(Show Context)
Citation Context ...eed to know the recursive structure of the domain. There are only a few generic programming libraries in Haskell that give the user access to the recursive structure of values: Uniplate [15], Regular =-=[16]-=- and Multirec [20] in a straightforward way, and Scrap Your Boilerplate (SYB) [13] in a rather cumbersome way (see the Uniplate module Data.Generics.PlateData which implements Uniplate using SYB). We ... |

20 | Yakushev. Libraries for generic programming in Haskell
- Jeuring, Leather, et al.
- 2008
(Show Context)
Citation Context ...ion trees, at which Haskell is good. Later, when we decided to make our domain reasoners generic, this turned out to be right choice, since there are many approaches to generic programming in Haskell =-=[10, 21]-=-. Types (domains) play an important role in our software, and we also want to use typed approaches to generic programming, which discards an approach like DrIFT and other approaches based on meta prog... |

18 |
Uniform boilerplate and list processing, in
- Mitchell, Runciman
(Show Context)
Citation Context ...lies that we need to know the recursive structure of the domain. There are only a few generic programming libraries in Haskell that give the user access to the recursive structure of values: Uniplate =-=[15]-=-, Regular [16] and Multirec [20] in a straightforward way, and Scrap Your Boilerplate (SYB) [13] in a rather cumbersome way (see the Uniplate module Data.Generics.PlateData which implements Uniplate u... |

17 |
Authoring interactive exercises in ActiveMath
- Goguadze, Tsigler
- 2007
(Show Context)
Citation Context ... derivative or integral of a function [7, 8, 14, 17]. Our domain reasoners offer the functionality as described above as web services [5]. Several exercise assistants, such as MathDox [4], ActiveMath =-=[6]-=-, and the Freudenthal digital mathematics environment [3], use our domain reasoning web services. At the moment we develop and maintain our own domain reasoners, but in the future we expect users of o... |

15 |
Towards Getting Generic Programming Ready for Prime Time
- Yakushev
(Show Context)
Citation Context ...or generic programming in Haskell. These differ substantially in expressiveness, datatypes supported and usability. Recently, a detailed comparison of generic programming libraries has been performed =-=[21, 23]-=-. We have used this comparison when choosing a generic programming library.1.3. GENERIC PROGRAMMING LIBRARIES 5 1.3.1 Datatypes in the domain reasoners Our domain reasoners currently represent severa... |

13 | Specifying strategies for exercises
- Heeren, Jeuring, et al.
(Show Context)
Citation Context ...omials, rewriting a logical term to disjunctive normal form, rewriting relation algebra terms, developing (extended) lambda-calculus programs, and determining the derivative or integral of a function =-=[7, 8, 14, 17]-=-. Our domain reasoners offer the functionality as described above as web services [5]. Several exercise assistants, such as MathDox [4], ActiveMath [6], and the Freudenthal digital mathematics environ... |

10 | MathDox : mathematical documents on the web
- Cohen, Cuypers, et al.
- 2006
(Show Context)
Citation Context ... determining the derivative or integral of a function [7, 8, 14, 17]. Our domain reasoners offer the functionality as described above as web services [5]. Several exercise assistants, such as MathDox =-=[4]-=-, ActiveMath [6], and the Freudenthal digital mathematics environment [3], use our domain reasoning web services. At the moment we develop and maintain our own domain reasoners, but in the future we e... |

10 |
Comparing libraries for generic programming in Haskell
- Yakushev, Jeuring, et al.
- 2008
(Show Context)
Citation Context ...trees, at which Haskell is good. Later, when we decided to make our domain reasoners generic, this turned out to be the right choice, since there are many approaches to generic programming in Haskell =-=[11, 23]-=-. Types (domains) play an important role in our software, and we also want to use typed approaches to generic programming, which rules out an approach like DrIFT [24] and other approaches based on met... |

9 |
Comparing approches to generic programming in Haskell. Pages 72–149 of: Spring school on datatype-generic programming
- Hinze, Jeuring, et al.
- 2007
(Show Context)
Citation Context ...ion trees, at which Haskell is good. Later, when we decided to make our domain reasoners generic, this turned out to be right choice, since there are many approaches to generic programming in Haskell =-=[10, 21]-=-. Types (domains) play an important role in our software, and we also want to use typed approaches to generic programming, which discards an approach like DrIFT and other approaches based on meta prog... |

9 | Feedback in an interactive equation solver
- Passier, Jeuring
- 2006
(Show Context)
Citation Context ...omials, rewriting a logical term to disjunctive normal form, rewriting relation algebra terms, developing (extended) lambda-calculus programs, and determining the derivative or integral of a function =-=[7, 8, 14, 17]-=-. Our domain reasoners offer the functionality as described above as web services [5]. Several exercise assistants, such as MathDox [4], ActiveMath [6], and the Freudenthal digital mathematics environ... |

8 | Optimizing generic functions
- Alimarine, Smetsers
- 2004
(Show Context)
Citation Context ...ys perform the necessary optimizations to remove the generic representation types and conversion functions from the compiled code. While this has been shown to be possible in at least the approach of =-=[1]-=-, in the general case it remains an open problem. In [19] a simple benchmark of generic programming libraries is performed. The two Uniplate functions tested are approximately 5 times slower than a ha... |

8 |
Generic programming—an introduction
- Backhouse, Jansson, et al.
- 1999
(Show Context)
Citation Context ...erating exercises, traversing terms, determining the top-level equality of two terms, etc. To avoid reimplementing the same functionality for every domain, we have used generic programming techniques =-=[2]-=- to implement rewriting, traversals, etc.1.2. USING GENERIC PROGRAMMING 3 once and for all domains. We have implemented our domain reasoners in Haskell. Initially we chose Haskell because it is a lan... |

8 | Feedback services for exercise assistants
- Gerdes, Heeren, et al.
- 2008
(Show Context)
Citation Context ...eveloping (extended) lambda-calculus programs, and determining the derivative or integral of a function [7, 8, 14, 17]. Our domain reasoners offer the functionality as described above as web services =-=[5]-=-. Several exercise assistants, such as MathDox [4], ActiveMath [6], and the Freudenthal digital mathematics environment [3], use our domain reasoning web services. At the moment we develop and maintai... |

8 | Recognizing strategies
- Heeren, Jeuring
- 2009
(Show Context)
Citation Context ...omials, rewriting a logical term to disjunctive normal form, rewriting relation algebra terms, developing (extended) lambda-calculus programs, and determining the derivative or integral of a function =-=[7, 8, 14, 17]-=-. Our domain reasoners offer the functionality as described above as web services [5]. Several exercise assistants, such as MathDox [4], ActiveMath [6], and the Freudenthal digital mathematics environ... |

7 |
Algebra en applets, leren en onderwijzen (algebra and applets, learning and teaching
- Boon, Drijvers
- 2005
(Show Context)
Citation Context ... domain reasoners offer the functionality as described above as web services [5]. Several exercise assistants, such as MathDox [4], ActiveMath [6], and the Freudenthal digital mathematics environment =-=[3]-=-, use our domain reasoning web services. At the moment we develop and maintain our own domain reasoners, but in the future we expect users of our services to add or adapt domains. Furthermore, we are ... |

7 | Optimizing generics is easy
- Magalhães, Holdermans, et al.
- 2010
(Show Context)
Citation Context ...s efficient than their handwritten counterparts. Compilers do not always perform the necessary optimizations to remove the generic representation types and conversion functions from the compiled code =-=[16]-=-. While this has been shown to be possible in at least the approach of Alimarine and Smetsers [1], in the general case it remains an open problem. Rodriguez Yakushev [21] performs a simple benchmark o... |

4 |
S.:Using IDEAS in teaching logic, lessons learned
- Lodder, Passier, et al.
- 2008
(Show Context)
Citation Context |

4 |
Generic programming with fixed points for parametrized datatypes
- Hesselink
- 2009
(Show Context)
Citation Context ...recursive occurrences. Regular does not support parametric datatypes or datatypes containing lists. However, we have investigated the possibility of changing the library to add support for parameters =-=[10]-=- and functor composition (of which datatypes with lists are a special case). Both extensions seem possible and do not lead to much increased code complexity. After having used Multirec, we realized ou... |

2 |
To appear
- Hesselink
- 2009
(Show Context)
Citation Context ...... :+: C F U -- false Regular does not support parametric datatypes or datatypes containing lists. However, we have investigated the possibility of changing the library to add support for parameters =-=[9]-=- [Pedro: correct this citation] and functor composition (of which datatypes with lists are a special case). Both extensions seem possible and do not lead to much increased code complexity. After havin... |

2 |
Towards Getting Generic Programming Ready for Prime Time
- Rodriguez
- 2009
(Show Context)
Citation Context ...or generic programming in Haskell. These differ substantially in expressiveness, datatypes supported and usability. Recently, a detailed comparison of generic programming libraries has been performed =-=[19, 21]-=-. We have used this comparison to choose a generic programming library. 1.3.1 Datatypes in the domain reasoners Our domain reasoners currently represent several domains, such as logical expressions, r... |

1 |
DrIFT User Guide. http://repetae.net/ computer/haskell/DrIFT/drift.html
- Winstanley, Meacham
- 2008
(Show Context)
Citation Context ...eneric programming in Haskell [11, 23]. Types (domains) play an important role in our software, and we also want to use typed approaches to generic programming, which rules out an approach like DrIFT =-=[24]-=- and other approaches based on metaprogramming or code generation. The essential technology used in our domain reasoners is rewriting (together with matching). When rewriting, we may apply any rewriti... |