A Generic Programming Extension for Clean
Generic programming enables the programmer to define functions by induction on the structure of types. Defined once, such a generic function can be used to generate a specialized function for any user defined data type. Several ways to support generic programming in functional languages have been proposed, each with its own pros and cons. In this paper we describe a combination of two existing approaches, which has the advantages of both of them. In our approach overloaded functions with class variables of an arbitrary kind can be defined generically. A single generic definition defines a kind-indexed family of overloaded functions, one for each kind. For instance, the generic mapping function generates an overloaded mapping function for each kind.
Additionally, we propose a separate extension that allows to specify a customized instance of a generic function for a type in terms of the generated instance for that type.
KeywordsData Type Class Variable Generic Extension Conversion Function Primitive Type
Unable to display preview. Download preview PDF.
- 1.Ralf Hinze and Simon Peyton Jones. Derivable Type Classes. In Graham Hutton, editor, Proceedings of the Fourth HaskellWorkshop, Montreal, Canada, September 17, 2000Google Scholar
- 2.Ralf Hinze. Polytypic values possess polykinded types. In Roland Backhouse, J.N. Oliveira, editors, Proceedings of the Fifth International Conference on Mathematics of Program Construction (MPC 2000), Ponte de Lima, Portugal, July 3–5, 2000.Google Scholar
- 3.Ralf 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.Google Scholar
- 4.Ralf Hinze. A Generic Programming Extension for Haskell In Erik Meijer, editor, Proceedings of the Third Haskell Workshop, Paris, France, September 1999. The proceedings appear as a technical report of Universiteit Utrecht, UU-CS-1999-28.Google Scholar
- 5.Juan Chen and Andrew W. Appel. Dictionary Passing for Polytypic Polymorphism Princeton University Computer Science TR-635-01, March 2001.Google Scholar
- 6.P. Jansson and J. Jeuring, PolyP-a polytypic programming language extension, POPL’ 97: The 24th ACM SIGPLAN-SIGACT Symposium on Principles of Programming Languages, ACM Press 470–482, 1997.Google Scholar
- 7.M. J. Plasmeijer, M.C.J.D. van Eekelen Language Report Concurrent Clean. Version 1.3. Technical Report CSI R9816, Faculty of mathematics and Informatics, Catholic University of Nijmegen, June 1998. Also available at http://www.cs.kun.nl/~clean/Manuals/manuals.html
- 8.Ralf Lämmel, Joost Visser, and Jan Kort. Dealing with large bananas. In Johan Jeuring, editor, Workshop on Generic Programming, Ponte de Lima, July 2000. Technical Report UU-CS-2000-19, Universiteit Utrecht.Google Scholar