## Scrap your boilerplate” reloaded (2006)

### Cached

### Download Links

Citations: | 41 - 11 self |

### BibTeX

@INPROCEEDINGS{Hinze06scrapyour,

author = {Ralf Hinze and Andres Löh and Bruno C. D. S. Oliveira},

title = {Scrap your boilerplate” reloaded},

booktitle = {},

year = {2006},

pages = {13--29},

publisher = {Springer}

}

### Years of Citing Articles

### OpenURL

### Abstract

Abstract. The paper “Scrap your boilerplate ” (SYB) introduces a combinator library for generic programming that offers generic traversals and queries. Classically, support for generic programming consists of two essential ingredients: a way to write (type-)overloaded functions, and independently, a way to access the structure of data types. SYB seems to lack the second. As a consequence, it is difficult to compare with other approaches such as PolyP or Generic Haskell. In this paper we reveal the structural view that SYB builds upon. This allows us to define the combinators as generic functions in the classical sense. We explain the SYB approach in this changed setting from ground up, and use the understanding gained to relate it to other generic programming approaches. Furthermore, we show that the SYB view is applicable to a very large class of data types, including generalized algebraic data types. 1

### Citations

329 | Theorems for free
- Wadler
- 1989
(Show Context)
Citation Context ...e a → a some . . . = . . . some t = fromSpine some ′ But we cannot define some ′ ::Spine a, because that would yield fromSpine some ′ :: ∀a.a, which has to be ⊥ according to the parametricity theorem =-=[18]-=-. Due to the well-definedness of fromSpine, some ′ would have to be ⊥, too. It is nevertheless possible to define some :: Type a → a, but only if Type is augmented with more information about the type... |

174 | PolyP – a polytypic programming language extension
- Jansson, Jeuring
- 1997
(Show Context)
Citation Context ...ily defined in the spine view than using the combinators underlying the original SYB library. – We compare the expressive power and applicability of the spine view to the original SYB paper, to PolyP =-=[2]-=- and to Generic Haskell [3, 4]. – Furthermore, we show that the SYB view is applicable to a very large class of data types, including generalized algebraic data types (GADTs) [5, 6].s2 R. Hinze, A. Lö... |

141 | Views: a way for pattern matching to cohabit with data abstraction
- Wadler
- 1987
(Show Context)
Citation Context ...n lists is likely to be less efficient than the one using the tree. Such different views on a data structure need not be mutually exclusive. Wadler and others have proposed language support for views =-=[10, 11]-=-. Many functions on a single data type follow common traversal and recursion patterns. Instead of defining each function by case analysis, it is possible to define combinators that capture these patte... |

136 | Scrap your boilerplate: A practical design pattern for generic programming
- Lämmel, Jones
- 2003
(Show Context)
Citation Context ...proaches. Furthermore, we show that the SYB view is applicable to a very large class of data types, including generalized algebraic data types. 1 Introduction The paper “Scrap your boilerplate” (SYB) =-=[1]-=- introduces a combinator library for generic programming that offers generic traversals and queries. Classically, support for generic programming consists of two essential ingredients: a way to write ... |

129 | Guarded recursive datatype constructors
- Xi, Chen, et al.
- 2003
(Show Context)
Citation Context ...l SYB paper, to PolyP [2] and to Generic Haskell [3, 4]. – Furthermore, we show that the SYB view is applicable to a very large class of data types, including generalized algebraic data types (GADTs) =-=[5, 6]-=-.s2 R. Hinze, A. Löh, and B. Oliveira We use Haskell [7] for all our examples. The source code of this paper [8] constitutes a Haskell program that can be compiled by GHC [9] in order to test and expe... |

107 | Polytypic values possess polykinded types
- Hinze
- 2000
(Show Context)
Citation Context ...ideas underlying the generic programming extension PolyP [2] go back to the categorical notions of functors and catamorphisms, which are independent of the data type in question [21]. Generic Haskell =-=[22]-=- was motivated by the desire to overcome the restrictions of PolyP. Due to the different backgrounds, it is not surprising that SYB and generic programming have remained difficult to compare for a lon... |

