Datatype-Generic Programming

Generic programming aims to increase the flexibility of programming languages, by expanding the possibilities for parametrization -- ideally, without also expanding the possibilities for uncaught errors. The term means different things to different people: parametric polymorphism, data abstraction, meta-programming, and so on. We use it to mean polytypism, that is, parametrization by the shape of data structures rather than their contents. To avoid confusion with other uses, we have coined the qualified term datatype-generic programming for this purpose. In these lecture notes, we expand on the definition of datatype-generic programming, and present some examples of datatype-generic programs. We also explore the connection with design patterns in object-oriented programming; in particular, we argue that certain design patterns are just higher-order datatype-generic programs.

[1]  Philip Wadler How to solve the reuse problem? Functional programming , 1998, Proceedings. Fifth International Conference on Software Reuse (Cat. No.98TB100203).

[2]  Ralph Johnson,et al.  design patterns elements of reusable object oriented software , 2019 .

[3]  Alberto Pardo,et al.  Fusion of recursive programs with computational effects , 2001, Theor. Comput. Sci..

[4]  Jeremy Gibbons,et al.  Enumerating the Rationals , 2004 .

[5]  Walid Taha,et al.  A Gentle Introduction to Multi-stage Programming , 2003, Domain-Specific Program Generation.

[6]  Pieter H. Hartel,et al.  Programming Languages: Implementations, Logics, and Programs , 1996, Lecture Notes in Computer Science.

[7]  James Cheney,et al.  A lightweight implementation of generics and dynamics , 2002, Haskell '02.

[8]  Philip Wadler XQuery: A Typed Functional Language for Querying XML , 2002, Advanced Functional Programming.

[9]  Irmgard Hofmann Ärzte und Pflegende - Dialogkultur mangelhaft! , 2002 .

[10]  Alan Bundy,et al.  Constructing Induction Rules for Deductive Synthesis Proofs , 2006, CLASE.

[11]  Simon L. Peyton Jones,et al.  Imperative functional programming , 1993, POPL '93.

[12]  Alexander A. Stepanov,et al.  Generic Programming , 1988, ISSAC.

[13]  Peter D. Mosses,et al.  Casl Reference Manual , 2004, Lecture Notes in Computer Science.

[14]  Richard D. Jenks,et al.  AXIOM: the scientific computation system , 1992 .

[15]  Philip Wadler,et al.  Comprehending monads , 1990, LISP and Functional Programming.

[16]  Sam Lindley,et al.  Extensional Rewriting with Sums , 2007, TLCA.

[17]  Barbara Liskov A history of CLU , 1996 .

[18]  Ralf Hinze,et al.  Polytypic values possess polykinded types , 2000, Sci. Comput. Program..

[19]  Maarten M. Fokkinga,et al.  Program Calculation Properties of Continuous Algebras , 1991 .

[20]  Oege de Moor,et al.  The Fun of Programming , 2003 .

[21]  Richard S. Bird Using circular programs to eliminate multiple traversals of data , 2004, Acta Informatica.

[22]  Simon L. Peyton Jones,et al.  Simple unification-based type inference for GADTs , 2006, ICFP '06.

[23]  Hartmut Ehrig,et al.  Fundamentals of Algebraic Specification 2: Module Specifications and Constraints , 1990 .

[24]  Johan Jeuring,et al.  Merging Monads and Folds for Functional Programming , 1995, Advanced Functional Programming.

[25]  Eugenio Moggi,et al.  Notions of Computation and Monads , 1991, Inf. Comput..

[26]  Philip Wadler,et al.  Theorems for free! , 1989, FPCA.

[27]  Alexander A. Stepanov,et al.  The Ada® Generic Library , 1989, Springer Compass International.

[28]  Ralf Lämmel,et al.  Haskell's overlooked object system , 2005, ArXiv.

[29]  Robin Milner,et al.  Definition of standard ML , 1990 .

[30]  Gregor Kiczales,et al.  Aspect-oriented programming , 2001, ESEC/FSE-9.

[31]  Johan Jeuring,et al.  Polytypic data conversion programs , 2002, Sci. Comput. Program..

[32]  Varmo Vene,et al.  Recursion Schemes for Dynamic Programming , 2006, MPC.

[33]  Maarten M. Fokkinga,et al.  Functional Programming with Bananas, Lenses, Envelopes and Barbed Wire , 1991, FPCA.

