Polytypic Values Possess Polykinded Types

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


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.


Mapping Function Logical Relation Type Term Type Constructor Manifest Type 
These keywords were added by machine and not by the authors. This process is experimental and the keywords may be updated as the learning algorithm improves.


Unable to display preview. Download preview PDF.

Unable to display preview. Download preview PDF.


  1. 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. 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)CrossRefGoogle Scholar
  3. 3.
    Bird, R., de Moor, O., Hoogendijk, P.: Generic functional programming with types and relations. Journal of Functional Programming 6(1), 1–28 (1996)zbMATHCrossRefMathSciNetGoogle Scholar
  4. 4.
    Bird, R., Meertens, L.: Nested datatypes. In: Jeuring, J. (ed.) MPC 1998. LNCS, vol. 1422, pp. 52–67. Springer, Heidelberg (1998)CrossRefGoogle Scholar
  5. 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. 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. 7.
    Hinze, R.: Polytypic functions over nested datatypes. Discrete Mathematics and Theoretical Computer Science 3(4), 159–180 (1999)MathSciNetGoogle Scholar
  8. 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. 9.
    Hinze, R.: Polytypic programming with ease (January 2000) (in submission) Google Scholar
  10. 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)CrossRefGoogle Scholar
  11. 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)CrossRefGoogle Scholar
  12. 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. 13.
    Jansson, P., Jeuring, J.: Calculating polytypic data conversion programs (1999) (in submission)Google Scholar
  14. 14.
    Jay, C.B., Bellè, G., Moggi, E.: Functorial ML. Journal of Functional Programming 8(6), 573–619 (1998)zbMATHCrossRefMathSciNetGoogle Scholar
  15. 15.
    Jones, M.P., Peterson, J.C.: Hugs 98 User Manual (May 1999), Available from
  16. 16.
    Leivant, D.: Polymorphic type inference. In: Proc. 10th Symposium on Principles of Programming Languages (1983)Google Scholar
  17. 17.
    McCracken, N.J.: An Investigation of a Programming Language witha Polymorphic Type Structure. PhD thesis, Syracuse University (June 1979)Google Scholar
  18. 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. 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. 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. 21.
    Milner, R.: A theory of type polymorphism in programming. Journal of Computer and System Sciences 17(3), 348–375 (1978)zbMATHCrossRefMathSciNetGoogle Scholar
  22. 22.
    Mitchell, J.C.: Foundations for Programming Languages. The MIT Press, Cambridge (1996)Google Scholar
  23. 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. 24.
    Okasaki, C.: Purely Functional Data Structures. Cambridge University Press, Cambridge (1998)CrossRefGoogle Scholar
  25. 25.
    Jones, S.P., Hughes, J. (eds.): Haskell 98 — A Non-strict, Purely Functional Language (February 1999), Available from
  26. 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. 27.
    Ruehr, K.F.: Analytical and Structural Polymorphism Expressed using Patterns over Types. PhD thesis, University of Michigan (1992)Google Scholar
  28. 28.
    The GHC Team. The Glasgow Haskell Compiler User’s Guide, Version 4.04 html (September 1999), Available from
  29. 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)CrossRefGoogle Scholar

Copyright information

© Springer-Verlag Berlin Heidelberg 2000

Authors and Affiliations

  • Ralf Hinze
    • 1
  1. 1.Institut für Informatik IIIUniversität BonnBonnGermany

Personalised recommendations