首页    期刊浏览 2024年09月12日 星期四
登录注册

文章基本信息

  • 标题:PARAMETRICITY FOR NESTED TYPES AND GADTS
  • 本地全文:下载
  • 作者:Patricia Johann ; Enrico Ghiorzi
  • 期刊名称:Logical Methods in Computer Science
  • 印刷版ISSN:1860-5974
  • 电子版ISSN:1860-5974
  • 出版年度:2021
  • 卷号:17
  • 期号:4
  • 页码:1-50
  • DOI:10.46298/lmcs-17(4:23)2021
  • 语种:English
  • 出版社:Technical University of Braunschweig
  • 摘要: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 must explicitly track functoriality of types, and cocontinuity conditions on the functors interpreting them must be appropriately threaded throughout the model construction. We also prove that our model satisfies an appropriate Abstraction Theorem, as well as that it verifies all standard consequences of parametricity in the presence of primitive nested types. We give several concrete examples illustrating how our model can be used to derive useful free theorems, including a short cut fusion transformation, for programs over nested types. Finally, we consider generalizing our results to GADTs, and argue that no extension of our parametric model for nested types can give a functorial interpretation of GADTs in terms of left Kan extensions and still be parametric.
  • 关键词:Nested types;GADTs;categorical semantics;parametricity
国家哲学社会科学文献中心版权所有