Skip to main content

Comparing Approaches to Generic Programming in Haskell

  • Conference paper
Datatype-Generic Programming (SSDGP 2006)

Part of the book series: Lecture Notes in Computer Science ((LNTCS,volume 4719))

Included in the following conference series:

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).

This is a preview of subscription content, log in via an institution to check access.

Access this chapter

Chapter
USD 29.95
Price excludes VAT (USA)
  • Available as PDF
  • Read on any device
  • Instant download
  • Own it forever
eBook
USD 39.99
Price excludes VAT (USA)
  • Available as PDF
  • Read on any device
  • Instant download
  • Own it forever
Softcover Book
USD 54.99
Price excludes VAT (USA)
  • Compact, lightweight edition
  • Dispatched in 3 to 5 business days
  • Free shipping worldwide - see info

Tax calculation will be finalised at checkout

Purchases are for personal use only

Institutional subscriptions

Preview

Unable to display preview. Download preview PDF.

Unable to display preview. Download preview PDF.

References

  1. 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)

    Chapter  Google Scholar 

  2. Alimarine, A.: Generic Functional Programming - Conceptual Design, Implementation and Applications. PhD thesis, University of Nijmegen, The Netherlands (2005)

    Google Scholar 

  3. 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)

    Chapter  Google Scholar 

  4. Alimarine, A., Smetsers, S.: Optimizing generic functions. In: Kozen, D. (ed.) MPC 2004. LNCS, vol. 3125, pp. 16–31. Springer, Heidelberg (2004)

    Chapter  Google Scholar 

  5. 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)

    Chapter  Google Scholar 

  6. Altenkirch, T., McBride, C.: Generic programming within dependently typed programming. In: Gibbons and Jeuring [27] , pp. 1–20

    Google Scholar 

  7. 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)

    Google Scholar 

  8. 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)

    Article  MathSciNet  MATH  Google Scholar 

  9. 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)

    Google Scholar 

  10. Backhouse, R., Gibbons, J.: The EPSRC project on Datatype-Generic Programming (2003-2006), http://web.comlab.ox.ac.uk /oucl/research/pdt/ap/dgp/

  11. 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)

    MathSciNet  MATH  Google Scholar 

  12. Bird, R., Meertens, L.: Nested datatypes. In: Jeuring, J. (ed.) MPC 1998. LNCS, vol. 1422, pp. 52–67. Springer, Heidelberg (1998)

    Chapter  Google Scholar 

  13. Bird, R., Paterson, R.: Generalised folds for nested datatypes. Formal Aspects of Computing 11(2), 200–222 (1999)

    Article  MATH  Google Scholar 

  14. Chen, J., Appel, A.W.: Dictionary passing for polytypic polymorphism. Technical Report TR-635-01, Princeton University (2001)

    Google Scholar 

  15. 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)

    Google Scholar 

  16. Clarke, D., Löh, A.: Generic Haskell, specifically. In: Gibbons and Jeuring [27], pp. 21–48

    Google Scholar 

  17. Clavel, M., Duran, F., Marti-Oliet, N.: Polytypic programming in Maude. In: Workshop on Rewriting Logic and its Applications 2000 (2000)

    Google Scholar 

  18. Cockett, R., Fukushima, T.: About Charity. Yellow Series Report No. 92/480/18, Dep. of Computer Science, Univ. of Calgary (1992)

    Google Scholar 

  19. 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)

    Google Scholar 

  20. 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)

    Google Scholar 

  21. 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)

    Google Scholar 

  22. Furuse, J.: Generic polymorphism in ML. In Journées Francophones des Langages Applicatifs (January 2001)

    Google Scholar 

  23. 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)

    Chapter  Google Scholar 

  24. 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)

    Google Scholar 

  25. 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)

    Google Scholar 

  26. Gibbons, J.: Metamorphisms: Streaming representation-changers. Science of Computer Programming 65(2), 108–139 (2007)

    Article  MathSciNet  MATH  Google Scholar 

  27. Gibbons, J., Jeuring, J.: Generic Programming. IFIP, vol. 243. Kluwer Academic Publishers, Dordrecht (2003)

    Book  MATH  Google Scholar 

  28. Gibbons, J., Paterson, R.: Parametric datatype-genericity. Unpublished manuscript (2006)

    Google Scholar 

  29. Hagg, P.: A framework for developing generic XML Tools. Master’s thesis, Department of Information and Computing Sciences, Utrecht University (2002)

    Google Scholar 

  30. 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)

    Google Scholar 

  31. 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)

    Google Scholar 

  32. Hinze, R.: Functional pearl: Perfect trees and bit-reversal permutations. Journal of Functional Programming 10(3), 305–317 (2000)

    Article  MathSciNet  MATH  Google Scholar 

  33. Hinze, R.: Generic Programs and Proofs. Habilitationsschrift, Bonn University (2000)

    Google Scholar 

  34. Hinze, R.: Polytypic values possess polykinded types. Science of Computer Programming 43(2-3), 129–159 (2002)

    Article  MathSciNet  MATH  Google Scholar 

  35. 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)

    Google Scholar 

  36. Hinze, R.: Generics for the masses. Journal of Functional Programming 16, 451–482 (2006)

    Article  MathSciNet  MATH  Google Scholar 

  37. Hinze, R., Jeuring, J.: Generic Haskell: applications. In: Backhouse, R., Gibbons, J. (eds.) Generic Programming. LNCS, vol. 2793, pp. 57–97. Springer, Heidelberg (2003)

    Chapter  Google Scholar 

  38. 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)

    Chapter  Google Scholar 

  39. Hinze, R., Jeuring, J., Löh, A.: Type-indexed data types. Science of Computer Programming 51(1-2), 117–151 (2004)

    Article  MathSciNet  MATH  Google Scholar 

  40. Hinze, R., Jeuring, J., Löh, A.: Comparing Approaches to Generic Programming in Haskell. Technical Report UU-CS-2006-022, Utrecht University (2006)

    Google Scholar 

  41. Hinze, R., Jones, S.P.: Derivable type classes. In: Hutton, G. (ed.) Proceedings of the 4th Haskell Workshop (2000)

    Google Scholar 

  42. 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)

    Google Scholar 

  43. Hinze, R., Löh, A.: Scrap Your Boilerplate revolutions. In: Uustalu, T. (ed.) MPC 2006. LNCS, vol. 4014, pp. 180–208. Springer, Heidelberg (2006)

    Chapter  Google Scholar 

  44. 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)

    Google Scholar 

  45. 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)

    Chapter  Google Scholar 

  46. Huet, G.: The zipper. Journal of Functional Programming 7(5), 549–554 (1997)

    Article  MathSciNet  MATH  Google Scholar 

  47. 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)

    Chapter  Google Scholar 

  48. 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)

    Google Scholar 

  49. Jansson, P., Jeuring, J.: PolyLib - a polytypic function library. In: Workshop on Generic Programming, Marstrand (June 1998)

    Google Scholar 

  50. Jansson, P., Jeuring, J.: Polytypic data conversion programs. Science of Computer Programming 43(1), 35–75 (2002)

    Article  MathSciNet  MATH  Google Scholar 

  51. 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)

    Google Scholar 

  52. Barry Jay, C.: Programming in FISh. International Journal on Software Tools for Technology Transfer 2, 307–315 (1999)

    Article  MATH  Google Scholar 

  53. 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)

    Chapter  Google Scholar 

  54. Barry Jay, C.: The pattern calculus. ACM Trans. Program. Lang. Syst. 26(6), 911–937 (2004)

    Article  Google Scholar 

  55. Barry Jay, C., Kesner, D.: Pure pattern calculus. In: Sestoft, P. (ed.) ESOP 2006 and ETAPS 2006. LNCS, vol. 3924, Springer, Heidelberg (2006)

    Google Scholar 

  56. Barry Jay, C., Bellé, G., Moggi, E.: Functorial ML. Journal of Functional Programming 8(6), 573–619 (1998)

    Article  MathSciNet  MATH  Google Scholar 

  57. 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)

    Chapter  Google Scholar 

  58. Jeuring, J., Plasmeijer, R.: Generic programming for software evolution. In: Informal proceedings of the ERCIM workshop on Software Evolution (2006)

    Google Scholar 

  59. Kiselyov, O.: Smash your boiler-plate without class and Typeable, Published on the Haskell mailing list (2006)

    Google Scholar 

  60. 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)

    Chapter  Google Scholar 

  61. Lämmel, R., Peyton Jones, S.: Scrap your boilerplate: a practical approach to generic programming. ACM SIGPLAN Notices 38(3), 26–37 (2003)

    Article  Google Scholar 

  62. 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 

  63. 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)

    Google Scholar 

  64. 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)

    Google Scholar 

  65. 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)

    Google Scholar 

  66. 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)

    Google Scholar 

  67. Lehman, M.M.: Programs, life cycles and the laws of software evolution. Proc. IEEE 68(9), 1060–1078 (1980)

    Article  Google Scholar 

  68. Lehman, M.M., Belady, L.A.: Program Evolution: Processes of Software Change. Academic Press, London (1985)

    MATH  Google Scholar 

  69. Lieberherr, K.J.: Adaptive Object-Oriented Software: The Demeter Method with Propagation Patterns. PWS Publishing Company, Boston (1996)

    Google Scholar 

  70. Löh, A.: Exploring Generic Haskell. PhD thesis, Utrecht University (2004)

    Google Scholar 

  71. 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)

    Google Scholar 

  72. 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)

    Google Scholar 

  73. 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)

    Google Scholar 

  74. 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

  75. Malcolm, G.: Data structures and program transformation. Science of Computer Programming 14, 255–279 (1990)

    Article  MathSciNet  MATH  Google Scholar 

  76. 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)

    Chapter  Google Scholar 

  77. Milner, R.: A theory of type polymorphism in programming. Journal of Computer and Systems Sciences 17, 348–375 (1978)

    Article  MathSciNet  MATH  Google Scholar 

  78. 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)

    Google Scholar 

  79. 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)

    Google Scholar 

  80. 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)

    Chapter  Google Scholar 

  81. 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)

    Chapter  Google Scholar 

  82. 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)

    Chapter  Google Scholar 

  83. 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)

    Google Scholar 

  84. 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)

    Google Scholar 

  85. OMG.Corba, http://www.omg.org/corba/

  86. Peyton Jones, S., et al.: Haskell 98, Language and Libraries. The Revised Report. A special issue of the Journal of Functional Programming (2003)

    Google Scholar 

  87. Powell, A.L.: A literature review on the quantification of software change. Technical Report YCS 305, Computer Science, University of York (1998)

    Google Scholar 

  88. Reig, F.: Generic proofs for combinator-based generic programs. In: Loidl, H.-W. (ed.) Trends in Functional Programming, vol. 5, Intellect (2006)

    Google Scholar 

  89. 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)

    Google Scholar 

  90. 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)

    Google Scholar 

  91. de Vries, M.: Specializing type-indexed values by partial evaluation. Master’s thesis, Rijksuniversiteit Groningen (2004)

    Google Scholar 

  92. Wadler, P.: Theorems for free! In: Functional Programming Languages and Computer Architecture, FPCA 1989, pp. 347–359. ACM Press, New York (1989)

    Google Scholar 

  93. 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)

    Chapter  Google Scholar 

  94. Wallace, M., Runciman, C.: Heap compression and binary I/O in Haskell. In: 2nd ACM Haskell Workshop (1997)

    Google Scholar 

  95. Watt, D.A.: Programming Language Design Concepts. John Wiley & Sons, Chichester (2004)

    Google Scholar 

  96. 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)

    Chapter  Google Scholar 

  97. 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)

    Google Scholar 

  98. Weirich, S., Huang, L.: A design for type-directed programming in Java. In: Workshop on Object-Oriented Developments, WOOD 2004 (2004)

    Google Scholar 

  99. Winstanley, N., Meacham, J.: The DrIFT manual (1997-2005), http://repetae.net /~john/computer/haskell/DrIFT/

  100. Xi, H.: Dependent types in practical programming. PhD thesis, Carnegie Mellon University (1998)

    Google Scholar 

Download references

Author information

Authors and Affiliations

Authors

Editor information

Roland Backhouse Jeremy Gibbons Ralf Hinze Johan Jeuring

Rights and permissions

Reprints 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)

Publish with us

Policies and ethics