121 research outputs found
Relational parametricity for higher kinds
Reynolds’ notion of relational parametricity has been extremely influential and well studied for polymorphic programming languages and type theories based on System F. The extension of relational parametricity to higher kinded polymorphism, which allows quantification over type operators as well as types, has not received as much attention. We present a model of relational parametricity for System Fω, within the impredicative Calculus of Inductive Constructions, and show how it forms an instance of a general class of models defined by Hasegawa. We investigate some of the consequences of our model and show that it supports the definition of inductive types, indexed by an arbitrary kind, and with reasoning principles provided by initiality
First-Class Subtypes
First class type equalities, in the form of generalized algebraic data types
(GADTs), are commonly found in functional programs. However, first-class
representations of other relations between types, such as subtyping, are not
yet directly supported in most functional programming languages.
We present several encodings of first-class subtypes using existing features
of the OCaml language (made more convenient by the proposed modular implicits
extension), show that any such encodings are interconvertible, and illustrate
the utility of the encodings with several examples.Comment: In Proceedings ML 2017, arXiv:1905.0590
Modular implicits
We present modular implicits, an extension to the OCaml language for ad-hoc
polymorphism inspired by Scala implicits and modular type classes. Modular
implicits are based on type-directed implicit module parameters, and elaborate
straightforwardly into OCaml's first-class functors. Basing the design on
OCaml's modules leads to a system that naturally supports many features from
other languages with systematic ad-hoc overloading, including inheritance,
instance constraints, constructor classes and associated types
Fighting bit Rot with Types (Experience Report: Scala Collections)
We report on our experiences in redesigning Scala\u27s collection
libraries, focussing on the role that type systems play in keeping
software architectures coherent over time. Type systems can make
software architecture more explicit but, if they are too weak, can
also cause code duplication. We show that code duplication can be
avoided using two of Scala\u27s type constructions: higher-kinded types
and implicit parameters and conversions
A Relationally Parametric Model of Dependent Type Theory
Reynolds’ theory of relational parametricity captures the invariance of polymorphically typed programs under change of data representation. Reynolds’ original work exploited the typing discipline of the polymorphically typed -calculus System F, but there is now considerable interest in extending relational parametricity to type systems that are richer and more expressive than that of System F.This paper constructs parametric models of predicative and impredicative dependent type theory. The significance of our models is twofold. Firstly, in the impredicative variant we are able to deduce the existence of initial algebras for all indexed functors. To our knowledge, ours is the first account of parametricity for dependent types that is able to lift the useful deduction of the existence of initial algebras in parametric models of System F to the dependently typed setting. Secondly, our models offer conceptual clarity by uniformly expressing relational parametricity for dependent types in terms of reflexive graphs, which allows us to unify the interpretations of types and kinds, instead of taking the relational interpretation of types as a primitive notion. Expressing our model in terms of reflexive graphs ensures that it has canonical choices for the interpretations of the standard type constructors of dependent type theory, except for the interpretation of the universe of small types, where we formulate a refined interpretation tailored for relational parametricity. Moreover, our reflexive graph model opens the door to generalizations of relational parametricity, for example to higher-dimensional relational parametricity
Machine-Checked Semantic Session Typing
Session types- A family of type systems for message-passing concurrency-have been subject to many extensions, where each extension comes with a separate proof of type safety. These extensions cannot be readily combined, and their proofs of type safety are generally not machine checked, making their correctness less trustworthy. We overcome these shortcomings with a semantic approach to binary asynchronous affine session types, by developing a logical relations model in Coq using the Iris program logic. We demonstrate the power of our approach by combining various forms of polymorphism and recursion, asynchronous subtyping, references, and locks/mutexes. As an additional benefit of the semantic approach, we demonstrate how to manually prove typing judgements of racy, but safe, programs that cannot be type checked using only the rules of the type system. Programming Language
Strategic polymorphism requires just two combinators!
In previous work, we introduced the notion of functional strategies:
first-class generic functions that can traverse terms of any type while mixing
uniform and type-specific behaviour. Functional strategies transpose the notion
of term rewriting strategies (with coverage of traversal) to the functional
programming paradigm. Meanwhile, a number of Haskell-based models and
combinator suites were proposed to support generic programming with functional
strategies.
In the present paper, we provide a compact and matured reconstruction of
functional strategies. We capture strategic polymorphism by just two primitive
combinators. This is done without commitment to a specific functional language.
We analyse the design space for implementational models of functional
strategies. For completeness, we also provide an operational reference model
for implementing functional strategies (in Haskell). We demonstrate the
generality of our approach by reconstructing representative fragments of the
Strafunski library for functional strategies.Comment: A preliminary version of this paper was presented at IFL 2002, and
included in the informal preproceedings of the worksho
Polymorphic Typestate for Session Types
Session types provide a principled approach to typed communication protocols
that guarantee type safety and protocol fidelity. Formalizations of
session-typed communication are typically based on process calculi, concurrent
lambda calculi, or linear logic. An alternative model based on
context-sensitive typing and typestate has not received much attention due to
its apparent restrictions. However, this model is attractive because it does
not force programmers into particular patterns like continuation-passing style
or channel-passing style, but rather enables them to treat communication
channels like mutable variables. Polymorphic typestate is the key that enables
a full treatment of session-typed communication. Previous work in this
direction was hampered by its setting in a simply-typed lambda calculus. We
show that higher-order polymorphism and existential types enable us to lift the
restrictions imposed by the previous work, thus bringing the expressivity of
the typestate-based approach on par with the competition. On this basis, we
define PolyVGR, the system of polymorphic typestate for session types,
establish its basic metatheory, type preservation and progress, and present a
prototype implementation.Comment: 29 pages. Short version appears in PPDP 202
- …