Advertisement

“Scrap Your Boilerplate” Reloaded

  • Ralf Hinze
  • Andres Löh
  • Bruno C. d. S. Oliveira
Part of the Lecture Notes in Computer Science book series (LNCS, volume 3945)

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.

Keywords

Data Type Priority Queue Functional Programming Type Argument Abstract Syntax Tree 
These keywords were added by machine and not by the authors. This process is experimental and the keywords may be updated as the learning algorithm improves.

Preview

Unable to display preview. Download preview PDF.

Unable to display preview. Download preview PDF.

References

  1. 1.
    Lämmel, R., Peyton Jones, S.: Scrap your boilerplate: a practical design pattern for generic programming. In: Types in Language Design and Implementation (2003)Google Scholar
  2. 2.
    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)CrossRefGoogle Scholar
  3. 3.
    Löh, A.: Exploring Generic Haskell. PhD thesis, Utrecht University (2004)Google Scholar
  4. 4.
    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)Google Scholar
  5. 5.
    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)CrossRefGoogle Scholar
  6. 6.
    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)Google Scholar
  7. 7.
    Peyton Jones, S. (ed.): Haskell 98 Language and Libraries: The Revised Report. Cambridge University Press, Cambridge (2003)MATHGoogle Scholar
  8. 8.
    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
  9. 9.
    GHC Team: The Glasgow Haskell Compiler User’s Guide (2005), http://haskell.org/ghc/docs/latest/users_guide.ps.gz
  10. 10.
    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)Google Scholar
  11. 11.
    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
  12. 12.
    Holdermans, S., Jeuring, J., Löh, A.: Generic views on data types. Technical Report UU-CS-2005-012, Utrecht University (2005)Google Scholar
  13. 13.
    Benke, M., Dybjer, P., Jansson, P.: Universes for generic programs and proofs in dependent type theory. Nordic Journal of Computing 10, 265–289 (2003)MathSciNetMATHGoogle Scholar
  14. 14.
    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)Google Scholar
  15. 15.
    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 29Google Scholar
  16. 16.
    Oliveira, B., Gibbons, J.: Typecase: A design pattern for type-indexed functions. In: Haskell Workshop, pp. 98–109 (2005)Google Scholar
  17. 17.
    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)Google Scholar
  18. 18.
    Wadler, P.: Theorems for free! Functional Programming and Computer Architecture (1989)Google Scholar
  19. 19.
    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)Google Scholar
  20. 20.
    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)Google Scholar
  21. 21.
    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)CrossRefGoogle Scholar
  22. 22.
    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)CrossRefGoogle Scholar
  23. 23.
    Holdermans, S.: Generic views. Master’s thesis, Utrecht University (2005)Google Scholar
  24. 24.
    Reig, F.: Generic proofs for combinator-based generic programs. In: Loidl, H.W. (ed.) Trends in Functional Programming, vol. 5. Intellect (2006)Google Scholar

Copyright information

© Springer-Verlag Berlin Heidelberg 2006

Authors and Affiliations

  • Ralf Hinze
    • 1
  • Andres Löh
    • 1
  • Bruno C. d. S. Oliveira
    • 2
  1. 1.Institut für Informatik IIIUniversität BonnBonnGermany
  2. 2.Oxford University Computing LaboratoryOxfordUK

Personalised recommendations