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.
Access this chapter
Tax calculation will be finalised at checkout
Purchases are for personal use only
Preview
Unable to display preview. Download preview PDF.
References
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)
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)
Bird, R., de Moor, O., Hoogendijk, P.: Generic functional programming with types and relations. Journal of Functional Programming 6(1), 1–28 (1996)
Bird, R., Meertens, L.: Nested datatypes. In: Jeuring, J. (ed.) MPC 1998. LNCS, vol. 1422, pp. 52–67. Springer, Heidelberg (1998)
Fokkinga, M.M.: Monadic maps and folds for arbitrary datatypes. Technical Report Memoranda Informatica 94-28, University of Twente (June 1994)
Girard, J.-Y.: Interprétation fonctionelle et élimination des coupures dans l’arithmétique d’ordre supérieur. PhD thesis, Université Paris VII (1972)
Hinze, R.: Polytypic functions over nested datatypes. Discrete Mathematics and Theoretical Computer Science 3(4), 159–180 (1999)
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)
Hinze, R.: Polytypic programming with ease (January 2000) (in submission)
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)
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)
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)
Jansson, P., Jeuring, J.: Calculating polytypic data conversion programs (1999) (in submission)
Jay, C.B., Bellè, G., Moggi, E.: Functorial ML. Journal of Functional Programming 8(6), 573–619 (1998)
Jones, M.P., Peterson, J.C.: Hugs 98 User Manual (May 1999), Available from http://www.haskell.org/hugs
Leivant, D.: Polymorphic type inference. In: Proc. 10th Symposium on Principles of Programming Languages (1983)
McCracken, N.J.: An Investigation of a Programming Language witha Polymorphic Type Structure. PhD thesis, Syracuse University (June 1979)
Meertens, L.: Calculate polytypically! In: Kuchen, H., Swierstra, S.D. (eds.) PLILP 1996. LNCS, vol. 1140, pp. 1–16. Springer, Heidelberg (1996)
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)
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)
Milner, R.: A theory of type polymorphism in programming. Journal of Computer and System Sciences 17(3), 348–375 (1978)
Mitchell, J.C.: Foundations for Programming Languages. The MIT Press, Cambridge (1996)
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)
Okasaki, C.: Purely Functional Data Structures. Cambridge University Press, Cambridge (1998)
Jones, S.P., Hughes, J. (eds.): Haskell 98 — A Non-strict, Purely Functional Language (February 1999), Available from http://www.haskell.org/-definition/
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)
Ruehr, K.F.: Analytical and Structural Polymorphism Expressed using Patterns over Types. PhD thesis, University of Michigan (1992)
The GHC Team. The Glasgow Haskell Compiler User’s Guide, Version 4.04 html (September 1999), Available from http://www.haskell.org/ghc/documentation
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)
Author information
Authors and Affiliations
Editor information
Editors and Affiliations
Rights 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