GADTs are not (Even partial) functors

Author:

Cagne PierreORCID,Ghiorzi EnricoORCID,Johann PatriciaORCID

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

同舟云学术

1.学者识别学者识别

2.学术分析学术分析

3.人才评估人才评估

"同舟云学术"是以全球学者为主线,采集、加工和组织学术论文而形成的新型学术文献查询和分析系统,可以对全球学者进行文献检索和人才价值评估。用户可以通过关注某些学科领域的顶尖人物而持续追踪该领域的学科进展和研究前沿。经过近期的数据扩容,当前同舟云学术共收录了国内外主流学术期刊6万余种,收集的期刊论文及会议论文总量共计约1.5亿篇,并以每天添加12000余篇中外论文的速度递增。我们也可以为用户提供个性化、定制化的学者数据。欢迎来电咨询!咨询电话:010-8811{复制后删除}0370

www.globalauthorid.com

TOP

Copyright © 2019-2024 北京同舟云网络信息技术有限公司
京公网安备11010802033243号  京ICP备18003416号-3