How Functorial Are (Deep) GADTs?
Patricia Johann, Pierre Cagne

TL;DR
This paper introduces an algorithm to determine which functions can be mapped over deep GADTs by analyzing their structure, enabling better understanding and manipulation of complex data types in functional programming.
Contribution
It develops a novel algorithm that detects mappable functions over deep GADTs by separating essential and incidental structures, advancing the semantics of GADTs.
Findings
Algorithm accurately identifies mappable functions over deep GADTs.
Separates essential structure from incidental data in GADT elements.
Supports the development of initial algebra semantics for GADTs.
Abstract
It is well-known that GADTs do not admit standard map functions of the kind supported by ADTs and nested types. In addition, standard map functions are insufficient to distribute their data-changing argument functions over all of the structure present in elements of deep GADTs, even just deep ADTs or nested types. This paper develops an algorithm for detecting exactly which functions are mappable over data whose types are (deep) GADTs. The algorithm takes as input a term t whose type is an instance of a deep GADT D and a function f to be mapped over t. It detects a minimal possible shape of t as an element of D, and returns a minimal set of constraints f must satisfy to be mappable over t. The crux of the algorithm is its ability to separate t's essential structure as an element of D -- i.e., the part of t that is essential for it to have the shape of an element of D -- from its…
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.
Taxonomy
TopicsLogic, programming, and type systems
