Libraries for Generic Programming in Haskell

  • Johan Jeuring
  • Sean Leather
  • José Pedro Magalhães
  • Alexey Rodriguez Yakushev
Part of the Lecture Notes in Computer Science book series (LNCS, volume 5832)

Abstract

These lecture notes introduce libraries for datatype-generic programming in Haskell. We introduce three characteristic generic programming libraries: lightweight implementation of generics and dynamics, extensible and modular generics for the masses, and scrap your boilerplate. We show how to use them to use and write generic programs. In the case studies for the different libraries we introduce generic components of a medium-sized application which assists a student in solving mathematical exercises.

Preview

Unable to display preview. Download preview PDF.

Unable to display preview. Download preview PDF.

References

  1. Alexandrescu, A.: Modern C++ design: generic programming and design patterns applied. Addison-Wesley Longman Publishing Co., Inc., Boston (2001)Google Scholar
  2. Alimarine, A., Plasmijer, R.: A generic programming extension for Clean. In: Arts, T., Mohnen, M. (eds.) IFL 2002. LNCS, vol. 2312, pp. 168–186. Springer, Heidelberg (2002)CrossRefGoogle Scholar
  3. Alimarine, A., Smetsers, S.: Optimizing generic functions. In: Kozen, D. (ed.) MPC 2004. LNCS, vol. 3125, pp. 16–31. Springer, Heidelberg (2004)CrossRefGoogle Scholar
  4. Altenkirch, T., McBride, C.: Generic programming within dependently typed programming. In: Gibbons, J., Jeuring, J. (eds.) Generic Programming. IFIP, vol. 243, pp. 1–20. Kluwer Academic Publishers, Dordrecht (2003)CrossRefGoogle Scholar
  5. Backhouse, R., de Bruin, P., Malcolm, G., Voermans, E., van der Woude, J.: Relational catamorphisms. In: Möller, B. (ed.) Proceedings of the IFIP TC2/WG2.1 Working Conference on Constructing Programs, pp. 287–318. Elsevier Science Publishers B.V, Amsterdam (1991)Google Scholar
  6. 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
  7. Benke, M., Dybjer, P., Jansson, P.: Universes for generic programs and proofs in Sdependent type theory. Nordic Journal of Computing 10(4), 265–289 (2003)MathSciNetMATHGoogle Scholar
  8. Bernardy, J.-P., Jansson, P., Zalewski, M., Schupp, S., Priesnitz, A.: A comparison of C++ concepts and Haskell type classes. In: ACM SIGPLAN Workshop on Generic Programming. ACM, New York (2008)Google Scholar
  9. Bertot, Y., Castéran, P.: Interactive Theorem Proving and Program Development. In: Coq’Art: The Calculus of Inductive Constructions. Texts in Theoretical Computer Science. EATCS (2004), ISBN 3-540-20854-2Google Scholar
  10. Bird, R., Meertens, L.: Nested datatypes. In: Jeuring, J. (ed.) MPC 1998. LNCS, vol. 1422, pp. 52–67. Springer, Heidelberg (1998)CrossRefGoogle Scholar
  11. Bird, R., de Moor, O.: Algebra of programming. Prentice-Hall, Englewood Cliffs (1997)MATHGoogle Scholar
  12. Cheney, J., Hinze, R.: A lightweight implementation of generics and dynamics. In: Chakravarty, M. (ed.) Proceedings of the 2002 ACM SIGPLAN workshop on Haskell, Haskell 2002, pp. 90–104. ACM, New York (2002)Google Scholar
  13. Claessen, K., Hughes, J.: Quickcheck: a lightweight tool for random testing of Haskell programs. In: Proceedings of the 5th ACM SIGPLAN International Conference on Functional Programming, ICFP 2000, pp. 268–279. ACM, New York (2000)Google Scholar
  14. Clavel, M., Durán, F., Martí-Oliet, N.: Polytypic programming in Maude. Electronic Notes in Theoretical Computer Science, vol. 36, pp. 339–360 (2000)Google Scholar
  15. Dornan, C., Jones, I., Marlow, S.: Alex User Guide (2003), http://www.haskell.org/alex
  16. Fokkinga, M.M.: Law and Order in Algorithmics, PhD thesis. University of Twente (1992)Google Scholar
  17. Forman, I.R., Danforth, S.H.: Putting metaclasses to work: a new dimension in object-oriented programming. Addison Wesley Longman Publishing Co., Inc., Redwood City (1999)Google Scholar
  18. Garcia, R., Järvi, J., Lumsdaine, A., Siek, J., Willcock, J.: An extended comparative study of language support for generic programming. Journal of Functional Programming 17(2), 145–205 (2007)CrossRefMATHGoogle Scholar
  19. Gibbons, J.: Datatype-generic programming. In: Backhouse, R., Gibbons, J., Hinze, R., Jeuring, J. (eds.) SSDGP 2006. LNCS, vol. 4719, pp. 1–71. Springer, Heidelberg (2007)CrossRefGoogle Scholar
  20. The Haskell Prime list. Haskell prime (2006), http://hackage.haskell.org/trac/haskell-prime
  21. Hinze, R.: Generic programs and proofs. Bonn University, Habilitation (2000)Google Scholar
  22. Hinze, R.: Generics for the masses. In: Proceedings of the ACM SIGPLAN International Conference on Functional Programming, ICFP 2004, pp. 236–243. ACM, New York (2004)Google Scholar
  23. Hinze, R.: Generics for the masses. Journal of Functional Programming 16, 451–482 (2006)MathSciNetCrossRefMATHGoogle Scholar
  24. Hinze, R., Jeuring, J.: Generic Haskell: applications. In: Backhouse, R., Gibbons, J. (eds.) Generic Programming. LNCS, vol. 2793, pp. 57–96. Springer, Heidelberg (2003)CrossRefGoogle Scholar
  25. Hinze, R., Jeuring, J.: Generic Haskell: practice and theory. In: Backhouse, R., Gibbons, J. (eds.) Generic Programming. LNCS, vol. 2793, pp. 1–56. Springer, Heidelberg (2003)CrossRefGoogle Scholar
  26. Hinze, R., Löh, A.: Generic programming in 3D. Science of Computer Programming (to appear, 2009)Google Scholar
  27. Hinze, R., Löh, A.: “Scrap Your Boilerplate” revolutions. In: Uustalu, T. (ed.) MPC 2006. LNCS, vol. 4014, pp. 180–208. Springer, Heidelberg (2006)CrossRefGoogle Scholar
  28. Hinze, R., Löh, A.: Generic programming, now! In: Backhouse, R., Gibbons, J., Hinze, R., Jeuring, J. (eds.) SSDGP 2006. LNCS, vol. 4719, pp. 150–208. Springer, Heidelberg (2007)CrossRefGoogle Scholar
  29. Hinze, R., Löh, A., Oliveira, B.C.d.S.: “Scrap Your Boilerplate” reloaded. In: Hagiya, M., Wadler, P. (eds.) FLOPS 2006. LNCS, vol. 3945, pp. 13–29. Springer, Heidelberg (2006)CrossRefGoogle Scholar
  30. Hinze, R., Jeuring, J., Löh, A.: Comparing approaches to generic programming in Haskell. In: Backhouse, R., Gibbons, J., Hinze, R., Jeuring, J. (eds.) SSDGP 2006. LNCS, vol. 4719, pp. 72–149. Springer, Heidelberg (2007)CrossRefGoogle Scholar
  31. Holdermans, S., Jeuring, J., Löh, A., Rodriguez, A.: Generic views on data types. In: Uustalu, T. (ed.) MPC 2006. LNCS, vol. 4014, pp. 209–234. Springer, Heidelberg (2006)CrossRefGoogle Scholar
  32. Jeuring, J., Leather, S., Magalhães, J.P., Yakushev, A.R.: Libraries for generic programming in Haskell. Technical Report UU-CS-2008-025, Department of Information and Computing Sciences. Utrecht University (2008)Google Scholar
  33. Karvonen, V.A.J.: Generics for the working ML’er. In: Proceedings of the 2007 Workshop on ML, ML 2007, pp. 71–82. ACM, New York (2007)Google Scholar
  34. Kiselyov, O.: Smash your boilerplate without class and typeable (2006), http://article.gmane.org/gmane.comp.lang.haskell.general/14086
  35. Kiselyov, O.: Compositional gmap in SYB1 (2008), http://www.haskell.org/pipermail/generics/2008-July/000362.html
  36. Lämmel, R., Jones, S.P.: Scrap your boilerplate: a practical approach to generic programming. In: Proceedings of the ACM SIGPLAN Workshop on Types in Language Design and Implementation, TLDI 2003, pp. 26–37. ACM, New York (2003)CrossRefGoogle Scholar
  37. Lämmel, R., Jones, S.P.: Scrap more boilerplate: reflection, zips, and generalised casts. In: Proceedings of the ACM SIGPLAN International Conference on Functional Programming, ICFP 2004, pp. 244–255. ACM, New York (2004)Google Scholar
  38. Lämmel, R., Jones, S.P.: 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, New York (2005)Google Scholar
  39. Lempsink, E., Leather, S., Löh, A.: Type-safe diff for families of datatypes (submitted for publication, 2009)Google Scholar
  40. Lodder, J., Jeuring, J., Passier, H.: An interactive tool for manipulating logical formulae. In: Manzano, M., Pérez Lancho, B., Gil, A. (eds.) Proceedings of the Second International Congress on Tools for Teaching Logic (2006)Google Scholar
  41. Löh, A.: Exploring Generic Haskell. PhD thesis, Utrecht University (2004)Google Scholar
  42. Löh, A., Hinze, R.: Open data types and open functions. In: Maher, M. (ed.) Proceedings of the 8th ACM SIGPLAN symposium on Principles and practice of declarative programming, PPDP 2006, pp. 133–144. ACM, New York (2006)Google Scholar
  43. Malcolm, G.: Algebraic data types and program transformation. PhD thesis, Department of Computing Science. Groningen University (1990)Google Scholar
  44. Marlow, S., Gill, A.: Happy User Guide (1997), http://www.haskell.org/happy
  45. Meertens, L.: Calculate polytypically! In: Kuchen, H., Swierstra, S.D. (eds.) PLILP 1996. LNCS, vol. 1140, pp. 1–16. Springer, Heidelberg (1996)CrossRefGoogle Scholar
  46. Meijer, E., Fokkinga, M., Paterson, R.: Functional programming with bananas, lenses, envelopes and barbed wire. In: Hughes, J. (ed.) FPCA 1991. LNCS, vol. 523, pp. 124–144. Springer, Heidelberg (1991)CrossRefGoogle Scholar
  47. Milner, R.: A theory of type polymorphism in programming. Journal of Computer and System Sciences 17, 348–375 (1978)MathSciNetCrossRefMATHGoogle Scholar
  48. Mitchell, N., Runciman, C.: Uniform boilerplate and list processing. In: Proceedings of the 2007 ACM SIGPLAN workshop on Haskell, Haskell 2007. ACM, New York (2007)Google Scholar
  49. Norell, U.: Towards a practical programming language based on dependent type theory. PhD thesis, Chalmers University of Technology and Göteborg University (2007)Google Scholar
  50. Norell, U., Jansson, P.: Polytypic programming in Haskell. In: Trinder, P., Michaelson, G.J., Peña, R. (eds.) IFL 2003. LNCS, vol. 3145, pp. 168–184. Springer, Heidelberg (2004)CrossRefGoogle Scholar
  51. Norell, U., Jansson, P.: Prototyping generic programming in Template Haskell. In: Kozen, D. (ed.) MPC 2004. LNCS, vol. 3125, pp. 314–333. Springer, Heidelberg (2004)CrossRefGoogle Scholar
  52. Bruno C. d. S. Oliveira, Hinze, R., Löh, A.: Extensible and modular generics for the masses. In: Nilsson, H. (ed.) Revised Selected Papers from the Seventh Symposium on Trends in Functional Programming, TFP 2006, vol. 7, pp. 199–216 (2006) Google Scholar
  53. Palsberg, J., Barry Jay, C.: The essence of the visitor pattern. In: Proceedings of the 22nd IEEE Conference on International Computer Software and Applications, COMPSAC 1998, pp. 9–15 (1998)Google Scholar
  54. Passier, H., Jeuring, J.: Feedback in an interactive equation solver. In: Seppälä, M., Xambo, S., Caprotti, O. (eds.) Proceedings of the Web Advanced Learning Conference and Exhibition, WebALT 2006, pp. 53–68. Oy WebALT Inc. (2006)Google Scholar
  55. Pfeifer, H., Ruess, H.: Polytypic proof construction. In: Bertot, Y., Dowek, G., Hirschowitz, A., Paulin, C., Théry, L. (eds.) TPHOLs 1999. LNCS, vol. 1690, pp. 55–72. Springer, Heidelberg (1999)CrossRefGoogle Scholar
  56. Reinke, C.: Traversable functor data, or: X marks the spot (2008), http://www.haskell.org/pipermail/generics/2008-June/000343.html
  57. Rodriguez, A.: Towards Getting Generic Programming Ready for Prime Time. PhD thesis, Utrecht University (2009)Google Scholar
  58. Rodriguez, A., Jeuring, J., Jansson, P., Gerdes, A., Kiselyov, O., Oliveira, B.C.d.S.: Comparing libraries for generic programming in haskell. Technical report, Utrecht University (2008a)Google Scholar
  59. Rodriguez, A., Jeuring, J., Jansson, P., Gerdes, A., Kiselyov, O., Oliveira, B.C.d.S.: Comparing libraries for generic programming in haskell. In: Haskell Symposium 2008 (2008b)Google Scholar
  60. Rodriguez, A., Holdermans, S., Löh, A., Jeuring, J.: Generic programming with fixed points for mutually recursive datatypes. In: Proceedings of the ACM SIGPLAN International Conference on Functional Programming, ICFP 2009 (2009)Google Scholar
  61. Sheard, T.: Using MetaML: A staged programming language. In: Revised Lectures of the Third International School on Advanced Functional Programming (1999)Google Scholar
  62. Sheard, T., Jones, S.P.: Template metaprogramming for Haskell. In: Chakravarty, M.M.T. (ed.) ACM SIGPLAN Haskell Workshop 2002, pp. 1–16. ACM, New York (2002)Google Scholar
  63. Taha, W.: Multi-Stage Programming: Its Theory and Applications. PhD thesis, Oregon Graduate Institute of Science and Technology (1999)Google Scholar
  64. Universiteit Utrecht. EMGM (2008), http://www.cs.uu.nl/wiki/GenericProgramming/EMGM
  65. Wadler, P.: Comprehending monads. In: Proceedings of the 1990 ACM conference on LISP and Functional Programming, LFP 1990, pp. 61–78. ACM, New York (1990)CrossRefGoogle Scholar
  66. Wadler, P., Blott, S.: How to make ad-hoc polymorphism less ad-hoc. In: Conference Record of the 16th Annual ACM Symposium on Principles of Programming Languages, pp. 60–76. ACM, New York (1989)Google Scholar
  67. Weirich, S.: RepLib: a library for derivable type classes. In: Proceedings of the 2006 ACM SIGPLAN workshop on Haskell, Haskell 2006, pp. 1–12. ACM, New York (2006)CrossRefGoogle Scholar
  68. Yallop, J.: Practical generic programming in OCaml. In: Proceedings of the 2007 workshop on Workshop on ML, ML 2007, pp. 83–94. ACM, New York (2007)CrossRefGoogle Scholar

Copyright information

© Springer-Verlag Berlin Heidelberg 2009

Authors and Affiliations

  • Johan Jeuring
    • 1
  • Sean Leather
    • 1
  • José Pedro Magalhães
    • 1
  • Alexey Rodriguez Yakushev
    • 1
  1. 1.Universiteit UtrechtThe Netherlands

Personalised recommendations