Parametricity for Nested Types and GADTs
Patricia Johann, Enrico Ghiorzi

TL;DR
This paper develops a parametricity framework for nested data types and GADTs within a Hindley-Milner-style calculus, enabling derivation of free theorems and handling truly nested types directly.
Contribution
It introduces a novel calculus for nested types with a parametric model that supports primitive pattern matching, map, and fold, and extends parametricity to GADTs with limitations.
Findings
Constructed a parametric model for nested types
Derived free theorems and a shortcut fusion transformation
Identified limitations in interpreting GADTs functorially
Abstract
This paper considers parametricity and its consequent free theorems for nested data types. Rather than representing nested types via their Church encodings in a higher-kinded or dependently typed extension of System F, we adopt a functional programming perspective and design a Hindley-Milner-style calculus with primitives for constructing nested types directly as fixpoints. Our calculus can express all nested types appearing in the literature, including truly nested types. At the level of terms, it supports primitive pattern matching, map functions, and fold combinators for nested types. Our main contribution is the construction of a parametric model for our calculus. This is both delicate and challenging. In particular, to ensure the existence of semantic fixpoints interpreting nested types, and thus to establish a suitable Identity Extension Lemma for our calculus, our type system…
Peer Reviews
No public reviews on file for this paper yet. If you reviewed it on a platform where reviews are public (OpenReview, ICLR, NeurIPS, ICML), you can paste yours below so the community can read it here.
Videos
No videos yet. Explain this paper in a talk, walkthrough, or lecture? Add one.
