Skip to main content

Testing Properties of Generic Functions

  • Conference paper
Implementation and Application of Functional Languages (IFL 2006)

Abstract

A datatype-generic function is a family of functions indexed by (the structure of) a type. Examples include equality tests, maps and pretty printers. Property based testing tools like QuickCheck and Gast support the definition of properties and test-data generators, and they check if a monomorphic property is satisfied by the test cases. Generic functions satisfy generic properties and this paper discusses specifying and testing such properties. It shows how generic properties and generators can be expressed, and explains three bugs we found and corrected in the Generic Haskell library.

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

Access this chapter

Institutional subscriptions

Preview

Unable to display preview. Download preview PDF.

Unable to display preview. Download preview PDF.

Similar content being viewed by others

References

  1. Beck, K.: Test-Driven Development by Example. Addison-Wesley, Reading (2003)

    Google Scholar 

  2. Claessen, K., Hughes, J.: QuickCheck: A lightweight tool for random testing of Haskell programs. In: ICFP 2000, pp. 268–279. ACM Press, New York (2000)

    Chapter  Google Scholar 

  3. Hinze, R.: Generic Programs and Proofs. Bonn University, Habilitation (2000)

    Google Scholar 

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

    Google Scholar 

  5. Hinze, R., Jeuring, J., Löh, A.: Comparing approaches to generic programming in Haskell. Technical Report UU-CS-2006-022, ICS, Utrecht University, 2006. In: Datatype-Generic Programming, LNCS, Springer (to appear, 2007)

    Google Scholar 

  6. Holdermans, S., Jeuring, J., Löh, A., Rodriguez, A.: Generic views on data types. In: Uustalu, T. (ed.) MPC 2006. LNCS, vol. 4014, Springer, Heidelberg (2006)

    Chapter  Google Scholar 

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

    Google Scholar 

  8. Koopman, P., Alimarine, A., Tretmans, J., Plasmeijer, R.: Gast: Generic automated software testing. In: Arts, T., Mohnen, M. (eds.) IFL 2002. LNCS, vol. 2312, pp. 84–100. Springer, Heidelberg (2002)

    Google Scholar 

  9. Koopman, P., Plasmeijer, R.: Generic generation of elements of types. In: TFP’05, pp. 167–179. Tallinn (2005)

    Google Scholar 

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

    Google Scholar 

  11. Löh, A., Clarke, D., Jeuring, J.: Dependency-style Generic Haskell. In: Shivers, O. (ed.) ICFP 2003, pp. 141–152. ACM Press, New York (2003)

    Chapter  Google Scholar 

  12. Löh, A., Jeuring, J., Rodriguez, A.: (editors) et al. The Generic Haskell user’s guide, Version 1.60 - Diamond release. Technical Report UU-CS-2006-049, ICS, Utrecht University (2006)

    Google Scholar 

  13. Mitchelland, R., McKim, J.: Design by Contract: by example. Addison-Wesley, Reading (2002)

    Google Scholar 

  14. Peyton Jones, S., et al.: Haskell 98, Language and Libraries. In: The Revised Report, Cambridge University Press, Cambridge (2003)

    Google Scholar 

  15. Plasmeijer, R., van Eekelen, M.: Clean Language Report version 2.1 (2005)

    Google Scholar 

Download references

Author information

Authors and Affiliations

Authors

Editor information

Zoltán Horváth Viktória Zsók Andrew Butterfield

Rights and permissions

Reprints and permissions

Copyright information

© 2007 Springer-Verlag Berlin Heidelberg

About this paper

Cite this paper

Jansson, P. et al. (2007). Testing Properties of Generic Functions. In: Horváth, Z., Zsók, V., Butterfield, A. (eds) Implementation and Application of Functional Languages. IFL 2006. Lecture Notes in Computer Science, vol 4449. Springer, Berlin, Heidelberg. https://doi.org/10.1007/978-3-540-74130-5_13

Download citation

  • DOI: https://doi.org/10.1007/978-3-540-74130-5_13

  • Publisher Name: Springer, Berlin, Heidelberg

  • Print ISBN: 978-3-540-74129-9

  • Online ISBN: 978-3-540-74130-5

  • eBook Packages: Computer ScienceComputer Science (R0)

Publish with us

Policies and ethics