ACM Home Page
Please provide us with feedback. Feedback
A new approach to generic functional programming
Full text PdfPdf (1.68 MB)
Source Annual Symposium on Principles of Programming Languages archive
Proceedings of the 27th ACM SIGPLAN-SIGACT symposium on Principles of programming languages table of contents
Boston, MA, USA
Pages: 119 - 132  
Year of Publication: 2000
ISBN:1-58113-125-9
Author
Ralf Hinze  Institut für Informatik III, Universität Bonn, Römerstraβe 164, 53117 Bonn, Germany
Sponsors
SIGPLAN: ACM Special Interest Group on Programming Languages
SIGACT: ACM Special Interest Group on Algorithms and Computation Theory
Publisher
ACM  New York, NY, USA
Bibliometrics
Downloads (6 Weeks): 7,   Downloads (12 Months): 64,   Citation Count: 22
Additional Information:

abstract   references   cited by   index terms   collaborative colleagues  

Tools and Actions: Request Permissions Request Permissions    Review this Article  
DOI Bookmark: Use this link to bookmark this Article: http://doi.acm.org/10.1145/325694.325709
What is a DOI?

ABSTRACT

This paper describes a new approach to generic functional programming, which allows us to define functions generically for all datatypes expressible in Haskell. A generic function is one that is defined by induction on the structure of types. Typical examples include pretty printers, parsers, and comparison functions. The advanced type system of Haskell presents a real challenge: datatypes may be parameterized not only by types but also by type constructors, type definitions may involve mutual recursion, and recursive calls of type constructors can be arbitrarily nested. We show that—despite this complexity—a generic function is uniquely defined by giving cases for primitive types and type constructors (such as disjoint unions and cartesian products). Given this information a generic function can be specialized to arbitrary Haskell datatypes. The key idea of the approach is to model types by terms of the simply typed &lgr;-calculus augmented by a family of recursion operators. While conceptually simple, our approach places high demands on the type system: it requires polymorphic recursion, rank-n types, and a strong form of type constructor polymorphism. Finally, we point out connections to Haskell's class system and show that our approach generalizes type classes in some respects.


REFERENCES

Note: OCR errors may be found in this Reference List extracted from the full text article. ACM has opted to expose the complete List rather than only correct and linked references.

 
1
M. Abadi, L. Cardelli, B. Pierce, and D. R~my. Dynamic typing in polymorphic languages. Journal of Functional Programming, 5(1):111-130, January 1995.
 
2
H. P. Barendregt. The Lambda Calculus m Its Syntax and Semantics. North-Holland, Amsterdam New York Oxford, revised edition, 1984.
 
3
 
4
 
5
 
6
 
7
Richard Bird and Ross Paterson. Generalised folds for nested datatypes. Formal Aspects o} Computing, 11(2):200-222, 1999.
 
8
Robin Cockett and Tom Fukushima. About Charity. Yellow Series Report 92/480/18, Dept. of Computer Science, Univ. of Calgary, June 1992.
 
9
Bruno Courcelle. Fundamental properties of infinite trees. Theoretical Computer Science, 25(2):95-169, March 1983.
10
 
11
Jean-Yves Girard. Interpretation fonctionelle et dlimination des coupures dans l'ar~thdtique d'ordre supdrieur. PhD thesis, Universit~ Paris VII, 1972.
 
12
T. Hagino. Category Theoretic Approach to Data Types. PhD thesis, University of Edinburgh, 1987.
13
14
 
15
Ralf Hinze. Numerical representations as higher-order nested datatypes. Technical Report IAI-TR-98-12, Institut fiir Informatik III, Universit~t Bonn, December 1998.
 
16
 
17
Ralf Hinze. A generic programming extension for Haskell. In Erik Meijer, editor, Proceedings of the 3rd Haskelt Workshop, Paris, France, September 1999. The proceedings appear as a technical report of Universiteit Utrecht, UU-CS-1999-28.
 
18
Ralf Hinze. Manufacturing datatypes. In Chris Okasaki, editor, Proceedings of the Workshop on Algorithmic Aspects of Advanced Programming Languages, WAAAPL'99, Paris, France, pages 1-16, September 1999. The proceedings appear as a technical report of Columbia University, CUCS-023-99, also available from http ://www. cs. columbia, edu/~ cdo/waaapl, html.
 
19
Ralf Hinze. Polytypic functions over nested datatypes. Discrete Mathematics and Theoretical Computer Science, 3(4):159-180, 1999.
 
20
21
 
22
Patrik Jansson and Johan Jeuring. PolyLib--A library of polytypic functions. In Roland Backhouse and Tim Sheard, editors, Informal Proceedings Workshop on Generic Programming, WGP'98, Marstrand, Sweden. Department of Computing Science, Chalmers University of Technology and GSteborg University, June 1998.
 
23
 
24
 
25
 
26
 
27
Mark P. Jones. A system of constructor classes: overloading and implicit higher-order polymorphism. Journal of Functional Programming, 5(1):1-35, January 1995.
 
28
 
29
M.P. Jones and J.C. Peterson. Hugs 98 User Manual, May 1999. Available from http://www, haskell, org/ hugs.
 
30
 
31
32
 
33
 
34
35
 
36
Simon Peyton Jones. Explicit quantification in Haskell, 1998. Available from http://research.microsoft. com/Us ers / s imonp j/Haske ii / quant if i cat i on. html.
 
37
Simon Peyton Jones and John Hughes, editors. Haskell 98 -- A Non-strict, Purely Functional Language, February 1999. Available from http://www, haskell, org/definition/.
 
38
 
39
Simon L. Peyton Jones and Erik Meijer. Henk: A typed intermediate language. In Proceedings of the Types in Compilation Workshop, Amsterdam, june, 1997. Available from http://~w, cs. be. edu/"muller/TIC97/.
 
40
Fritz Ruehr. Structural polymorphism. In Roland Backhouse and Tim Sheaxd, editors, Informal Proceedings Workshop on Generic Programming, WGP'98, Marstrand, Sweden, 18 June 1998. Dept. of Computing Science, Chalmers Univ. of Techn. and GSteborg Univ., June 1998.
 
41
Karl Fritz l%uehr. Analytical and Structural Polymorphism Expressed using Patterns over Types. PhD thesis, University of Michigan, 1992.
42
 
43
Tim Sheard. Type parametric programming. Technical report CS/E 93-018, Oregon Graduate Institute of Science and Technology, Department of Computer Science and Engineering, Portland, OR, USA, November 1993.
44
45

CITED BY  22