Generic Views on Data Types

  • Stefan Holdermans
  • Johan Jeuring
  • Andres Löh
  • Alexey Rodriguez
Part of the Lecture Notes in Computer Science book series (LNCS, volume 4014)

Abstract

A generic function is defined by induction on the structure of types. The structure of a data type can be defined in several ways. For example, in PolyP a pattern functor gives the structure of a data type viewed as a fixed point, and in Generic Haskell a structural representation type gives an isomorphic type view of a data type in terms of sums of products. Depending on this generic view on the structure of data types, some generic functions are easier, more difficult, or even impossible to define. Furthermore, the efficiency of some generic functions can be improved by choosing a different view. This paper introduces generic views on data types and shows why they are useful. Furthermore, it shows how generic views have been added to Generic Haskell, an extension of the functional programming language Haskell that supports the construction of generic functions. The separation between inductive definitions on type structure and generic views allows us to combine many approaches to generic programming in a single framework.

Preview

Unable to display preview. Download preview PDF.

Unable to display preview. Download preview PDF.

References

  1. 1.
    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)CrossRefGoogle Scholar
  2. 2.
    Hinze, R.: Polytypic values possess polykinded types. Science of Computer Programming 43(2-3), 129–159 (2002)MATHCrossRefMathSciNetGoogle Scholar
  3. 3.
    Lämmel, R., Jones, S.P.: Scrap your boilerplate: a practical approach to generic programming. ACM SIGPLAN Notices 38(3), 26–37 (2003); Proceedings ACM SIGPLAN Workshop on Types in Language Design and Implementation (TLDI 2003)CrossRefGoogle Scholar
  4. 4.
    Jay, C.B.: 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)CrossRefGoogle Scholar
  5. 5.
    Hoogendijk, P., de Moor, O.: Container types categorically. Journal of Functional Programming 10(2), 191–225 (2000)MATHCrossRefMathSciNetGoogle Scholar
  6. 6.
    Meijer, E., Fokkinga, M., Paterson, R.: Functional programming with bananas, lenses, envelopes, and barbed wire. In: Hughes, J. (ed.) FPCA 1991. LNCS, vol. 523, pp. 124–144. Springer, Heidelberg (1991)Google Scholar
  7. 7.
    Jansson, P., Jeuring, J.: A framework for polytypic programming on terms, with an application to rewriting. In: Jeuring, J. (ed.) Workshop on Generic Programming 2000, Ponte de Lima, Portugal, July 2000, pp. 33–45 (2000) Utrecht Technical Report UU-CS-2000-19Google Scholar
  8. 8.
    Löh, A., Jeuring, J., Clarke, D., Hinze, R., Rodriguez, A., de Wit, J.: The Generic Haskell user’s guide, version 1.42 (Coral). Technical Report UU-CS-2005-004, Institute of Information and Computing Sciences, Utrecht University (2005)Google Scholar
  9. 9.
    Löh, A.: Exploring Generic Haskell. PhD thesis, Utrecht University (September 2004)Google Scholar
  10. 10.
    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)CrossRefGoogle Scholar
  11. 11.
    Hinze, R., Jeuring, J.: Generic Haskell: applications. In: Backhouse, R., Gibbons, J. (eds.) Generic Programming. LNCS, vol. 2793, pp. 57–97. Springer, Heidelberg (2003)CrossRefGoogle Scholar
  12. 12.
    Wadler, P.: Views: a way for pattern matching to cohabit with data abstraction. In: Conference Record of POPL 1987: The 14th ACM SIGPLAN-SIGACT Symposium on Principles of Programming Languages (1987)Google Scholar
  13. 13.
    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)CrossRefGoogle Scholar
  14. 14.
    Malcolm, G.: Data structures and program transformation. Science of Computer Programming 14, 255–279 (1990)MATHCrossRefMathSciNetGoogle Scholar
  15. 15.
    Schrage, M.: Proxima, a presentation-oriented editor for structured documents. PhD thesis, Utrecht University (October 2004)Google Scholar
  16. 16.
    Reynolds, J.C.: Definitional interpreters for higher-order programming languages. In: ACM 1972: Proceedings of the ACM annual conference, pp. 717–740. ACM Press, New York (1972)CrossRefGoogle Scholar
  17. 17.
    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)CrossRefGoogle Scholar
  18. 18.
    Holdermans, S., Jeuring, J., Löh, A., Rodriguez, A.: Generic views on data types. Technical Report UU-CS-2006-020, Department of Information and Computing Sciences, Utrecht University (2006)Google Scholar
  19. 19.
    Holdermans, S.: Generic views. Master’s thesis, Institute of Information and Computing Sciences, Utrecht University (2005)Google Scholar
  20. 20.
    Burton, F.W., Cameron, R.D.: Pattern matching with abstract data types. Journal of Functional Programming 3(2), 117–190 (1993)CrossRefMathSciNetGoogle Scholar
  21. 21.
    Okasaki, C.: Views for Standard ML. In: SIGPLAN Workshop on ML, pp. 14–23 (1998)Google Scholar
  22. 22.
    Burton, F.W., Meijer, E., Sansom, P., Thompson, S., Wadler, P.: Views: an extension to Haskell pattern matching (1996), Available from: http://www.haskell.org/development/views.html
  23. 23.
    Abiteboul, S.: On views and XML. In: Proceedings of the 18th ACM SIGACT-SIGMOD-SIGART Symposium on Principles of Database Systems, pp. 1–9. ACM Press, New York (1999)Google Scholar
  24. 24.
    Ohori, A., Tajima, K.: A polymorphic calculus for views and object sharing. In: Proceedings of the 13th ACM SIGACT-SIGMOD-SIGART Symposium on Principles of Database Systems, pp. 255–266 (1994)Google Scholar
  25. 25.
    Souza dos Santos, C., Abiteboul, S., Delobel, C.: Virtual schemas and bases. In: Jarke, M., Bubenko, J., Jeffery, K. (eds.) EDBT 1994. LNCS, vol. 779, pp. 81–94. Springer, Heidelberg (1994)Google Scholar
  26. 26.
    Altenkirch, T., McBride, C.: Generic programming within dependently typed programming. In: Gibbons, J., Jeuring, J. (eds.) Generic Programming: IFIP TC2/WG2.1 Working Conference on Generic Programming, Number 115 in International Federation for Information Processing, Dagstuhl, Germany, July 11-12, 2002, pp. 1–20. Kluwer Academic Publishers, Dordrecht (2003)Google Scholar
  27. 27.
    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)MATHMathSciNetGoogle Scholar

Copyright information

© Springer-Verlag Berlin Heidelberg 2006

Authors and Affiliations

  • Stefan Holdermans
    • 1
  • Johan Jeuring
    • 1
  • Andres Löh
    • 2
  • Alexey Rodriguez
    • 1
  1. 1.Department of Information and Computing SciencesUtrecht UniversityUtrechtThe Netherlands
  2. 2.Institut für Informatik IIIUniversität BonnBonnGermany

Personalised recommendations