[34]  Simon L. Peyton Jones,et al.  Derivable Type Classes , 2001, Haskell.

[35]  Ralf Hinze,et al.  Comparing Approaches to Generic Programming in Haskell , 2006, SSDGP.

[36]  Satoshi Matsuoka,et al.  ECOOP'97 — Object-Oriented Programming , 1997, Lecture Notes in Computer Science.

[37]  Andres Löh,et al.  Generic H∀SKELL, Specifically , 2003 .

[38]  Lambert G. L. T. Meertens Calculate Polytypically! , 1996, PLILP.

[39]  Bjarne Stroustrup,et al.  Specifying C++ concepts , 2006, POPL '06.

[40]  Krzysztof Czarnecki,et al.  Generative programming - methods, tools and applications , 2000 .

[41]  James McKinna,et al.  Why dependent types matter , 2006, POPL '06.

[42]  Stephanie Weirich,et al.  An open and shut typecase , 2005, TLDI '05.

[43]  Matthew H. Austern Generic programming and the STL - using and extending the C++ standard template library , 1999, Addison-Wesley professional computing series.

[44]  C. Barry Jay,et al.  Monads, shapely functors, and traversals , 1999, CTCS.

[45]  Todd L. Veldhuizen,et al.  Active libraries and universal languages , 2004 .

[46]  Christopher Strachey,et al.  Fundamental Concepts in Programming Languages , 2000, High. Order Symb. Comput..

[47]  John McCarthy,et al.  Recursive functions of symbolic expressions and their computation by machine, Part I , 1959, Commun. ACM.

[48]  Niklaus Wirth,et al.  Pascal User Manual and Report , 1991, Springer New York.

[49]  Ralf Hinze Church numerals, twice! , 2005, J. Funct. Program..

[50]  Peter G. Harrison,et al.  Functional Programming , 1988 .

[51]  Tarmo Uustalu,et al.  Build, Augment and Destroy, Universally , 2004, APLAS.

[52]  Richard S. Bird,et al.  Generic functional programming with types and relations , 1996, Journal of Functional Programming.

[53]  Ranko S. Lazic,et al.  A semantic study of data independence with applications to model checking , 1999 .

[54]  Thomas Kühne,et al.  Internal Iteration Externalized , 1999, ECOOP.

[55]  Henry Ledgard,et al.  Reference Manual for the ADA® Programming Language , 1983, Springer New York.

[56]  Johan Jeuring,et al.  PolyP—a polytypic programming language extension , 1997, POPL '97.

[57]  Norman Ramsey,et al.  Advanced Functional Programming , 2005 .

[58]  David B. MacQueen,et al.  The Definition of Standard ML (Revised) , 1997 .

[59]  Alan J. Perlis,et al.  Preliminary report: international algebraic language , 1958, CACM.

[60]  Kenneth E. Iverson,et al.  A programming language , 1899, AIEE-IRE '62 (Spring).

[61]  A. Bansal,et al.  Programming Language Implementation and Logic Programming , 1991, Lecture Notes in Computer Science.

[62]  John C. Reynolds,et al.  Types, Abstraction and Parametric Polymorphism , 1983, IFIP Congress.

[63]  Lucio Grandinetti,et al.  Software for Parallel Computation , 1993, NATO ASI Series.

[64]  Jim Law,et al.  Review of "The boost graph library: user guide and reference manual by Jeremy G. Siek, Lie-Quan Lee, and Andrew Lumsdaine." Addison-Wesley 2002. , 2003, SOEN.

[65]  Andrew M. Pitts,et al.  Category Theory and Computer Science , 1987, Lecture Notes in Computer Science.

[66]  Ira R. Forman Putting Metaclasses To Work , 1998, Proceedings. Technology of Object-Oriented Languages. TOOLS 26 (Cat. No.98EX176).

[67]  Sibylle Schupp,et al.  Making the Usage of STL Safe , 2002, Generic Programming.

[68]  Richard S. Bird,et al.  Nested Datatypes , 1998, MPC.

[69]  Jeremy G. Siek,et al.  Essential language support for generic programming , 2005, PLDI '05.

[70]  John C. Reynolds,et al.  Towards a theory of type structure , 1974, Symposium on Programming.

