Abstract
Abstract
Generalized Algebraic Data Types (GADTs) are a syntactic generalization of the usual algebraic data types (ADTs), such as lists, trees, etc. ADTs’ standard initial algebra semantics (IAS) in the category
$\mathit{Set}$
of sets justify critical syntactic constructs – such as recursion, pattern matching, and fold – for programming with them. In this paper, we show that semantics for GADTs that specialize to the IAS for ADTs are necessarily unsatisfactory. First, we show that the functorial nature of such semantics for GADTs in
$\mathit{Set}$
introduces ghost elements, i.e., elements not writable in syntax. Next, we show how such ghost elements break parametricity. We observe that the situation for GADTs contrasts dramatically with that for ADTs, whose IAS coincides with the parametric model constructed via their Church encodings in System F. Our analysis reveals that the fundamental obstacle to giving a functorial IAS for GADTs is the inherently partial nature of their map functions. We show that this obstacle cannot be overcome by replacing
$\mathit{Set}$
with other categories that account for this partiality.
Publisher
Cambridge University Press (CUP)
Reference49 articles.
1. Partiality, cartesian closedness, and toposes
2. Vytiniotis, D. and Weirich, S. (2006). Parametricity and GADTs. Available at https://www.cis.upenn.edu/~sweirich/talks/param-gadt.pdf.
3. Johann, P. , Ghiorzi, E. and Jeffries, D. (2021). Parametricity for primitive nested types. In: Foundations of Software Science and Computation Structures: 24th International Conference, FOSSACS 2021, Springer-Verlag. 324–343.
4. Computing left Kan extensions
5. The Church-Scott representation of inductive and coinductive data;Geuvers;Unpublished,2014