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.
Preview
Unable to display preview. Download preview PDF.
Similar content being viewed by others
References
Lämmel, R., Peyton Jones, S.: Scrap your boilerplate: a practical design pattern for generic programming. In: Types in Language Design and Implementation (2003)
Jansson, P., Jeuring, J.: PolyP – a polytypic programming language extension. In: Conference Record 24th ACM SIGPLAN-SIGACT Symposium on Principles of Programming Languages, Paris, France, pp. 470–482. ACM Press, New York (1997)
Löh, A.: Exploring Generic Haskell. PhD thesis, Utrecht University (2004)
Löh, A., Jeuring, J., Clarke, D., Hinze, R., Rodriguez, A., de Wit, J.: The Generic Haskell user’s guide, version 1.42 (Coral). Technical Report UU-CS-2005-004, Institute of Information and Computing Sciences, Utrecht University (2005)
Xi, H., Chen, C., Chen, G.: Guarded recursive datatype constructors. In: Proceedings of the ACM SIGPLAN-SIGACT symposium on Principles of Programming Languages (POPL 2003), pp. 224–235. ACM Press, New York (2003)
Peyton Jones, S., Washburn, G., Weirich, S.: Wobbly types: Type inference for generalised algebraic data types. Technical Report MS-CIS-05-26, University of Pennsylvania (2004)
Peyton Jones, S. (ed.): Haskell 98 Language and Libraries: The Revised Report. Cambridge University Press, Cambridge (2003)
Hinze, R., Löh, A., Oliveira, B.: Scrap Your Boilerplate reloaded. Technical report, Universität Bonn (2006), http://www.informatik.unionn.de/~loeh/SYB0.html
GHC Team: The Glasgow Haskell Compiler User’s Guide (2005), http://haskell.org/ghc/docs/latest/users_guide.ps.gz
Wadler, P.: Views: a way for pattern matching to cohabit with data abstraction. In: Principles of Programming Languages, pp. 307–313. ACM Press, New York (1987)
Burton, F.W., Meijer, E., Sansom, P., Thompson, S., Wadler, P.: Views: an extension to Haskell pattern matching (1996), http://www.haskell.org/development/views.html
Holdermans, S., Jeuring, J., Löh, A.: Generic views on data types. Technical Report UU-CS-2005-012, Utrecht University (2005)
Benke, M., Dybjer, P., Jansson, P.: Universes for generic programs and proofs in dependent type theory. Nordic Journal of Computing 10, 265–289 (2003)
Visser, E.: Language independent traversals for program transformation. In: Jeuring, J. (ed.) Workshop on Generic Programming (WGP 2000), Ponte de Lima, Portugal, Technical Report UU-CS-2000-19, Department of Information and Computing Sciences, Universiteit Utrecht (2000)
Hinze, R.: Fun with phantom types. In: Gibbons, J., de Moor, O. (eds.) The Fun of Programming, Palgrave, pp. 245–262 (2003); Scrap Your Boilerplate Reloaded 29
Oliveira, B., Gibbons, J.: Typecase: A design pattern for type-indexed functions. In: Haskell Workshop, pp. 98–109 (2005)
Li, H., Reinke, C., Thompson, S.: Tool support for refactoring functional programs. In: Jeuring, J. (ed.) HaskellWorkshop, pp. 27–38. Association for Computing Machinery (2003)
Wadler, P.: Theorems for free! Functional Programming and Computer Architecture (1989)
Lämmel, R., Peyton Jones, S.: Scrap more boilerplate: reflection, zips, and generalized casts. In: Proceedings of the ACM SIGPLAN International Conference on Functional Programming (ICFP 2004), pp. 244–255. ACM Press, New York (2004)
Lämmel, R., Peyton Jones, S.: Scrap your boilerplate with class: extensible generic functions. In: Proceedings of the ACM SIGPLAN International Conference on Functional Programming (ICFP 2005), pp. 204–215. ACM Press, New York (2005)
Backhouse, R., Jansson, P., Jeuring, J., Meertens, L.: Generic programming: An introduction. In: Swierstra, S.D., Oliveira, J.N. (eds.) AFP 1998. LNCS, vol. 1608, pp. 28–115. Springer, Heidelberg (1999)
Hinze, R.: Polytypic values possess polykinded types. In: Backhouse, R., Oliveira, J.N. (eds.) MPC 2000. LNCS, vol. 1837, pp. 2–27. Springer, Heidelberg (2000)
Holdermans, S.: Generic views. Master’s thesis, Utrecht University (2005)
Reig, F.: Generic proofs for combinator-based generic programs. In: Loidl, H.W. (ed.) Trends in Functional Programming, vol. 5. Intellect (2006)
Author information
Authors and Affiliations
Editor information
Editors and Affiliations
Rights and permissions
Copyright information
© 2006 Springer-Verlag Berlin Heidelberg
About this paper
Cite this paper
Hinze, R., Löh, A., Oliveira, B.C.d.S. (2006). “Scrap Your Boilerplate” Reloaded. In: Hagiya, M., Wadler, P. (eds) Functional and Logic Programming. FLOPS 2006. Lecture Notes in Computer Science, vol 3945. Springer, Berlin, Heidelberg. https://doi.org/10.1007/11737414_3
Download citation
DOI: https://doi.org/10.1007/11737414_3
Publisher Name: Springer, Berlin, Heidelberg
Print ISBN: 978-3-540-33438-5
Online ISBN: 978-3-540-33439-2
eBook Packages: Computer ScienceComputer Science (R0)