[71]  Bruno C. d. S. Oliveira,et al.  TypeCase: a design pattern for type-indexed functions , 2005, Haskell '05.

[72]  Ralf Hinze,et al.  Generic Haskell: Practice and Theory , 2003, Generic Programming.

[73]  Cristina V. Lopes,et al.  Aspect-oriented programming , 1999, ECOOP Workshops.

[74]  Tim Sheard,et al.  Generic Programming in Ωmega , 2006, SSDGP.

[75]  J. Y. Girard,et al.  Interpretation fonctionelle et elimination des coupures dans l'aritmetique d'ordre superieur , 1972 .

[76]  Hartmut Ehrig,et al.  Fundamentals of Algebraic Specification 1 , 1985, EATCS Monographs on Theoretical Computer Science.

[77]  Philip Wadler,et al.  Combining Monads , 1992 .

[78]  Peter D. Mosses,et al.  CASL User Manual , 2004, Lecture Notes in Computer Science.

[79]  Karl Fritz Ruehr,et al.  Analytical and structural polymorphism expressed using patterns over types , 1992 .

[80]  T. A. Team Programatica Tools for Certifiable , Auditable Development of High-assurance Systems in Haskell , 2003 .

[81]  J. E. L. Peck,et al.  Revised report on the algorithmic language ALGOL 68 , 2004, Acta Informatica.

[82]  Luca Cardelli,et al.  On understanding types, data abstraction, and polymorphism , 1985, CSUR.

[83]  Roland Carl Backhouse,et al.  Elements of a Relational Theory of Datatypes , 1993, Formal Program Development.

[84]  Daniel G. Bobrow,et al.  Book review: The Art of the MetaObject Protocol By Gregor Kiczales, Jim des Rivieres, Daniel G. and Bobrow(MIT Press, 1991) , 1991, SGAR.

[85]  Simon L. Peyton Jones,et al.  A short cut to deforestation , 1993, FPCA '93.

[86]  Jack Edmonds,et al.  Matroids and the greedy algorithm , 1971, Math. Program..

[87]  Alexander A. Stepanov,et al.  Fundamentals of Generic Programming , 1998, Generic Programming.

[88]  R. Backhouse,et al.  Regular Algebra Applied to Path-finding Problems , 1975 .

[89]  Andres Löh,et al.  Generic Haskell, Specifically , 2002, Generic Programming.

[90]  V. Stavridou,et al.  Abstraction and specification in program development , 1988 .

[91]  G. Malcolm,et al.  Data Structures and Program Transformation , 1990, Sci. Comput. Program..

[92]  Tatsuya Hagino,et al.  A categorical programming language , 2020, ArXiv.

[93]  Andrei Alexandrescu,et al.  Modern C++ Design , 2001 .

[94]  Friedrich L. Bauer,et al.  Revised report on the algorithm language ALGOL 60 , 1963, CACM.

[95]  Alberto Pardo Combining Datatypes and Effects , 2004, Advanced Functional Programming.

[96]  Rachid Guerraoui,et al.  ECOOP’ 99 — Object-Oriented Programming , 1999, Lecture Notes in Computer Science.

[97]  John Hughes,et al.  Why Functional Programming Matters , 1989, Comput. J..

[98]  Conor McBride,et al.  Applicative programming with effects , 2008, J. Funct. Program..

[99]  Robin Milner,et al.  A Theory of Type Polymorphism in Programming , 1978, J. Comput. Syst. Sci..

[100]  Richard S. Bird,et al.  Lectures on Constructive Functional Programming , 1989 .

[101]  Robin Milner,et al.  Principal type-schemes for functional programs , 1982, POPL '82.

[102]  Jeremy Gibbons,et al.  Calculating Functional Programs , 2000, Algebraic and Coalgebraic Methods in the Mathematics of Program Construction.

[103]  Martin Aigner,et al.  Proofs from THE BOOK , 1998 .

[104]  C. A. R. Hoare,et al.  A contribution to the development of ALGOL , 1966, CACM.

[105]  Hartmut Ehrig,et al.  Fundamentals of Algebraic Specification 1: Equations and Initial Semantics , 1985 .

[106]  Alexander A. Stepanov,et al.  The Ada® Generic Library: Linear List Processing Packages , 1989 .

[107]  Tony Hoare,et al.  Notes on Data Structuring , 1972 .

