Skip to main content

Polytypic Values Possess Polykinded Types

  • Conference paper
Mathematics of Program Construction (MPC 2000)

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

Included in the following conference series:

Abstract

A polytypic value is one that is defined by induction on the structure of types. In Haskell types are assigned so-called kinds that distinguish between manifest types like the type of integers and functions on types like the list type constructor. Previous approaches to polytypic programming were restricted in that they only allowed to parameterize values by types of one fixed kind. In this paper we show how to define values that are indexed by types of arbitrary kinds. It turns out that these polytypic values possess types that are indexed by kinds. We present several examples that demonstrate that the additional flexibility is useful in practice. One paradigmatic example is the mapping function, which describes the functorial action on arrows. A single polytypic definition yields mapping functions for datatypes of arbitrary kinds including first- and higher-order functors. Polytypic values enjoy polytypic properties. Using kind-indexed logical relations we prove among other things that the polytypic mapping function satisfies suitable generalizations of the functorial laws.

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. Amadio, R., Bruce, K.B., Longo, G.: The finitary projection model for second order lambda calculus and solutions to higher order domain equations. In: Proceedings of the Symposium on Logic in Computer Science, Cambridge, Massachusetts, pp. 122–130. IEEE Computer Society, Los Alamitos (1986)

    Google Scholar 

  2. Backhouse, R., Jansson, P., Jeuring, J., Meertens, L.: Generic Programming — An Introduction. In: Swierstra, S.D., Henriques, P.R., Oliveira, J.N. (eds.) AFP 1998. LNCS, vol. 1608, pp. 28–115. Springer, Heidelberg (1999)

    Chapter  Google Scholar 

  3. Bird, R., de Moor, O., Hoogendijk, P.: Generic functional programming with types and relations. Journal of Functional Programming 6(1), 1–28 (1996)

    Article  MATH  MathSciNet  Google Scholar 

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

    Chapter  Google Scholar 

  5. Fokkinga, M.M.: Monadic maps and folds for arbitrary datatypes. Technical Report Memoranda Informatica 94-28, University of Twente (June 1994)

    Google Scholar 

  6. Girard, J.-Y.: Interprétation fonctionelle et élimination des coupures dans l’arithmétique d’ordre supérieur. PhD thesis, Université Paris VII (1972)

    Google Scholar 

  7. Hinze, R.: Polytypic functions over nested datatypes. Discrete Mathematics and Theoretical Computer Science 3(4), 159–180 (1999)

    MathSciNet  Google Scholar 

  8. Hinze, R.: A new approach to generic functional programming. In: Reps, T.W. (ed.) Proceedings of the 27th Annual ACM SIGPLAN-SIGACT Symposium on Principles of Programming Languages, Boston, Massachusetts, January 19-21, pp. 119–132 (2000)

    Google Scholar 

  9. Hinze, R.: Polytypic programming with ease (January 2000) (in submission)

    Google Scholar 

  10. Hoogendijk, P., Backhouse, R.: When do datatypes commute? In: Moggi, E., Rosolini, G. (eds.) CTCS 1997. LNCS, vol. 1290, pp. 242–260. Springer, Heidelberg (1997)

    Chapter  Google Scholar 

  11. Jansson, P., Jeuring, J.: PolyP—a polytypic programming language extension. In: Conference Record 24thA CM SIGPLAN-SIGACT Symposium on Principles of Programming Languages, POPL 1997, Paris, France, pp. 470–482. ACM-Press, New York (1997)

    Chapter  Google Scholar 

  12. Jansson, P., Jeuring, J.: PolyLib—A library of polytypic functions. In: Backhouse, R., Sheard, T. (eds.) Informal Proceedings Workshop on Generic Programming, WGP 1998, Marstrand, Sweden. Department of Computing Science, Chalmers University of Technology and Göteborg University (June 1998)

    Google Scholar 

  13. Jansson, P., Jeuring, J.: Calculating polytypic data conversion programs (1999) (in submission)

    Google Scholar 

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

    Article  MATH  MathSciNet  Google Scholar 

  15. Jones, M.P., Peterson, J.C.: Hugs 98 User Manual (May 1999), Available from http://www.haskell.org/hugs

  16. Leivant, D.: Polymorphic type inference. In: Proc. 10th Symposium on Principles of Programming Languages (1983)

    Google Scholar 

  17. McCracken, N.J.: An Investigation of a Programming Language witha Polymorphic Type Structure. PhD thesis, Syracuse University (June 1979)

    Google Scholar 

  18. Meertens, L.: Calculate polytypically! In: Kuchen, H., Swierstra, S.D. (eds.) PLILP 1996. LNCS, vol. 1140, pp. 1–16. Springer, Heidelberg (1996)

    Google Scholar 

  19. Meijer, E., Hutton, G.: Bananas in space: Extending fold and unfold to exponential types. In: Conference Record 7th ACM SIGPLAN/SIGARCH and IFIP WG 2.8 International Conference on Functional Programming Languages and Computer Architecture, FPCA 1995, La Jolla, San Diego, CA, USA, pp. 324–333. ACM-Press, New York (1995)

    Google Scholar 

  20. Meijer, E., Jeuring, J.: Merging monads and folds for functional programming. In: Jeuring, J., Meijer, E. (eds.) AFP 1995. LNCS, vol. 925, pp. 228–266. Springer, Heidelberg (1995)

    Google Scholar 

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

    Article  MATH  MathSciNet  Google Scholar 

  22. Mitchell, J.C.: Foundations for Programming Languages. The MIT Press, Cambridge (1996)

    Google Scholar 

  23. Mycroft, A.: Polymorphic type schemes and recursive definitions. In: Paul, M., Robinet, B. (eds.) Programming 1984. LNCS, vol. 167, pp. 217–228. Springer, Heidelberg (1984)

    Google Scholar 

  24. Okasaki, C.: Purely Functional Data Structures. Cambridge University Press, Cambridge (1998)

    Book  Google Scholar 

  25. Jones, S.P., Hughes, J. (eds.): Haskell 98 — A Non-strict, Purely Functional Language (February 1999), Available from http://www.haskell.org/-definition/

  26. Jones, S.L.P.: Compiling Haskell by program transformation: A report from the trenches. In: Riis Nielson, H. (ed.) ESOP 1996. LNCS, vol. 1058, pp. 22–24. Springer, Heidelberg (1996)

    Google Scholar 

  27. Ruehr, K.F.: Analytical and Structural Polymorphism Expressed using Patterns over Types. PhD thesis, University of Michigan (1992)

    Google Scholar 

  28. The GHC Team. The Glasgow Haskell Compiler User’s Guide, Version 4.04 html (September 1999), Available from http://www.haskell.org/ghc/documentation

  29. Wadler, P.: Theorems for free! In: The Fourth International Conference on Functional Programming Languages and Computer Architecture (FPCA 1989), London, UK, pp. 347–359. Addison-Wesley Publishing Company, Reading (1989)

    Chapter  Google Scholar 

Download references

Author information

Authors and Affiliations

Authors

Editor information

Editors and Affiliations

Rights and permissions

Reprints and permissions

Copyright information

© 2000 Springer-Verlag Berlin Heidelberg

About this paper

Cite this paper

Hinze, R. (2000). Polytypic Values Possess Polykinded Types. In: Backhouse, R., Oliveira, J.N. (eds) Mathematics of Program Construction. MPC 2000. Lecture Notes in Computer Science, vol 1837. Springer, Berlin, Heidelberg. https://doi.org/10.1007/10722010_2

Download citation

  • DOI: https://doi.org/10.1007/10722010_2

  • Publisher Name: Springer, Berlin, Heidelberg

  • Print ISBN: 978-3-540-67727-7

  • Online ISBN: 978-3-540-45025-2

  • eBook Packages: Springer Book Archive

Publish with us

Policies and ethics