4 research outputs found

    Parametricity for Nested Types and GADTs

    Full text link
    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

    Internal enriched categories

    Get PDF
    This dissertation introduces and develops the theory of internal enriched categories, arising from the internalization of the theory of enriched categories. Given an internal monoidal category V in an ambient category E, we define the notions of V-enriched category, functor and natural transformation. We then develop such theory, which presents many of the good properties of standard enriched category theory. Notably, under suitable conditions, the category of internal V-enriched categories and their functors is monoidal closed. Internal enriched categories admit a notion of internal weighted limit, analo- gously to how internal categories admit internal limits. Such theory of limits constitutes a major focus point in the dissertation and yields fundamental results such as the adjoint functor theorem. It is observed that internal categories are intrinsically small and some of them are non-trivial examples of small complete categories, whereas the only standard small complete categories are complete lattices. As a consequence, the internal theory is better behaved than that of standard categories, particularly in relation with size issues, while still featuring interesting examples. Moreover, to frame it into a wider context, the notion of internal enriched category is compared with related notions from the literature, such as those of indexed enriched category and enriched generalized multicategory. It turns out that internal enriched categories are indeed strongly connected with such other notions, thus providing a novel approach to–and, possibly, insight into–other topics in category theory.EPSRC - covering university and college fees Cambridge Trust - covering living expense
    corecore