Abstract
Tired of writing boilerplate code? Tired of repeating essentially the same function definition for lots of different datatypes? Datatype-generic programming promises to end these coding nightmares. In these lecture notes, we present the key abstractions of datatype-generic programming, give several applications, and provide an elegant embedding of generic programming into Haskell. The embedding builds on recent advances in type theory: generalised algebraic datatypes and open datatypes. We hope to convince you that generic programming is useful and that you can use generic programming techniques today!
Preview
Unable to display preview. Download preview PDF.
Similar content being viewed by others
References
Alimarine, A., Plasmeijer, R.: A generic programming extension for Clean. In: Arts, T., Mohnen, M. (eds.) IFL 2002. LNCS, vol. 2312, Springer, Heidelberg (2002)
Backhouse, R., Jansson, P., Jeuring, J., Meertens, L.: Generic Programming: An Introduction. In: Swierstra, S.D., Henriques, P.R., Oliveira, J.N. (eds.) AFP 1998. LNCS, vol. 1608, pp. 28–115. Springer, Heidelberg (1999)
Bird, R., Meertens, L.: Nested datatypes. In: Jeuring, J. (ed.) MPC 1998. LNCS, vol. 1422, pp. 52–67. Springer, Heidelberg (1998)
Braun, W., Rem, M.: A logarithmic implementation of flexible arrays. Memorandum MR83/4, Eindhoven University of Technology (1983)
Cheney, J., Hinze, R.: A lightweight implementation of generics and dynamics. In: Chakravarty, M.M.T. (ed.) Proceedings of the 2002 ACM SIGPLAN Haskell Workshop, pp. 90–104. ACM Press, New York (2002)
Clarke, D., Löh, A.: Generic Haskell, specifically. In: Gibbons, J., Jeuring, J. (eds.) Proceedings of the IFIP TC2 Working Conference on Generic Programming, Schloss Dagstuhl, pp. 21–48. Kluwer Academic Publishers, Dordrecht (2002)
Crary, K., Weirich, S.: Flexible type analysis. ACM SIGPLAN Notices 34(9), 233–248 (1999) (Proceedings of the fourth ACM SIGPLAN International Conference on Functional Programming (ICFP ’99), Paris, France)
Crary, K., Weirich, S., Morrisett, G.: Intensional polymorphism in type-erasure semantics. In: Proceedings of the ACM SIGPLAN International Conference on Functional Programming (ICFP 1998), Baltimore, MD, vol. (34)1 of ACM SIGPLAN Notices, pp. 301–312. ACM Press, New York (1999)
Fegaras, L., Sheard, T.: Revisiting catamorphisms over datatypes with embedded functions (or, programs from outer space). In: Proceedings of the 23rd ACM SIGPLAN-SIGACT symposium on Principles of programming languages, St. Petersburg Beach, Florida, United States, pp. 284–294 (1996)
Girard, J.-Y.: Interprétation foncionnelle et élimination des coupures de l’arithmétique d’order supérieur. PhD thesis, Université de Paris VII (1972)
Hall, C.V., Hammond, K., Peyton Jones, S.L., Wadler, P.L.: Type classes in Haskell. ACM Transactions on Programming Languages and Systems 18(2), 109–138 (1996)
Harper, R., Morrisett, G.: Compiling polymorphism using intensional type analysis. In: 22nd Symposium on Principles of Programming Languages, POPL 1995, pp. 130–141 (1995)
Hinze, R.: Functional Pearl: Perfect trees and bit-reversal permutations. Journal of Functional Programming 10(3), 305–317 (2000)
Hinze, R.: Memo functions, polytypically! In: Jeuring, J. (ed.) Proceedings of the 2nd Workshop on Generic Programming, Ponte de Lima, Portugal. The proceedings appeared as a technical report of Universiteit Utrecht, UU-CS-2000-19, pp. 17–32 (2000)
Hinze, R.: A new approach to generic functional programming. In: Reps, T.W. (ed.) Proceedings of the 27th Annual ACM SIGPLAN-SIGACT Symposium on Principles of Programming Languages (POPL 2000), Boston, Massachusetts, January 19-21, pp. 119–132 (2000)
Hinze, R.: Polytypic values possess polykinded types. Science of Computer Programming 43, 129–159 (2002)
Hinze, R.: Fun with phantom types. In: Gibbons, J., de Moor, O. (eds.) The Fun of Programming, pp. 245–262 Palgrave Macmillan (2003), ISBN 1-4039-0772-2 hardback, ISBN 0-333-99285-7 paperback
Hinze, R.: Generics for the masses. J. Functional Programming 16(4&5), 451–483 (2006)
Hinze, R., Jeuring, J.: Generic Haskell: Applications. In: Backhouse, R., Gibbons, J. (eds.) Generic Programming. LNCS, vol. 2793, pp. 57–97. 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., Jeuring, J., Löh, A.: Type-indexed data types. Science of Computer Programming 51, 117–151 (2004)
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., 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., Löh, A., Oliveira, B.C.d.S.: Scrap Your Boilerplate reloaded. Technical Report IAI-TR-2006-2, Institut für Informatik III, Universität Bonn. (2006)
Hinze, R., Peyton Jones, S.L.: Derivable type classes. In: Hutton, G. (ed.) Proceedings of the 2000 ACM SIGPLAN Haskell Workshop. Electronic Notes in Theoretical Computer Science, vol. 41.1, Elsevier, Amsterdam (2001) The preliminary proceedings appeared as a University of Nottingham technical report
Hutton, G.: Higher-order functions for parsing. Journal of Functional Programming 2(3), 323–343 (1992)
Jansson, P., Jeuring, J.: PolyP-a polytypic programming language extension. In: Conference Record 24th ACM SIGPLAN-SIGACT Symposium on Principles of Programming Languages (POPL 1997), Paris, France, pp. 470–482. ACM Press, New York (1997)
Jones, M.P.: A system of constructor classes: overloading and implicit higher-order polymorphism. Journal of Functional Programming 5(1), 1–35 (1995)
Jones, M.P.: Type classes with functional dependencies. In: Smolka, G. (ed.) ESOP 2000 and ETAPS 2000. LNCS, vol. 1782, pp. 230–244. Springer, Heidelberg (2000)
Lämmel, R., Peyton Jones, S.L.: Scrap more boilerplate: reflection, zips, and generalised casts. In: Fisher, K. (ed.) Proceedings of the 2004 International Conference on Functional Programming, Snowbird, Utah, September 19-22, 2004, pp. 244–255 (2004)
Lämmel, R., Peyton Jones, S.L.: Scrap your boilerplate with class: extensible generic functions. In: Pierce, B. (ed.) Proceedings of the 2005 International Conference on Functional Programming, Tallinn, Estonia (September 26-28, 2005)
Leijen, D., Meijer, E.: Domain-specific embedded compilers. In: Proceedings of the 2nd Conference on Domain-Specific Languages, Berkeley, CA, USENIX Association, pp. 109–122 (1999)
Löh, A., Hinze, R.: Open data types and open functions. In: Proceedings of the 8th ACM SIGPLAN Symposium on Principles and Practice of Declarative Programming, Venice, Italy, pp. 133–144. ACM Press, New York (2006)
Löh, A.: Exploring Generic Haskell. PhD thesis, Utrecht University (2004)
Löh, A., Jeuring, J.: The Generic Haskell user’s guide, version 1.42 - Coral release. Technical Report UU-CS-2005-004, Universiteit Utrecht (January 2005)
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)
Oliveira, B.C.d.S., Gibbons, J.: TypeCase: A design pattern for type-indexed functions. In: Leijen, D. (ed.) Proceedings of the 2005 ACM SIGPLAN workshop on Haskell, Tallinn, Estonia, pp. 98–109 (2005)
Peyton Jones, S.L.: Haskell 98 Language and Libraries. Cambridge University Press, Cambridge (2003)
Peyton Jones, S.L., Lämmel, R.: 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), New Orleans, pp. 26–37 (2003)
The GHC Team. The Glorious Glasgow Haskell Compilation System User’s Guide, Version 6.4.1 (2005), Available from http://www.haskell.org/ghc/
Trifonov, V., Saha, B., Shao, Z.: Fully reflexive intensional type analysis. In: Proceedings ICFP 2000: International Conference on Functional Programming, pp. 82–93. ACM Press, New York (2000)
Wadler, P.: The expression problem. Note to Java Genericity mailing list (November 12, 1998)
Wadler, P.: Theorems for free! In: The Fourth International Conference on Functional Programming Languages and Computer Architecture (FPCA 1989), London, UK, pp. 347–359. Addison-Wesley, Reading (1989)
Weirich, S.: Encoding intensional type analysis. In: Sands, D. (ed.) ESOP 2001 and ETAPS 2001. LNCS, vol. 2028, pp. 92–106. Springer, Heidelberg (2001)
Weirich, S.: Type-safe cast. Journal of Functional Programming 14(6), 681–695 (2004)
Author information
Authors and Affiliations
Editor information
Rights and permissions
Copyright information
© 2007 Springer-Verlag Berlin Heidelberg
About this paper
Cite this paper
Hinze, R., Löh, A. (2007). Generic Programming, Now!. In: Backhouse, R., Gibbons, J., Hinze, R., Jeuring, J. (eds) Datatype-Generic Programming. SSDGP 2006. Lecture Notes in Computer Science, vol 4719. Springer, Berlin, Heidelberg. https://doi.org/10.1007/978-3-540-76786-2_3
Download citation
DOI: https://doi.org/10.1007/978-3-540-76786-2_3
Publisher Name: Springer, Berlin, Heidelberg
Print ISBN: 978-3-540-76785-5
Online ISBN: 978-3-540-76786-2
eBook Packages: Computer ScienceComputer Science (R0)