Abstract
This paper proposes a new framework for a polytypic extension of functional programming languages. A functional polytypic program is one that is parameterised by datatype. Since polytypic functions are defined by induction on types rather than by induction on values, they typically operate on a higher level of abstraction than their monotypic counterparts. However, polytypic programming is not necessarily more complicated than conventional programming. In fact, a polytypic function is uniquely defined by its action on constant functors, projection functors, sums, and products. This information is sufficient to specialize a polytypic function to arbitrary datatypes, including mutually recursive datatypes and nested datatypes. The key idea is to use infinite trees as index sets for polytypic functions and to interpret datatypes as algebraic trees. This approach is simpler, more general, and more efficient than previous ones that are based on the initial algebra semantics of datatypes.
This is a preview of subscription content, log in via an institution.
Buying options
Tax calculation will be finalised at checkout
Purchases are for personal use only
Learn about institutional subscriptionsPreview
Unable to display preview. Download preview PDF.
References
Abadi, M., Cardelli, L., Pierce, B., Rémy, D.: Dynamic typing in polymorphic languages. J. Functional Programming 5(1), 111–130 (1995)
Bird, R.: Introduction to Functional Programming using Haskell, 2nd edn. Prentice Hall Europe, London (1998)
Bird, R., de Moor, O., Hoogendijk, P.: Generic functional programming with types and relations. J. 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)
Courcelle, B.: Fundamental properties of infinite trees. Theoretical Computer Science 25(2), 95–169 (1983)
Hinze, R.: Generalizing generalized tries. J. Functional Programming (1999) (accepted for publication)
Hinze, R.: Polytypic functions over nested datatypes. Discrete Mathematics and Theoretical Computer Science (1999) (accepted for publication)
Hinze, R.: Polytypic programming with ease. Technical Report IAI-TR-99-2, Institut fúr Informatik III, Universität Bonn (February 1999)
Jansson, P., Jeuring, J.: Polytypic compact printing and parsing. In: Swierstra, S.D. (ed.) ESOP 1999. LNCS, vol. 1576, pp. 273–287. Springer, Heidelberg (1999)
Jansson, P., Jeuring, J.: PolyP–a polytypic programming language extension. In: 24th Symposium on Principles of Programming Languages, POPL 1997, pp. 470–482. ACM-Press, New York (1997)
Jansson, P., Jeuring, J.: Functional Pearl: Polytypic unification. J. Functional Programming 8(5), 527–536 (1998)
Jansson, P., Jeuring, J.: PolyLib–A library of polytypic functions. In: Backhouse, R., Sheard, T. (eds.) Informal Proceedings Workshop on Generic Programming, WGP 1998. Department of Computing Science, Chalmers University of Technology and Göteborg University (June 1998), http://wsinwp01.win.tue.nl:1234/WGPProceedings/index.html
Jones, M.P.: Functional programming with overloading and higher-order polymorphism. In: Jeuring, J., Meijer, E. (eds.) AFP 1995. LNCS, vol. 925, pp. 97–136. Springer, Heidelberg (1995)
Jones, M.P., Peterson, J.C.: Hugs 98 User Manual (May 1999), Available from http://www.haskell.org/hugs
McCracken, N.J.: The typechecking of programs with implicit type structure. In: Plotkin, G., MacQueen, D.B., Kahn, G. (eds.) Semantics of Data Types 1984. LNCS, vol. 173, pp. 301–315. Springer, Heidelberg (1984)
Meertens, L.: Calculate polytypically! In: Kuchen, H., Swierstra, S.D. (eds.) PLILP 1996. LNCS, vol. 1140, pp. 1–16. Springer, Heidelberg (1996)
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)
Meijer, E., Hutton, G.: Bananas in space: Extending fold and unfold to exponential types. In: 7th Conference on Functional Programming Languages and Computer Architecture, FPCA 1995, pp. 324–333. ACM-Press, New York (1995)
Okasaki, C.: Purely Functional Data Structures. Cambridge University Press, Cambridge (1998)
Jones, S.P.: Explicit quantification in Haskell (1998), Available from http://research.microsoft.com/Users/simonpj/Haskell/quantification.html
Jones, S.P., Hughes, J. (eds.): Haskell 98 – A Non-strict, Purely Functional Language (February 1999), http://www.haskell.org/onlinereport/
Yang, Z.: Encoding types in ML-like languages. SIGPLAN Notices 34(1), 289–300 (1999)
Author information
Authors and Affiliations
Editor information
Editors and Affiliations
Rights and permissions
Copyright information
© 1999 Springer-Verlag Berlin Heidelberg
About this paper
Cite this paper
Hinze, R. (1999). Polytypic Programming With Ease. In: Middeldorp, A., Sato, T. (eds) Functional and Logic Programming. FLOPS 1999. Lecture Notes in Computer Science, vol 1722. Springer, Berlin, Heidelberg. https://doi.org/10.1007/10705424_2
Download citation
DOI: https://doi.org/10.1007/10705424_2
Publisher Name: Springer, Berlin, Heidelberg
Print ISBN: 978-3-540-66677-6
Online ISBN: 978-3-540-47950-5
eBook Packages: Springer Book Archive