84 | Generic programming – an introduction
- Backhouse, Jansson, et al.
- 1999
(Show Context)
Citation Context ...act syntax trees. The ideas underlying the generic programming extension PolyP [2] go back to the categorical notions of functors and catamorphisms, which are independent of the data type in question =-=[21]-=-. Generic Haskell [22] was motivated by the desire to overcome the restrictions of PolyP. Due to the different backgrounds, it is not surprising that SYB and generic programming have remained difficul... |

68 | Exploring Generic Haskell
- Löh
- 2004
(Show Context)
Citation Context ...ew than using the combinators underlying the original SYB library. – We compare the expressive power and applicability of the spine view to the original SYB paper, to PolyP [2] and to Generic Haskell =-=[3, 4]-=-. – Furthermore, we show that the SYB view is applicable to a very large class of data types, including generalized algebraic data types (GADTs) [5, 6].s2 R. Hinze, A. Löh, and B. Oliveira We use Hask... |

62 |
Scrap your boilerplate with class: extensible generic functions. Pages 204–215 of: ICFP’05
- Lämmel, Jones, et al.
- 2005
(Show Context)
Citation Context ...ty test. 8 Class-based implementation In this section, we combine the idea of the Spine view with an alternative way to express overloaded functions, using classes as described in the third SYB paper =-=[20]-=-, short SYB 3 in the remainder of this section. We assume knowledge with the material in that paper, as some of the techniques described there are quite subtle. The advantage of this presentation (whi... |

59 | Scrap more boilerplate: reflection, zips, and generalised casts
- Lämmel, Jones
- 2004
(Show Context)
Citation Context ... Oliveira some ′ :: TypeSpine a → a some ′ (TypeAs c ) = c some ′ (f � a) = some ′ f (some a) . Indeed, the gunfold function that is added to the set of predefined combinators in the second SYB paper =-=[19]-=- is derived from the catamorphism on Constr much like gfoldl is derived from the catamorphism on Spine. Unfortunately though, there is no relation between gunfold and an anamorphism on Spine. We can, ... |

48 | Wobbly types: type inference for generalised algebraic data types
- Jones, Washburn, et al.
- 2004
(Show Context)
Citation Context ...l SYB paper, to PolyP [2] and to Generic Haskell [3, 4]. – Furthermore, we show that the SYB view is applicable to a very large class of data types, including generalized algebraic data types (GADTs) =-=[5, 6]-=-.s2 R. Hinze, A. Löh, and B. Oliveira We use Haskell [7] for all our examples. The source code of this paper [8] constitutes a Haskell program that can be compiled by GHC [9] in order to test and expe... |

46 |
Tool support for refactoring functional programs
- Li, Reinke, et al.
- 2003
(Show Context)
Citation Context ...t syntax tree, annotating a structure with additional information, optimizing or simplifying a structure etc. Here is a simplified example of a transformation performed by the Haskell refactorer HaRe =-=[17]-=-, which rewrites a Haskell if construct into an equivalent case expression according to the rule if e then e1 else e2 � case e of True → e1; False → e2 . We assume a suitable abstract syntax for Haske... |

42 | Universes for generic programs and proofs in dependent type theory
- Benke, Dybjer, et al.
- 2003
(Show Context)
Citation Context ...s of functions we can write. The concepts4 R. Hinze, A. Löh, and B. Oliveira of generic views is explained further in a recent paper [12], and is related to universes in dependently-typed programming =-=[13]-=-. In summary, it turns out that there is a close analogy between plain functional and generic programming: the concepts of views, function definition by case analysis, and combinators occur in both se... |

33 |
Fun with phantom types
- Hinze
- 2003
(Show Context)
Citation Context ...edded languages, so it seems a good idea to try to embed the type language in Haskell. The following way to encode overloaded functions is not new: it is based on Hinze’s “Fun of Programming” chapter =-=[15]-=- and has been used widely elsewhere [16]. The whole point of static types is that they can be used at compile time to distinguish programs, hence we certainly do not want to use an unparameterized dat... |

26 | Language independent traversals for program transformation
- Visser
- 2000
(Show Context)
Citation Context ... fact, the very combinators we have used above, foldTree and mapTree, are typical candidates for generalization. The paper “Scrap your boilerplate” (SYB) describes a library for strategic programming =-=[14]-=-, i.e., it offers combinators for generic traversals and queries on terms. Two central combinators of the SYB library are everywhere to traverse a data structure and modify it in certain places, and e... |

26 | TypeCase: A design pattern for type-indexed functions
- Oliveira, Gibbons
- 2005
(Show Context)
Citation Context ... to try to embed the type language in Haskell. The following way to encode overloaded functions is not new: it is based on Hinze’s “Fun of Programming” chapter [15] and has been used widely elsewhere =-=[16]-=-. The whole point of static types is that they can be used at compile time to distinguish programs, hence we certainly do not want to use an unparameterized data type Type to represent types. Instead,... |

25 | Generic views on data types
- Holdermans, Jeuring, et al.
- 2006
(Show Context)
Citation Context ...-products view which is more widely applicable, but limits the class of functions we can write. The concepts4 R. Hinze, A. Löh, and B. Oliveira of generic views is explained further in a recent paper =-=[12]-=-, and is related to universes in dependently-typed programming [13]. In summary, it turns out that there is a close analogy between plain functional and generic programming: the concepts of views, fun... |

9 |
Generic proofs for combinator-based generic programs
- Reig
(Show Context)
Citation Context ...re expect that it is easier to prove algebraic properties about SYB (such as mapT copy = copy where copy = id is the identity traversal) in this setting. For example, we believe that the work of Reig =-=[24]-=- could be recast using our approach, leading to shorter and more concise proofs.s“Scrap Your Boilerplate” Reloaded 21 Acknowledgements We thank Jeremy Gibbons, Ralf Lämmel, Pablo Nogueira, Simon Peyto... |

8 | The Generic Haskell user’s guide, version 1.42 (Coral
- Löh, Jeuring, et al.
- 2005
(Show Context)
Citation Context ...ew than using the combinators underlying the original SYB library. – We compare the expressive power and applicability of the spine view to the original SYB paper, to PolyP [2] and to Generic Haskell =-=[3, 4]-=-. – Furthermore, we show that the SYB view is applicable to a very large class of data types, including generalized algebraic data types (GADTs) [5, 6].s2 R. Hinze, A. Löh, and B. Oliveira We use Hask... |

7 |
Views: An Extension to Haskell Pattern Matching. Available from http://www.haskell.org/development/views.html
- Burton, Meijer, et al.
- 1996
(Show Context)
Citation Context ...n lists is likely to be less efficient than the one using the tree. Such different views on a data structure need not be mutually exclusive. Wadler and others have proposed language support for views =-=[10, 11]-=-. Many functions on a single data type follow common traversal and recursion patterns. Instead of defining each function by case analysis, it is possible to define combinators that capture these patte... |

5 |
Scrap your boilerplate: a practical design pattern for generic programming
- Lmmel, Jones
- 2003
(Show Context)
Citation Context ...proaches. Furthermore, we show that the SYB view is applicable to a very large class of data types, including generalized algebraic data types. 1 Introduction The paper “Scrap your boilerplate” (SYB) =-=[1]-=- introduces a combinator library for generic programming that offers generic traversals and queries. Classically, support for generic programming consists of two essential ingredients: a way to write ... |

4 |
Generic views
- Holdermans
- 2005
(Show Context)
Citation Context ...the restrictions of PolyP. Due to the different backgrounds, it is not surprising that SYB and generic programming have remained difficult to compare for a long time. The recent work on generic views =-=[12, 23]-=- has been an attempt to unify different approaches. We believe that we bridged the gap in this paper for the first time, by presenting the Spine data type which encodes the SYB approach faithfully. Ou... |

2 |
The Glasgow Haskell Compiler User’s Guide. (2005) Available from http://haskell.org/ghc/docs/latest/users_guide.ps.gz
- Team
(Show Context)
Citation Context ...aic data types (GADTs) [5, 6].s2 R. Hinze, A. Löh, and B. Oliveira We use Haskell [7] for all our examples. The source code of this paper [8] constitutes a Haskell program that can be compiled by GHC =-=[9]-=- in order to test and experiment with our implementation. While our implementation is not directly usable as a separate library, because it is not extensible (new data types cannot be added in a compo... |