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.
Access this chapter
Tax calculation will be finalised at checkout
Purchases are for personal use only
Preview
Unable to display preview. Download preview PDF.
References
Alexandrescu, A.: Modern C++ design: generic programming and design patterns applied. Addison-Wesley Longman Publishing Co., Inc., Boston (2001)
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)
Alimarine, A., Smetsers, S.: Optimizing generic functions. In: Kozen, D. (ed.) MPC 2004. LNCS, vol. 3125, pp. 16–31. Springer, Heidelberg (2004)
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)
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)
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)
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)
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)
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-2
Bird, R., Meertens, L.: Nested datatypes. In: Jeuring, J. (ed.) MPC 1998. LNCS, vol. 1422, pp. 52–67. Springer, Heidelberg (1998)
Bird, R., de Moor, O.: Algebra of programming. Prentice-Hall, Englewood Cliffs (1997)
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)
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)
Clavel, M., Durán, F., Martí-Oliet, N.: Polytypic programming in Maude. Electronic Notes in Theoretical Computer Science, vol. 36, pp. 339–360 (2000)
Dornan, C., Jones, I., Marlow, S.: Alex User Guide (2003), http://www.haskell.org/alex
Fokkinga, M.M.: Law and Order in Algorithmics, PhD thesis. University of Twente (1992)
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)
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)
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)
The Haskell Prime list. Haskell prime (2006), http://hackage.haskell.org/trac/haskell-prime
Hinze, R.: Generic programs and proofs. Bonn University, Habilitation (2000)
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)
Hinze, R.: Generics for the masses. Journal of Functional Programming 16, 451–482 (2006)
Hinze, R., Jeuring, J.: Generic Haskell: applications. In: Backhouse, R., Gibbons, J. (eds.) Generic Programming. LNCS, vol. 2793, pp. 57–96. Springer, Heidelberg (2003)
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)
Hinze, R., Löh, A.: Generic programming in 3D. Science of Computer Programming (to appear, 2009)
Hinze, R., Löh, A.: “Scrap Your Boilerplate” revolutions. In: Uustalu, T. (ed.) MPC 2006. LNCS, vol. 4014, pp. 180–208. Springer, Heidelberg (2006)
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)
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)
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)
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)
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)
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)
Kiselyov, O.: Smash your boilerplate without class and typeable (2006), http://article.gmane.org/gmane.comp.lang.haskell.general/14086
Kiselyov, O.: Compositional gmap in SYB1 (2008), http://www.haskell.org/pipermail/generics/2008-July/000362.html
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)
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)
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)
Lempsink, E., Leather, S., Löh, A.: Type-safe diff for families of datatypes (submitted for publication, 2009)
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)
Löh, A.: Exploring Generic Haskell. PhD thesis, Utrecht University (2004)
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)
Malcolm, G.: Algebraic data types and program transformation. PhD thesis, Department of Computing Science. Groningen University (1990)
Marlow, S., Gill, A.: Happy User Guide (1997), http://www.haskell.org/happy
Meertens, L.: Calculate polytypically! In: Kuchen, H., Swierstra, S.D. (eds.) PLILP 1996. LNCS, vol. 1140, pp. 1–16. Springer, Heidelberg (1996)
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)
Milner, R.: A theory of type polymorphism in programming. Journal of Computer and System Sciences 17, 348–375 (1978)
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)
Norell, U.: Towards a practical programming language based on dependent type theory. PhD thesis, Chalmers University of Technology and Göteborg University (2007)
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)
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)
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)
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)
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)
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)
Reinke, C.: Traversable functor data, or: X marks the spot (2008), http://www.haskell.org/pipermail/generics/2008-June/000343.html
Rodriguez, A.: Towards Getting Generic Programming Ready for Prime Time. PhD thesis, Utrecht University (2009)
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)
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)
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)
Sheard, T.: Using MetaML: A staged programming language. In: Revised Lectures of the Third International School on Advanced Functional Programming (1999)
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)
Taha, W.: Multi-Stage Programming: Its Theory and Applications. PhD thesis, Oregon Graduate Institute of Science and Technology (1999)
Universiteit Utrecht. EMGM (2008), http://www.cs.uu.nl/wiki/GenericProgramming/EMGM
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)
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)
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)
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)
Author information
Authors and Affiliations
Editor information
Editors and Affiliations
Rights and permissions
Copyright information
© 2009 Springer-Verlag Berlin Heidelberg
About this chapter
Cite this chapter
Jeuring, J., Leather, S., Pedro Magalhães, J., Rodriguez Yakushev, A. (2009). Libraries for Generic Programming in Haskell. In: Koopman, P., Plasmeijer, R., Swierstra, D. (eds) Advanced Functional Programming. AFP 2008. Lecture Notes in Computer Science, vol 5832. Springer, Berlin, Heidelberg. https://doi.org/10.1007/978-3-642-04652-0_4
Download citation
DOI: https://doi.org/10.1007/978-3-642-04652-0_4
Publisher Name: Springer, Berlin, Heidelberg
Print ISBN: 978-3-642-04651-3
Online ISBN: 978-3-642-04652-0
eBook Packages: Computer ScienceComputer Science (R0)