Skip to main content

Type-Indexed Data Types

  • Conference paper
  • First Online:

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

Abstract

A polytypic function is a function that can be instantiated on many data types to obtain data type specific functionality. Examples of polytypic functions are the functions that can be derived in Haskell, such as show, read, and ‘==’. More advanced examples are functions for digital searching, pattern matching, unification, rewriting, and structure editing. For each of these problems, we not only have to define polytypic functionality, but also a type-indexed data type: a data type that is constructed in a generic way from an argument data type. For example, in the case of digital searching we have to define a search tree type by induction on the structure of the type of search keys. This paper shows how to define type-indexed data types, discusses several examples of type-indexed data types, and shows how to specialize type-indexed data types. The approach has been implemented in Generic Haskell, a generic programming extension of the functional language Haskell.

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

Buying options

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

Learn about institutional subscriptions

Preview

Unable to display preview. Download preview PDF.

Unable to display preview. Download preview PDF.

References

  1. R. Backhouse, P. Jansson, J. Jeuring, and L. Meertens. Generic programming: An introduction. In S. Doaitse Swierstra, Pedro R. Henriques, and José N. Oliveira, editors, Advanced Functional Programming, volume 1608 of LNCS, pages 28–115. Springer-Verlag, 1999.

    Chapter  Google Scholar 

  2. Richard Bird, Oege de Moor, and Paul Hoogendijk. Generic functional programming with types and relations. Journal of Functional Programming, 6(1):1–28, 1996.

    Article  MATH  MathSciNet  Google Scholar 

  3. Manuel M.T. Chakravarty and Gabriele Keller. More types for nested data parallel programming. In Proceedings ICFP 2000: International Conference on Functional Programming, pages 94–105. ACM Press, 2000.

    Google Scholar 

  4. Koen Claessen and Peter Ljunglöf. Typed logical variables in Haskell. In Proceedings Haskell Workshop 2000, 2000.

    Google Scholar 

  5. Karl Crary and Stephanie Weirich. Flexible type analysis. In Proceedings ICFP 1999: International Conference on Functional Programming, pages 233–248. ACM Press, 1999.

    Google Scholar 

  6. Karl Crary, Stephanie Weirich, and J. Gregory Morrisett. Intensional polymorphism in type-erasure semantics. In Proceedings ICFP 1998: International Conference on Functional Programming, pages 301–312. ACM Press, 1998.

    Google Scholar 

  7. C. Dubois, F. Rouaix, and P. Weis. Extensional polymorphism. In 22nd Symposium on Principles of Programming Languages, POPL’ 95, pages 118–129, 1995.

    Google Scholar 

  8. M.M. Fokkinga. Law and Order in Algorithmics. PhD thesis, University of Twente, Dept INF, Enschede, The Netherlands, 1992.

    Google Scholar 

  9. Jeremy Gibbons. Polytypic downwards accumulations. In Proceedings of Mathematics of Program Construction, volume 1422 of LNCS. Springer-Verlag, June 1998.

    Chapter  Google Scholar 

  10. Robert Harper and Greg Morrisett. Compiling polymorphism using intensional type analysis. In 22nd Symposium on Principles of Programming Languages, POPL’ 95, pages 130–141, 1995.

    Google Scholar 

  11. Ralf Hinze. Generalizing generalized tries. Journal of Functional Programming, 10(4):327–351, 2000.

    Article  MATH  MathSciNet  Google Scholar 

  12. Ralf Hinze. Generic Programs and Proofs. 2000. Habilitationsschrift, Bonn University.

    Google Scholar 

  13. Ralf Hinze. A new approach to generic functional programming. In Conference Record of POPL’ 00: The 27th ACM SIGPLAN-SIGACT Symposium on Principles of Programming Languages, pages 119–132. ACM Press, 2000.

    Google Scholar 

  14. Ralf Hinze. Polytypic values possess polykinded types. In Roland Backhouse and José Nuno Oliveira, editors, Mathematics of Program Construction, volume 1837 of LNCS, pages 2–27. Springer-Verlag, 2000.

    Chapter  Google Scholar 

  15. Ralf Hinze and Simon Peyton Jones. Derivable type classes. In Graham Hutton, editor, Proceedings of the 2000 ACM SIGPLAN Haskell Workshop, volume 41.1 of Electronic Notes in Theoretical Computer Science. Elsevier Science, August 2001. The preliminary proceedings appeared as a University of Nottingham technical report.

    Google Scholar 

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

    Article  MATH  MathSciNet  Google Scholar 

  17. P. Jansson and J. Jeuring. PolyP — a polytypic programming language extension. In Conference Record of POPL’ 97: The 24th ACM SIGPLAN-SIGACT Symposium on Principles of Programming Languages, pages 470–482. ACM Press, 1997.

    Google Scholar 

  18. Patrik Jansson. The WWW home page for polytypic programming. Available from http://www.cs.chalmers.se/~patrikj/poly/, 2001.

  19. Patrik Jansson and Johan Jeuring. Functional pearl: Polytypic unification. Journal of Functional Programming, 8(5):527–536, September 1998.

    Google Scholar 

  20. Patrik Jansson and Johan Jeuring. A framework for polytypic programming on terms, with an application to rewriting. In J. Jeuring, editor, Workshop on Generic Programming 2000, Ponte de Lima, Portugal, July 2000, pages 33–45, 2000. Utrecht Technical Report UU-CS-2000-19.

    Google Scholar 

  21. C.B. Jay, G. Bellè, and E. Moggi. Functorial ML. Journal of Functional Programming, 8(6):573–619, 1998.

    Article  MATH  MathSciNet  Google Scholar 

  22. J. Jeuring. Polytypic pattern matching. In Conference Record of FPCA’ 95, SIGPLAN-SIGARCH-WG2.8 Conference on Functional Programming Languages and Computer Architecture, pages 238–248. ACM Press, 1995.

    Google Scholar 

  23. Mark P. Jones. Type classes with functional dependencies. In G. Smolka, editor, Proceedings of the 9th European Symposium on Programming, ESOP 2000, Berlin, Germany, volume 1782 of LNCS, pages 230–244. Springer-Verlag, March 2000.

    Google Scholar 

  24. Ralf Lämmel and Wolfgang Lohmann. Format Evolution. In J. Kouloumdjian, H.C. Mayr, and A. Erkollar, editors, Proc. 7th International Conference on Reverse Engineering for Information Systems (RETIS 2001), volume 155 of books@ocg.at, pages 113–134. OCG, 2001.

    Google Scholar 

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

    Article  MathSciNet  MATH  Google Scholar 

  26. Connor McBride. The derivative of a regular type is its type of one-hole contexts. Unpublished manuscript, 2001.

    Google Scholar 

  27. Nancy J. McCracken. An investigation of a programming language with a polymorphic type structure. PhD thesis, Syracuse University, June 1979.

    Google Scholar 

  28. L. Meertens. Paramorphisms. Formal Aspects of Computing, 4(5):413–425, 1992.

    Article  MATH  Google Scholar 

  29. E. Meijer, M.M. Fokkinga, and R. Paterson. Functional programming with bananas, lenses, envelopes, and barbed wire. In J. Hughes, editor, FPCA’91: Functional Programming Languages and Computer Architecture, volume 523 of LNCS, pages 124–144. Springer-Verlag, 1991.

    Google Scholar 

  30. John C. Mitchell. Foundations for Programming Languages. The MIT Press, 1996.

    Google Scholar 

  31. Simon Peyton Jones [editor], John Hughes [editor], Lennart Augustsson, Dave Barton, Brian Boutel, Warren Burton, Simon Fraser, Joseph Fasel, Kevin Hammond, Ralf Hinze, Paul Hudak, Thomas Johnsson, Mark Jones, John Launchbury, Erik Meijer, John Peterson, Alastair Reid, Colin Runciman, and Philip Wadler. Haskell 98 — A non-strict, purely functional language. Available from http://www.haskell.org/definition/, February 1999.

  32. Valery Trifonov, Bratin Saha, and Zhong Shao. Fully reflexive intensional type analysis. In Proceedings ICFP 2000: International Conference on Functional Programming, pages 82–93. ACM Press, 2000.

    Google Scholar 

  33. Måns Vestin. Genetic algorithms in Haskell with polytypic programming. Examensarbeten 1997:36, Göteborg University, Gothenburg, Sweden, 1997. Available from the Polytypic programming WWW page [18].

    Google Scholar 

  34. Stephanie Weirich. Encoding intensional type analysis. In European Symposium on Programming, volume 2028 of LNCS, pages 92–106. Springer-Verlag, 2001.

    Google Scholar 

  35. Jan de Wit. A technical overview of Generic Haskell. Master’s thesis, Department of Information and Computing Sciences, Utrecht University, 2002.

    Google Scholar 

  36. Zhe Yang. Encoding types in ML-like languages. In Proceedings ICFP 1998: International Conference on Functional Programming, pages 289–300. ACM Press, 1998.

    Google Scholar 

Download references

Author information

Authors and Affiliations

Authors

Editor information

Editors and Affiliations

Rights and permissions

Reprints and permissions

Copyright information

© 2002 Springer-Verlag Berlin Heidelberg

About this paper

Cite this paper

Hinze, R., Jeuring, J., Löh, A. (2002). Type-Indexed Data Types. In: Boiten, E.A., Möller, B. (eds) Mathematics of Program Construction. MPC 2002. Lecture Notes in Computer Science, vol 2386. Springer, Berlin, Heidelberg. https://doi.org/10.1007/3-540-45442-X_10

Download citation

  • DOI: https://doi.org/10.1007/3-540-45442-X_10

  • Published:

  • Publisher Name: Springer, Berlin, Heidelberg

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

  • Online ISBN: 978-3-540-45442-7

  • eBook Packages: Springer Book Archive

Publish with us

Policies and ethics