Abstract
The last decade has seen a number of approaches to datatype-generic programming: PolyP, Functorial ML, ‘Scrap Your Boilerplate’, Generic Haskell, ‘Generics for the Masses’, and so on. The approaches vary in sophistication and target audience: some propose full-blown programming languages, some suggest libraries, some can be seen as categorical programming methods. In these lecture notes we compare the various approaches to datatype-generic programming in Haskell. We introduce each approach by means of example, and we evaluate it along different dimensions (expressivity, ease of use, and so on).
Preview
Unable to display preview. Download preview PDF.
Similar content being viewed by others
References
Achten, P., van Eekelen, M., Plasmeijer, R.: Generic Graphical User Interfaces. In: Trinder, P., Michaelson, G.J., Peña, R. (eds.) IFL 2003. LNCS, vol. 3145, pp. 152–167. Springer, Heidelberg (2004)
Alimarine, A.: Generic Functional Programming - Conceptual Design, Implementation and Applications. PhD thesis, University of Nijmegen, The Netherlands (2005)
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)
Alimarine, A., Smetsers, S.: Improved fusion for optimizing generics. In: Hermenegildo, M.V., Cabeza, D. (eds.) Practical Aspects of Declarative Languages. LNCS, vol. 3350, pp. 203–218. Springer, Heidelberg (2005)
Altenkirch, T., McBride, C.: Generic programming within dependently typed programming. In: Gibbons and Jeuring [27] , pp. 1–20
Atanassow, F., Clarke, D., Jeuring, J.: Scripting XML with Generic Haskell. In: Proceedings of the 7th Brazilian Symposium on Programming Languages, SBLP 2003, An extended version of this paper appears as ICS, Utrecht University, technical report UU-CS-2003-023 (2003)
Atanassow, F., Jeuring, J.: Customizing an XML-Haskell data binding with type isomorphism inference in Generic Haskell. Science of Computer Programming 65(2), 72–107 (2007)
Augustsson, L.: Cayenne – a language with dependent types. In: Proceedings of the ACM SIGPLAN International Conference on Functional Programming, ICFP 1998, pp. 239–250. ACM Press, New York (1998)
Backhouse, R., Gibbons, J.: The EPSRC project on Datatype-Generic Programming (2003-2006), http://web.comlab.ox.ac.uk /oucl/research/pdt/ap/dgp/
Benke, M., Dybjer, P., Jansson, P.: Universes for generic programs and proofs in dependent type theory. Nordic Journal of Computing 10(4), 265–289 (2003)
Bird, R., Meertens, L.: Nested datatypes. In: Jeuring, J. (ed.) MPC 1998. LNCS, vol. 1422, pp. 52–67. Springer, Heidelberg (1998)
Bird, R., Paterson, R.: Generalised folds for nested datatypes. Formal Aspects of Computing 11(2), 200–222 (1999)
Chen, J., Appel, A.W.: Dictionary passing for polytypic polymorphism. Technical Report TR-635-01, Princeton University (2001)
Cheney, J., Hinze, R.: A lightweight implementation of generics and dynamics. In: Chakravarty, M. (ed.) Haskell 2002. Proceedings of the 2002 ACM SIGPLAN workshop on Haskell, pp. 90–104. ACM Press, New York (2002)
Clarke, D., Löh, A.: Generic Haskell, specifically. In: Gibbons and Jeuring [27], pp. 21–48
Clavel, M., Duran, F., Marti-Oliet, N.: Polytypic programming in Maude. In: Workshop on Rewriting Logic and its Applications 2000 (2000)
Cockett, R., Fukushima, T.: About Charity. Yellow Series Report No. 92/480/18, Dep. of Computer Science, Univ. of Calgary (1992)
Crary, K., Weirich, S., Morrisett, J.G.: Intensional polymorphism in type-erasure semantics. In: Proceedings of the ACM SIGPLAN International Conference on Functional Programming, ICFP 1998, pp. 301–312. ACM Press, New York (1998)
Demers, A., Donahue, J., Skinner, G.: Data types as values: polymorphism, type-checking, encapsulation. In: Conference Record of POPL 1978: The 5th ACM SIGPLAN-SIGACT Symposium on Principles of Programming Languages, pp. 23–30. ACM Press, New York (1978)
Dubois, C., Rouaix, F., Weis, P.: Extensional polymorphism. In: Conference Record of POPL 1995: The 22nd ACM SIGPLAN-SIGACT Symposium on Principles of Programming Languages, pp. 118–129 (1995)
Furuse, J.: Generic polymorphism in ML. In Journées Francophones des Langages Applicatifs (January 2001)
Garcia, R., Jarvi, J., Lumsdaine, A., Siek, J.G., Willcock, J.: A comparative study of language support for generic programming. In: OOPSLA 2003: Proceedings of the 18th annual ACM SIGPLAN conference on Object-oriented programing, systems, languages, and applications, pp. 115–134. ACM Press, New York (2003)
Gibbons, J.: Patterns in datatype-generic programming. In: Striegnitz, J., Davis, K. (eds.) Multiparadigm Programming. John von Neumann Institute for Computing (NIC), First International Workshop on Declarative Programming in the Context of Object-Oriented Languages (DPCOOL), vol. 27, pp. 277–289 (2003)
Gibbons, J.: Datatype-generic programming. In: Backhouse, R., Gibbons, J., Hinze, R., Jeuring, J. (eds.) Generic Programming, Advanced Lectures. LNCS, vol. 419, pp. 1–71. Springer, Heidelberg (2006)
Gibbons, J.: Metamorphisms: Streaming representation-changers. Science of Computer Programming 65(2), 108–139 (2007)
Gibbons, J., Jeuring, J.: Generic Programming. IFIP, vol. 243. Kluwer Academic Publishers, Dordrecht (2003)
Gibbons, J., Paterson, R.: Parametric datatype-genericity. Unpublished manuscript (2006)
Hagg, P.: A framework for developing generic XML Tools. Master’s thesis, Department of Information and Computing Sciences, Utrecht University (2002)
Harper, R., Morrisett, G.: Compiling polymorphism using intensional type analysis. In: Conference Record of POPL 1995: The 22nd ACM SIGPLAN-SIGACT Symposium on Principles of Programming Languages, pp. 130–141 (1995)
Hinze, R.: A generic programming extension for Haskell. In: Meijer, E. (ed.) Proceedings of the Third Haskell Workshop, Technical report of Utrecht University, UU-CS-1999-28 (1999)
Hinze, R.: Functional pearl: Perfect trees and bit-reversal permutations. Journal of Functional Programming 10(3), 305–317 (2000)
Hinze, R.: Generic Programs and Proofs. Habilitationsschrift, Bonn University (2000)
Hinze, R.: Polytypic values possess polykinded types. Science of Computer Programming 43(2-3), 129–159 (2002)
Hinze, R.: Generics for the masses. In: Proceedings of the ACM SIGPLAN International Conference on Functional Programming, ICFP 2004, pp. 236–243. ACM Press, 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–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(1-2), 117–151 (2004)
Hinze, R., Jeuring, J., Löh, A.: Comparing Approaches to Generic Programming in Haskell. Technical Report UU-CS-2006-022, Utrecht University (2006)
Hinze, R., Jones, S.P.: Derivable type classes. In: Hutton, G. (ed.) Proceedings of the 4th Haskell Workshop (2000)
Hinze, R., Löh, A.: Generic programming, now! In: Backhouse, R., Gibbons, J., Hinze, R., Jeuring, J. (eds.) Datatype-Generic Programming, Advanced Lectures. LNCS, vol. 4719, Springer, Heidelberg (2006)
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: Wadler, P., Hagiya, M. (eds.) FLOPS 2006. LNCS, vol. 3945, Springer, Heidelberg (2006)
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)
Huet, G.: The zipper. Journal of Functional Programming 7(5), 549–554 (1997)
Hughes, J.: The design of a pretty-printing library. In: Jeuring, J., Meijer, E. (eds.) Advanced Functional Programming. LNCS, vol. 925, pp. 53–96. Springer, Heidelberg (1995)
Jansson, P., Jeuring, J.: PolyP – a polytypic programming language extension. In: Conference Record of POPL 1997: The 24th ACM SIGPLAN-SIGACT Symposium on Principles of Programming Languages, pp. 470–482. ACM Press, New York (1997)
Jansson, P., Jeuring, J.: PolyLib - a polytypic function library. In: Workshop on Generic Programming, Marstrand (June 1998)
Jansson, P., Jeuring, J.: Polytypic data conversion programs. Science of Computer Programming 43(1), 35–75 (2002)
Jansson, P., Jeuring, J.: students of the Utrecht University Generic Programming class. In: Horváth, Z. (ed.) Testing properties of generic functions. Proceedings 18th International Symposium on Implementation and Application of Functional Languages, IFL 2006. LNCS, vol. 4449, Springer, Heidelberg (2007)
Barry Jay, C.: Programming in FISh. International Journal on Software Tools for Technology Transfer 2, 307–315 (1999)
Barry Jay, C.: Distinguishing data structures and functions: the constructor calculus and functorial types. In: Abramsky, S. (ed.) TLCA 2001. LNCS, vol. 2044, pp. 217–239. Springer, Heidelberg (2001)
Barry Jay, C.: The pattern calculus. ACM Trans. Program. Lang. Syst. 26(6), 911–937 (2004)
Barry Jay, C., Kesner, D.: Pure pattern calculus. In: Sestoft, P. (ed.) ESOP 2006 and ETAPS 2006. LNCS, vol. 3924, Springer, Heidelberg (2006)
Barry Jay, C., Bellé, G., Moggi, E.: Functorial ML. Journal of Functional Programming 8(6), 573–619 (1998)
Jeuring, J., Jansson, P.: Polytypic programming. In: Launchbury, J., Meijer, E., Sheard, T. (eds.) Advanced Functional Programming. LNCS, vol. 1129, pp. 68–114. Springer, Heidelberg (1996)
Jeuring, J., Plasmeijer, R.: Generic programming for software evolution. In: Informal proceedings of the ERCIM workshop on Software Evolution (2006)
Kiselyov, O.: Smash your boiler-plate without class and Typeable, Published on the Haskell mailing list (2006)
Koopman, P., Alimarine, A., Tretmans, J., Plasmeijer, R.: Gast: Generic Automated Software Testing. In: Peña, R., Arts, T. (eds.) IFL 2002. LNCS, vol. 2670, Springer, Heidelberg (2003)
Lämmel, R., Peyton Jones, S.: Scrap your boilerplate: a practical approach to generic programming. ACM SIGPLAN Notices 38(3), 26–37 (2003)
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)
Lämmel, R., Meijer, E.: Revealing the X/O impedance mismatch. In: Backhouse, R., Gibbons, J., Hinze, R., Jeuring, J. (eds.) Datatype-Generic Programming, Advanced Lectures. LNCS, vol. 4719, Springer, Heidelberg (2006)
Lämmel, R., Peyton Jones, S.: 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 Press, New York (2004)
Lämmel, R., Visser, J.: Typed Combinators for Generic Traversal. In: Krishnamurthi, S., Ramakrishnan, C.R. (eds.) PADL 2002. LNCS, vol. 2257, pp. 137–154. Springer, Heidelberg (2002)
Lang, B.: Threshold evaluation and the semantics of call by value, assignment and generic procedures. In: Conference Record of POPL 1977: The 4th ACM SIGPLAN-SIGACT Symposium on Principles of Programming Languages, pp. 227–237. ACM Press, New York (1977)
Lehman, M.M.: Programs, life cycles and the laws of software evolution. Proc. IEEE 68(9), 1060–1078 (1980)
Lehman, M.M., Belady, L.A.: Program Evolution: Processes of Software Change. Academic Press, London (1985)
Lieberherr, K.J.: Adaptive Object-Oriented Software: The Demeter Method with Propagation Patterns. PWS Publishing Company, Boston (1996)
Löh, A.: Exploring Generic Haskell. PhD thesis, Utrecht University (2004)
Löh, A., Clarke, D., Jeuring, J.: Dependency-style Generic Haskell. In: Shivers, O. (ed.) Proceedings of the ACM SIGPLAN International Conference on Functional Programming, ICFP 2003, pp. 141–152. ACM Press, New York (2003)
Löh, A., Hinze, R.: Open data types. In: Maher, M. (ed.) Proceedings of the 8th ACM-SIGPLAN International Symposium on Principles and Practice of Declarative Programming, PPDP 2006 (2006)
Löh, A., Jeuring, J.(eds.). The Generic Haskell user’s guide, Version 1.42 - Coral release. Technical Report UU-CS-2005-004, Utrecht University (2005)
Lynagh, I.: Typing Template Haskell: Soft Type (August 2004), http://web.comlab.ox.ac.uk/oucl/work/ian.lynagh/papers/Typing_Template_Haskell:_Soft_Types.ps
Malcolm, G.: Data structures and program transformation. Science of Computer Programming 14, 255–279 (1990)
McBride, C.: Epigram: practical programming with dependent types. In: Vene, V., Uustalu, T. (eds.) AFP 2004. LNCS, vol. 3622, pp. 130–170. Springer, Heidelberg (2005)
Milner, R.: A theory of type polymorphism in programming. Journal of Computer and Systems Sciences 17, 348–375 (1978)
Moggi, E., Bellè,, Barry Jay, C.: Monads, shapely functors and traversals. In: Hoffman, M., Pavlovic̀,, Rosolini, P. (eds.) Proceedings of the 8th Conference on Category Theory and Computer Science, CTCS 1999. Electronic Lecture Notes in Computer Science, vol. 24, pp. 265–286. Elsevier, Amsterdam (1999)
Musser, D.R., Derge, G.J., Saini, A.: STL Tutorial and Reference Guide, Second Edition: C++ Programming with the Standard Template Library, 2nd edn. Addison-Wesley, Reading (2001)
Nogueira, P.: Context-parametric polykinded types. In: Hinze, R. (ed.) Proceedings of the of the ACM SIGPLAN Workshop on Generic Programming 2006, pp. 45–54. ACM Press, New York (2006)
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)
Oliveira, B.C.d.S., Gibbons, J.: TypeCase: A design pattern for type-indexed functions. In: Löh, A. (ed.) Proceedings Haskell Workshop, ACM Press, New York (2005)
Oliveira, B.C.d.S., Hinze, R., Löh, A.: Generics as a library. In: Nilsson, H. (ed.) Proceedings of the 7th Symposium on Trends in Functional Programming, Nottingham, UK (April 19-21, 2006)
OMG.Corba, http://www.omg.org/corba/
Peyton Jones, S., et al.: Haskell 98, Language and Libraries. The Revised Report. A special issue of the Journal of Functional Programming (2003)
Powell, A.L.: A literature review on the quantification of software change. Technical Report YCS 305, Computer Science, University of York (1998)
Reig, F.: Generic proofs for combinator-based generic programs. In: Loidl, H.-W. (ed.) Trends in Functional Programming, vol. 5, Intellect (2006)
Schuman, S.A.: On generic functions. In: Schuman, S.A. (ed.) First IFIP WG 2.1 Working Conference on New Directions in Algorithmic Languages 1975, pp. 169–192 IRIA (1975)
Sheard, T.: Generic programming in Ωmega. In: Backhouse, R., Gibbons, J., Hinze, R., Jeuring, J. (eds.) Datatype-Generic Programming, Advanced Lectures. LNCS, vol. 4719, Springer, Heidelberg (2006)
de Vries, M.: Specializing type-indexed values by partial evaluation. Master’s thesis, Rijksuniversiteit Groningen (2004)
Wadler, P.: Theorems for free! In: Functional Programming Languages and Computer Architecture, FPCA 1989, pp. 347–359. ACM Press, New York (1989)
Wadler, P.: How to replace failure by a list of successes. In: Jouannaud, J.-P. (ed.) Functional Programming Languages and Computer Architecture. LNCS, vol. 201, pp. 113–128. Springer, New York (1985)
Wallace, M., Runciman, C.: Heap compression and binary I/O in Haskell. In: 2nd ACM Haskell Workshop (1997)
Watt, D.A.: Programming Language Design Concepts. John Wiley & Sons, Chichester (2004)
Weirich, S.: Higher-order intensional type analysis. In: Le Métayer, D. (ed.) ESOP 2002 and ETAPS 2002. LNCS, vol. 2305, pp. 98–114. Springer, Heidelberg (2002)
Weirich, S.: Replib: a library for derivable type classes. In: Haskell 2006: Proceedings of the 2006 ACM SIGPLAN workshop on Haskell, pp. 1–12. ACM Press, New York (2006)
Weirich, S., Huang, L.: A design for type-directed programming in Java. In: Workshop on Object-Oriented Developments, WOOD 2004 (2004)
Winstanley, N., Meacham, J.: The DrIFT manual (1997-2005), http://repetae.net /~john/computer/haskell/DrIFT/
Xi, H.: Dependent types in practical programming. PhD thesis, Carnegie Mellon University (1998)
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., Jeuring, J., Löh, A. (2007). Comparing Approaches to Generic Programming in Haskell. 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_2
Download citation
DOI: https://doi.org/10.1007/978-3-540-76786-2_2
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)