{"title":"嵌套类型和gadt的参数化","authors":"Patricia Johann, Enrico Ghiorzi, D. Jeffries","doi":"10.46298/lmcs-17(4:23)2021","DOIUrl":null,"url":null,"abstract":"This paper considers parametricity and its consequent free theorems for\nnested data types. Rather than representing nested types via their Church\nencodings in a higher-kinded or dependently typed extension of System F, we\nadopt a functional programming perspective and design a Hindley-Milner-style\ncalculus with primitives for constructing nested types directly as fixpoints.\nOur calculus can express all nested types appearing in the literature,\nincluding truly nested types. At the level of terms, it supports primitive\npattern matching, map functions, and fold combinators for nested types. Our\nmain contribution is the construction of a parametric model for our calculus.\nThis is both delicate and challenging. In particular, to ensure the existence\nof semantic fixpoints interpreting nested types, and thus to establish a\nsuitable Identity Extension Lemma for our calculus, our type system must\nexplicitly track functoriality of types, and cocontinuity conditions on the\nfunctors interpreting them must be appropriately threaded throughout the model\nconstruction. We also prove that our model satisfies an appropriate Abstraction\nTheorem, as well as that it verifies all standard consequences of parametricity\nin the presence of primitive nested types. We give several concrete examples\nillustrating how our model can be used to derive useful free theorems,\nincluding a short cut fusion transformation, for programs over nested types.\nFinally, we consider generalizing our results to GADTs, and argue that no\nextension of our parametric model for nested types can give a functorial\ninterpretation of GADTs in terms of left Kan extensions and still be\nparametric.","PeriodicalId":314387,"journal":{"name":"Log. Methods Comput. Sci.","volume":"24 1","pages":"0"},"PeriodicalIF":0.0000,"publicationDate":"2021-01-13","publicationTypes":"Journal Article","fieldsOfStudy":null,"isOpenAccess":false,"openAccessPdf":"","citationCount":"2","resultStr":"{\"title\":\"Parametricity for Nested Types and GADTs\",\"authors\":\"Patricia Johann, Enrico Ghiorzi, D. Jeffries\",\"doi\":\"10.46298/lmcs-17(4:23)2021\",\"DOIUrl\":null,\"url\":null,\"abstract\":\"This paper considers parametricity and its consequent free theorems for\\nnested data types. Rather than representing nested types via their Church\\nencodings in a higher-kinded or dependently typed extension of System F, we\\nadopt a functional programming perspective and design a Hindley-Milner-style\\ncalculus with primitives for constructing nested types directly as fixpoints.\\nOur calculus can express all nested types appearing in the literature,\\nincluding truly nested types. At the level of terms, it supports primitive\\npattern matching, map functions, and fold combinators for nested types. Our\\nmain contribution is the construction of a parametric model for our calculus.\\nThis is both delicate and challenging. In particular, to ensure the existence\\nof semantic fixpoints interpreting nested types, and thus to establish a\\nsuitable Identity Extension Lemma for our calculus, our type system must\\nexplicitly track functoriality of types, and cocontinuity conditions on the\\nfunctors interpreting them must be appropriately threaded throughout the model\\nconstruction. We also prove that our model satisfies an appropriate Abstraction\\nTheorem, as well as that it verifies all standard consequences of parametricity\\nin the presence of primitive nested types. We give several concrete examples\\nillustrating how our model can be used to derive useful free theorems,\\nincluding a short cut fusion transformation, for programs over nested types.\\nFinally, we consider generalizing our results to GADTs, and argue that no\\nextension of our parametric model for nested types can give a functorial\\ninterpretation of GADTs in terms of left Kan extensions and still be\\nparametric.\",\"PeriodicalId\":314387,\"journal\":{\"name\":\"Log. Methods Comput. Sci.\",\"volume\":\"24 1\",\"pages\":\"0\"},\"PeriodicalIF\":0.0000,\"publicationDate\":\"2021-01-13\",\"publicationTypes\":\"Journal Article\",\"fieldsOfStudy\":null,\"isOpenAccess\":false,\"openAccessPdf\":\"\",\"citationCount\":\"2\",\"resultStr\":null,\"platform\":\"Semanticscholar\",\"paperid\":null,\"PeriodicalName\":\"Log. Methods Comput. Sci.\",\"FirstCategoryId\":\"1085\",\"ListUrlMain\":\"https://doi.org/10.46298/lmcs-17(4:23)2021\",\"RegionNum\":0,\"RegionCategory\":null,\"ArticlePicture\":[],\"TitleCN\":null,\"AbstractTextCN\":null,\"PMCID\":null,\"EPubDate\":\"\",\"PubModel\":\"\",\"JCR\":\"\",\"JCRName\":\"\",\"Score\":null,\"Total\":0}","platform":"Semanticscholar","paperid":null,"PeriodicalName":"Log. Methods Comput. Sci.","FirstCategoryId":"1085","ListUrlMain":"https://doi.org/10.46298/lmcs-17(4:23)2021","RegionNum":0,"RegionCategory":null,"ArticlePicture":[],"TitleCN":null,"AbstractTextCN":null,"PMCID":null,"EPubDate":"","PubModel":"","JCR":"","JCRName":"","Score":null,"Total":0}
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.