[108]  Bjarne Stroustrup,et al.  Concepts: linguistic support for generic programming in C++ , 2006, OOPSLA '06.

[109]  Martin Odersky,et al.  Domain-Specific Program Generation , 2004, Lecture Notes in Computer Science.

[110]  Jeremy Gibbons,et al.  Design patterns as higher-order datatype-generic programs , 2006, WGP '06.

[111]  Graham Hutton,et al.  When is a function a fold or an unfold? , 2001, CMCS.

[112]  Roland Carl Backhouse,et al.  Algebraic and Coalgebraic Methods in the Mathematics of Program Construction , 2000, Lecture Notes in Computer Science.

[113]  Bernhard Möller,et al.  Formal Program Development , 1993, Lecture Notes in Computer Science.

[114]  Tobias Nipkow,et al.  Automating Squiggol , 1990, Programming Concepts and Methods.

[115]  Richard S. Bird,et al.  FUNCTIONAL PEARL: Enumerating the rationals , 2006, Journal of Functional Programming.

[116]  Paul Steckler,et al.  The Functional Imperative: Shape! , 1998, ESOP.

[117]  C. Barry Jay,et al.  A Semantics for Shape , 1995, Sci. Comput. Program..

[118]  Tarmo Uustalu,et al.  Primitive (Co)Recursion and Course-of-Value (Co)Iteration, Categorically , 1999, Informatica.

[119]  Peyton Jones,et al.  Haskell 98 language and libraries : the revised report , 2003 .

[120]  Patrik Jansson Functional Polytypic Programming , 2000 .

[121]  Barbara Liskov,et al.  Abstraction and Specification in Program Development , 1986 .

[122]  Erik Poll,et al.  Algebra of Programming by Richard Bird and Oege de Moor, Prentice Hall, 1996 (dated 1997). , 1999 .

[123]  Jeremy Gibbons,et al.  The under-appreciated unfold , 1998, ICFP '98.

[124]  Ira R. Forman,et al.  Putting metaclasses to work: a new dimension in object-oriented programming , 1999 .

[125]  Maarten M. Fokkinga Monadic Maps and Folds for Arbitrary Datatypes , 1994 .

[126]  Richard S. Bird,et al.  Algebra of programming , 1997, Prentice Hall International series in computer science.

[127]  Maarten M. Fokkinga Tupling and Mutumorphisms , 1989 .

[128]  David Nowak,et al.  On a Semantic Definition of Data Independence , 2003, TLCA.

[129]  Roland Carl Backhouse,et al.  When Do Datatypes Commute? , 1997, Category Theory and Computer Science.

[130]  David B. Skillicorn,et al.  The Bird-Meertens Formalism as a Parallel Model , 1993 .

[131]  Sergei Gorlatch,et al.  Parallelization of divide-and-conquer in the Bird-Meertens formalism , 1995, Formal Aspects of Computing.

[132]  Joyce L. Vedral,et al.  Functional Programming Languages and Computer Architecture , 1989, Lecture Notes in Computer Science.

[133]  Hayo Thielecke,et al.  A Type-theoretic Reconstruction of the Visitor Pattern , 2006, MFPS.

[134]  Andrew Kennedy,et al.  Design and implementation of generics for the .NET Common language runtime , 2001, PLDI '01.

[135]  Ralf Hinze Generics for the masses , 2006, J. Funct. Program..

[136]  Stephen J. Garland,et al.  Larch: Languages and Tools for Formal Specification , 1993, Texts and Monographs in Computer Science.

[137]  Roland Carl Backhouse,et al.  Generic Programming: An Introduction , 1998, Advanced Functional Programming.

[138]  Philip Wadler,et al.  Monads for functional programming , 1995, NATO ASI PDC.

[139]  Uday S. Reddy,et al.  Imperative functional programming , 1996, CSUR.

[140]  Ralf Hinze,et al.  Generic Programming, Now! , 2006, SSDGP.

[141]  Philip Wadler,et al.  Deforestation: Transforming Programs to Eliminate Trees , 1990, Theor. Comput. Sci..

[142]  Andres Löh,et al.  Exploring generic Haskell , 2004 .

[143]  Jeremy Gibbons,et al.  Metamorphisms: Streaming representation-changers , 2007, Sci. Comput. Program..