858 research outputs found
Foundations for structured programming with GADTs
GADTs are at the cutting edge of functional programming and become more widely used every day. Nevertheless, the semantic foundations underlying GADTs are not well understood. In this paper we solve this problem by showing that the standard theory of data types as carriers of initial algebras of functors can be extended from algebraic and nested data types to GADTs. We then use this observation to derive an initial algebra semantics for GADTs, thus ensuring that all of the accumulated knowledge about initial algebras can be brought to bear on them. Next, we use our initial algebra semantics for GADTs to derive expressive and principled tools â analogous to the well-known and widely-used ones for algebraic and nested data types â for reasoning about, programming with, and improving the performance of programs involving, GADTs; we christen such a collection of tools for a GADT an initial algebra package. Along the way, we give a constructive demonstration that every GADT can be reduced to one which uses only the equality GADT and existential quantification. Although other such reductions exist in the literature, ours is entirely local, is independent of any particular syntactic presentation of GADTs, and can be implemented in the host language, rather than existing solely as a metatheoretical artifact. The main technical ideas underlying our approach are (i) to modify the notion of a higher-order functor so that GADTs can be seen as carriers of initial algebras of higher-order functors, and (ii) to use left Kan extensions to trade arbitrary GADTs for simpler-but-equivalent ones for which initial algebra semantics can be derive
A generic operational metatheory for algebraic effects
We provide a syntactic analysis of contextual preorder and equivalence for a polymorphic programming language with effects. Our approach applies uniformly across a range of algebraic effects, and incorporates, as instances: errors, input/output, global state, nondeterminism, probabilistic choice, and combinations thereof. Our approach is to extend Plotkin and Powerâs structural operational semantics for algebraic effects (FoSSaCS 2001) with a primitive âbasic preorderâ on ground type computation trees. The basic preorder is used to derive notions of contextual preorder and equivalence on program terms. Under mild assumptions on this relation, we prove fundamental properties of contextual preorder (hence equivalence) including extensionality properties and a characterisation via applicative contexts, and we provide machinery for reasoning about polymorphism using relational parametricity
Indexed Induction and Coinduction, Fibrationally
This paper extends the fibrational approach to induction and coinduction
pioneered by Hermida and Jacobs, and developed by the current authors, in two
key directions. First, we present a dual to the sound induction rule for
inductive types that we developed previously. That is, we present a sound
coinduction rule for any data type arising as the carrier of the final
coalgebra of a functor, thus relaxing Hermida and Jacobs' restriction to
polynomial functors. To achieve this we introduce the notion of a quotient
category with equality (QCE) that i) abstracts the standard notion of a
fibration of relations constructed from a given fibration; and ii) plays a role
in the theory of coinduction dual to that played by a comprehension category
with unit (CCU) in the theory of induction. Secondly, we show that inductive
and coinductive indexed types also admit sound induction and coinduction rules.
Indexed data types often arise as carriers of initial algebras and final
coalgebras of functors on slice categories, so we give sufficient conditions
under which we can construct, from a CCU (QCE) U:E \rightarrow B, a fibration
with base B/I that models indexing by I and is also a CCU (resp., QCE). We
finish the paper by considering the more general case of sound induction and
coinduction rules for indexed data types when the indexing is itself given by a
fibration
Interleaving data and effects
The study of programming with and reasoning about inductive datatypes such as lists and trees has benefited from the simple categorical principle of initial algebras. In initial algebra semantics, each inductive datatype is represented by an initial f-algebra for an appropriate functor f. The initial algebra principle then supports the straightforward derivation of definitional principles and proof principles for these datatypes. This technique has been expanded to a whole methodology of structured functional programming, often called origami programming. In this article we show how to extend initial algebra semantics from pure inductive datatypes to inductive datatypes interleaved with computational effects. Inductive datatypes interleaved with effects arise naturally in many computational settings. For example, incrementally reading characters from a file generates a list of characters interleaved with input/output actions, and lazily constructed infinite values can be represented by pure data interleaved with the possibility of non-terminating computation. Straightforward application of initial algebra techniques to effectful datatypes leads either to unsound conclusions if we ignore the possibility of effects, or to unnecessarily complicated reasoning because the pure and effectful concerns must be considered simultaneously. We show how pure and effectful concerns can be separated using the abstraction of initial f-and-m-algebras, where the functor f describes the pure part of a datatype and the monad m describes the interleaved effects. Because initial f-and-m-algebras are the analogue for the effectful setting of initial f-algebras, they support the extension of the standard definitional and proof principles to the effectful setting. Initial f-and-m-algebras are originally due to Filinski and StĂžvring, who studied them in the category Cpo. They were subsequently generalised to arbitrary categories by Atkey, Ghani, Jacobs, and Johann in a FoSSaCS 2012 paper. In this article we aim to introduce the general concept of initial f-and-m-algebras to a general functional programming audience
Parametricity for Nested Types and GADTs
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
Interdependent Formation of Symbolic and Regulatory Boundaries: The Discursive Contestation Around the Home-Sharing Category
The formation of boundaries between established and emergent categories is a complex social process. Therein, our understanding of how symbolic boundaries translate into regulatory boundaries is underdeveloped. Extant research either treats laws and regulations for categories as given or assumes a seamless translation of a symbolic into a regulatory boundary. This sidelines that market participants actively contest and shape boundaries between categories. To address this lacuna, we open the black box of how symbolic boundaries are translated into regulatory boundaries. We adopt a discursive perspective and conduct a longitudinal study of the contestation around the categories of home sharing and short-term rental in Europe. Our analysis shows how symbolic and regulatory boundaries are formed in a causal sequential process, driven by shifts in the field positioning of market actors and in the discursive accounts they mobilize. We develop a theoretical model of the discursive foundation of category boundary formation. At the heart of our theorization are discursive accounts and how shifting coalitions of market participants mobilize them to shape the evolving symbolic and regulatory boundaries between an emergent and an established category. We contribute to category research by unearthing the interdependent formation of symbolic and regulatory boundaries and the role of discursive accounts in these processes
Interdependent Formation of Symbolic and Regulatory Boundaries: The Discursive Contestation Around the Home-Sharing Category
The formation of boundaries between established and emergent categories is a complex social process. Therein, our understanding of how symbolic boundaries translate into regulatory boundaries is underdeveloped. Extant research either treats laws and regulations for categories as given, or it assumes a seamless translation of a symbolic into a regulatory boundary. This sidelines that market participants actively contest and shape boundaries between categories. To address this lacuna, we open the black box of how symbolic boundaries are translated into regulatory boundaries. We adopt a discursive perspective and conduct a longitudinal study of the contestation around the categories of home sharing and short-term rental in Europe. Our analysis shows how symbolic and regulatory boundaries are formed in a causal sequential process, driven by shifts in the field positioning of market actors and in the discursive accounts they mobilize. We develop a theoretical model of the discursive foundation of category boundary formation. At the heart of our theorization are discursive accounts and how shifting coalitions of market participants mobilize them to shape the evolving symbolic and regulatory boundaries between an emergent and an established category. We contribute to category research by unearthing the interdependent formation of symbolic and regulatory boundaries and the role of discursive accounts in these processes
Monadic fold, Monadic build, Monadic Short Cut Fusion
Abstract: Short cut fusion improves the efficiency of modularly constructed programs by eliminating intermediate data structures produced by one program component and immediately consumed by another. We define a combinator which expresses uniform production of data structures in monadic contexts, and is the natural counterpart to the well-known monadic fold which consumes them. Like the monadic fold, our new combinator quantifies over monadic algebras rather than standard ones. Together with the monadic fold, it gives rise to a new short cut fusion rule for eliminating intermediate data structures in monadic contexts. This new rule differs significantly from previous short cut fusion rules, all of which are based on combinators which quantify over standard, rather than monadic, algebras. We give examples illustrating the benefits of quantifying over monadic algebras, prove our new fusion rule correct, and show how it can improve programs. We also consider its coalgebraic dual
Bifibrational Functorial Semantics For Parametric Polymorphism
Reynoldsâ theory of parametric polymorphism captures the invariance of polymorphically typed programs under change of data representation. Semantically, reflexive graph categories and fibrations are both known to give a categorical understanding of parametric polymorphism. This paper contributes further to this categorical perspective by showing the relevance of bifibrations. We develop a bifibrational framework for models of System F that are parametric, in that they verify the Identity Extension Lemma and Reynoldsâ Abstraction Theorem. We also prove that our models satisfy expected properties, such as the existence of initial algebras and final coalgebras, and that parametricity implies dinaturality
- âŠ