Skip to main content

Prototyping Generic Programming in Template Haskell

  • Conference paper
Mathematics of Program Construction (MPC 2004)

Part of the book series: Lecture Notes in Computer Science ((LNCS,volume 3125))

Included in the following conference series:

Abstract

Generic Programming deals with the construction of programs that can be applied to many different datatypes. This is achieved by parameterizing the generic programs by the structure of the datatypes on which they are to be applied. Programs that can be defined generically range from simple map functions through pretty printers to complex XML tools.

The design space of generic programming languages is largely unexplored, partly due to the time and effort required to implement such a language. In this paper we show how to write flexible prototype implementations of two existing generic programming languages, PolyP and Generic Haskell, using Template Haskell, an extension to Haskell that enables compile-time meta-programming. In doing this we also gain a better understanding of the differences and similarities between the two languages.

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. Alimarine, A., Plasmeijer, R.: A generic programming extension for Clean. In: Arts, T., Mohnen, M. (eds.) IFL 2002. LNCS, vol. 2312, pp. 168–185. Springer, Heidelberg (2002)

    Chapter  Google Scholar 

  2. Clarke, D., Löh, A.: Generic haskell, specifically. In: Gibbons, J., Jeuring, J. (eds.) Proceedings of the IFIP TC2 Working Conference on Generic Programming, pp. 21–48. Kluwer, Dordrecht (2003)

    Google Scholar 

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

    Google Scholar 

  4. Hinze, R.: Polytypic values possess polykinded types. In: Backhouse, R., Oliveira, J.N. (eds.) MPC 2000. LNCS, vol. 1837, pp. 2–27. Springer, Heidelberg (2000)

    Chapter  Google Scholar 

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

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

  7. Hinze, R., Peyton Jones, S.: 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 Science, Amsterdam (2001)

    Google Scholar 

  8. Hutton, G.: A tutorial on the universality and expressiveness of fold. Journal of Functional Programming 9(4), 355–372 (1999)

    Article  MATH  MathSciNet  Google Scholar 

  9. Jansson, P.: Functional Polytypic Programming. PhD thesis, Computing Science, Chalmers University of Technology and Göteborg University, Sweden (May 2000)

    Google Scholar 

  10. Jansson, P., Jeuring, J.: PolyP — a polytypic programming language extension. In: POPL 1997, pp. 470–482. ACM Press, New York (1997)

    Chapter  Google Scholar 

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

    Article  MATH  MathSciNet  Google Scholar 

  12. Jay, C., Steckler, P.: The functional imperative: shape! In: Hankin, C. (ed.) ESOP 1998. LNCS, vol. 1381, pp. 139–153. Springer, Heidelberg (1998)

    Chapter  Google Scholar 

  13. Lämmel, R., Peyton Jones, S.: Scrap your boilerplate: a practical design pattern for generic programming. SIGPLAN Not. 38(3), 26–37 (2003)

    Article  Google Scholar 

  14. Lieberherr, K.J.: Adaptive Object-Oriented Software: The Demeter Method with Propagation Patterns. PWS Publishing Company, Boston (1996) ISBN 0-534- 94602-X

    Google Scholar 

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

  16. Sheard, T., Jones, S.P.: Template meta-programming for Haskell. In: Proceedings of the Haskell workshop, pp. 1–16. ACM Press, New York (2002)

    Chapter  Google Scholar 

Download references

Author information

Authors and Affiliations

Authors

Editor information

Editors and Affiliations

Rights and permissions

Reprints and permissions

Copyright information

© 2004 Springer-Verlag Berlin Heidelberg

About this paper

Cite this paper

Norell, U., Jansson, P. (2004). Prototyping Generic Programming in Template Haskell. In: Kozen, D. (eds) Mathematics of Program Construction. MPC 2004. Lecture Notes in Computer Science, vol 3125. Springer, Berlin, Heidelberg. https://doi.org/10.1007/978-3-540-27764-4_17

Download citation

  • DOI: https://doi.org/10.1007/978-3-540-27764-4_17

  • Publisher Name: Springer, Berlin, Heidelberg

  • Print ISBN: 978-3-540-22380-1

  • Online ISBN: 978-3-540-27764-4

  • eBook Packages: Springer Book Archive

Publish with us

Policies and ethics