Distinguishing Data Structures and Functions: The Constructor Calculus and Functorial Types
The expressive power of functional programming can be improved by identifying and exploiting the characteristics that distinguish data types from function types. Data types support generic functions for equality, mapping, folding, etc. that do not apply to functions. Such generic functions require case analysis, or pattern-matching, where the branches may have incompatible types, e.g. products or sums. This is handled in the constructor calculus where specialisation of program extensions is governed by constructors for data types. Typing of generic functions employs polymorphism over functors in a functorial type system. The expressive power is greatly increased by allowing the functors to be polymorphic in the number of arguments they take, i.e. in their arities. The resulting system can define and type the fundamental examples above. Some basic properties are established, namely subject reduction, the Church-Rosser property, and the existence of a practical type inference algorithm.
KeywordsData Type Natural Transformation Expressive Power Type Scheme Reduction Rule
Unable to display preview. Download preview PDF.
- [Aa97]L Augustsson and all. Report on the functional programming language Haskell: version 1.4. Technical report, University of Glasgow, 1997.Google Scholar
- [BS98]R. Backhouse and T. Sheard, editors. Workshop on Generic Programming: Marstrand, Sweden, 18th June, 1998. Chalmers University of Technology, 1998.Google Scholar
- [CF92]J.R.B. Cockett and T. Fukushima. About Charity. Technical Report 92/480/18, University of Calgary, 1992.Google Scholar
- [GLT89]J-Y. Girard, Y. Lafont, and P. Taylor. Proofs and Types. Tracts in Theoretical Computer Science. Cambridge University Press, 1989.Google Scholar
- [Hin00]R. Hinze. A new approach to generic functional programming. In Proceedings of the 27th Annual ACM SIGPLAN-SIGACT Symposium on Principles of Programming Languages, Boston, Massachusetts, January 19–21, 2000, 2000.Google Scholar
- [Hyl82]J.M.E. Hyland. The effective topos. In A.S. Troelstra and D. van Dalen, editors, The L.E.J. Brouwer Centenary Symposium. North Holland, 1982.Google Scholar
- [Jan00]P. Jansson. Functional Polytypic Programming. PhD thesis, Chalmers University, 2000.Google Scholar
- [Jay95a]C.B. Jay. Polynomial polymorphism. In R. Kotagiri, editor, Proceedings of the Eighteenth Australasian Computer Science Conference: Glenelg, South Australia 1–3 February, 1995, volume 17, pages 237–243. A.C.S. Communications, 1995.Google Scholar
- [Jay96]C.B. Jay. Data categories. In M.E. Houle and P. Eades, editors, Computing: The Australasian Theory Symposium Proceedings, Melbourne, Australia, 29–30 January, 1996, volume 18, pages 21–28. Australian Computer Science Communications, 1996. ISSN 0157-3055.Google Scholar
- [Jay00]C.B. Jay. Distinguishing data structures and functions: the constructor calculus and functorial types. http://www-staff.it.uts.edu.au/~cbj/Publications/constructors.ps, 2000.
- [Jeu00]J. Jeuring, editor. Proceedings: Workshop on Generic Programming (WGP2000): July 6, 2000, Ponte de Lima, Portugal. Utrecht University, UU-CS-2000-19, 2000.Google Scholar
- [JJ97]P. Jansson and J. Jeuring. PolyP — a polytypic programming language extension. In POPL’ 97: The 24th ACM SIGPLAN-SIGACT Symposium on Principles of Programming Languages, pages 470–482. ACM Press, 1997.Google Scholar
- [Klo80]J.W. Klop. Combinatory Reduction Systems. PhD thesis, Mathematical Center Amsterdam, 1980. Tracts 129.Google Scholar
- [MFP91]E. Meijer, M. Fokkinga, and R. Paterson. Functional programming with bananas, lenses, envelopes and barbed wire. In J. Hughes, editor, Procceding of the 5th ACM Conference on Functional Programming and Computer Architecture, volume 523 of Lecture Notes in Computer Science, pages 124–44. Springer Verlag, 1991.Google Scholar
- [Mil78]R. Milner. A theory of type polymorphism in programming. JCSS, 17, 1978.Google Scholar
- [MT91]R. Milner and M. Tofte. Commentary on Standard ML. MIT Press, 1991.Google Scholar
- [Rey85]J. Reynolds. Types, abstraction, and parametric polymorphism. In R.E.A. Mason, editor, Information Processing’ 83. North Holland, 1985.Google Scholar