A foundation for GADTs and inductive families: dependent polynomial functor approach

Every Algebraic Datatype (ADT) is characterised as the initial algebra of a polynomial functor on sets. This paper extends the characterisation to the case of more advanced datatypes: Generalised Algebraic Datatypes (GADTs) and Inductive Families. Specifically, we show that GADTs and Inductive Families are characterised as initial algebras of dependent polynomial functors. The theoretical tool we use throughout is an abstract notion of polynomial between sets together with its associated general form of polynomial functor between categories of indexed sets introduced by Gambino and Hyland. In the context of ADTs, this fundamental result is the basis for various generic functional programming techniques. To establish the usefulness of our approach for such developments in the broader context of inductively defined dependent types, we apply the theory to construct zippers for Inductive Families.

[1]  S. Lane Categories for the Working Mathematician , 1971 .

[2]  R. Hinze Adjoint folds and unfolds: or: scything through the thicket of morphisms , 2010, MPC'10 2010.

[3]  Peter Morris,et al.  The gentle art of levitation , 2010, ICFP '10.

[4]  米田 信夫,et al.  On ext and exact sequences , 1961 .

[5]  Thorsten Altenkirch,et al.  Representing Nested Inductive Types Using W-Types , 2004, ICALP.

[6]  Marcelo P. Fiore,et al.  Mathematical Models of Computational and Combinatorial Structures , 2005, FoSSaCS.

[7]  Richard S. Bird,et al.  Generalised folds for nested datatypes , 1999, Formal Aspects of Computing.

[8]  U. Norell,et al.  Towards a practical programming language based on dependent type theory , 2007 .

[9]  Akihiko Takano,et al.  Shortcut deforestation in calculational form , 1995, FPCA '95.

[10]  Gérard P. Huet,et al.  The Zipper , 1997, Journal of Functional Programming.

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

[12]  Ulf Norell,et al.  Dependently typed programming in Agda , 2009, TLDI '09.

[13]  Bart Jacobs,et al.  Categorical Logic and Type Theory , 2001, Studies in logic and the foundations of mathematics.

[14]  Richard S. Bird,et al.  de Bruijn notation as a nested datatype , 1999, Journal of Functional Programming.

[15]  Wouter Swierstra,et al.  The power of Pi , 2008, ICFP.

[16]  Thorsten Altenkirch,et al.  for Data: Differentiating Data Structures , 2005, Fundam. Informaticae.

[17]  Conor McBride,et al.  Epigram: Practical Programming with Dependent Types , 2004, Advanced Functional Programming.

[18]  Peter Dybjer,et al.  Dependent Types at Work , 2009, LerNet ALFA Summer School.

[19]  Akimasa Morihata,et al.  The third homomorphism theorem on trees: downward & upward lead to divide-and-conquer , 2009, POPL '09.

[20]  Tatsuya Hagino,et al.  A Typed Lambda Calculus with Categorical Type Constructors , 1987, Category Theory and Computer Science.

[21]  Michael D. Adams Scrap your zippers: a generic zipper for heterogeneous types , 2010, WGP '10.

[22]  Gordon D. Plotkin,et al.  Abstract syntax and variable binding , 1999, Proceedings. 14th Symposium on Logic in Computer Science (Cat. No. PR00158).

[23]  N. Gambino,et al.  Polynomial functors and polynomial monads , 2009, Mathematical Proceedings of the Cambridge Philosophical Society.

[24]  Masato Takeichi,et al.  Deriving structural hylomorphisms from recursive definitions , 1996, ICFP '96.

[25]  Johan Jeuring,et al.  Polyp - A Polytypic Programming Language. , 1997 .

[26]  Tim Sheard,et al.  A fold for all seasons , 1993, FPCA '93.

[27]  John Launchbury,et al.  Warm fusion: deriving build-catas from recursive definitions , 1995, FPCA '95.

[28]  Simon L. Peyton Jones,et al.  Complete and decidable type inference for GADTs , 2009, ICFP.

[29]  Peter Dybjer,et al.  Universes for Generic Programs and Proofs in Dependent Type Theory , 2003, Nord. J. Comput..

[30]  Tarmo Uustalu,et al.  Monadic augment and generalised short cut fusion , 2005, ICFP '05.

[31]  Ralf Hinze,et al.  Fun with phantom types , 2003 .

[32]  I. Moerdijk,et al.  Sheaves in geometry and logic: a first introduction to topos theory , 1992 .

[33]  Peter Morris,et al.  Indexed Containers , 2009, 2009 24th Annual IEEE Symposium on Logic In Computer Science.

[34]  Ralph Matthes,et al.  Iteration and coiteration schemes for higher-order and nested datatypes , 2005, Theor. Comput. Sci..

[35]  Peter Dybjer,et al.  Induction-recursion and initial algebras , 2003, Ann. Pure Appl. Log..

[36]  Patricia Johann,et al.  Monadic augment and generalised short cut fusion , 2007, J. Funct. Program..

[37]  Conor McBride The Derivative of a Regular Type is its Type of One-Hole Contexts , 2001 .

[38]  F. William Lawvere,et al.  Adjointness in Foundations , 1969 .

[39]  Jiří Adámek,et al.  Free algebras and automata realizations in the language of categories , 1974 .

[40]  Shin-ya Katsumata,et al.  Algebraic fusion of functions with an accumulating parameter and its improvement , 2006, ICFP '06.

[41]  Gordon D. Plotkin,et al.  The category-theoretic solution of recursive domain equations , 1977, 18th Annual Symposium on Foundations of Computer Science (sfcs 1977).

[42]  Martin Hyland,et al.  Wellfounded Trees and Dependent Polynomial Functors , 2003, TYPES.

[43]  Thorsten Altenkirch,et al.  Generic Programming within Dependently Typed Programming , 2002, Generic Programming.

[44]  Peter Dybjer,et al.  Inductive families , 2005, Formal Aspects of Computing.

[45]  Patricia Johann,et al.  Foundations for structured programming with GADTs , 2008, POPL '08.

[46]  Peter Dybjer,et al.  Indexed induction-recursion , 2001, J. Log. Algebraic Methods Program..

[47]  Ralf Hinze Adjoint Folds and Unfolds , 2010, MPC.

[48]  Nils Anders Danielsson,et al.  Fast and loose reasoning is morally correct , 2006, POPL '06.

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

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