725 research outputs found
Effect systems revisited—control-flow algebra and semantics
Effect systems were originally conceived as an inference-based program analysis to capture program behaviour—as a set of (representations of) effects. Two orthogonal developments have since happened. First, motivated by static analysis, effects were generalised to values in an algebra, to better model control flow (e.g. for may/must analyses and concurrency). Second, motivated by semantic questions, the syntactic notion of set- (or semilattice-) based effect system was linked to the semantic notion of monads and more recently to graded monads which give a more precise semantic account of effects.
We give a lightweight tutorial explanation of the concepts involved in these two threads and then unify them via the notion of an effect-directed semantics for a control-flow algebra of effects. For the case of effectful programming with sequencing, alternation and parallelism—illustrated with music—we identify a form of graded joinads as the appropriate structure for unifying effect analysis and semantics
Relational Parametricity for Computational Effects
According to Strachey, a polymorphic program is parametric if it applies a
uniform algorithm independently of the type instantiations at which it is
applied. The notion of relational parametricity, introduced by Reynolds, is one
possible mathematical formulation of this idea. Relational parametricity
provides a powerful tool for establishing data abstraction properties, proving
equivalences of datatypes, and establishing equalities of programs. Such
properties have been well studied in a pure functional setting. Many programs,
however, exhibit computational effects, and are not accounted for by the
standard theory of relational parametricity. In this paper, we develop a
foundational framework for extending the notion of relational parametricity to
programming languages with effects.Comment: 31 pages, appears in Logical Methods in Computer Scienc
Polymonadic Programming
Monads are a popular tool for the working functional programmer to structure
effectful computations. This paper presents polymonads, a generalization of
monads. Polymonads give the familiar monadic bind the more general type forall
a,b. L a -> (a -> M b) -> N b, to compose computations with three different
kinds of effects, rather than just one. Polymonads subsume monads and
parameterized monads, and can express other constructions, including precise
type-and-effect systems and information flow tracking; more generally,
polymonads correspond to Tate's productoid semantic model. We show how to equip
a core language (called lambda-PM) with syntactic support for programming with
polymonads. Type inference and elaboration in lambda-PM allows programmers to
write polymonadic code directly in an ML-like syntax--our algorithms compute
principal types and produce elaborated programs wherein the binds appear
explicitly. Furthermore, we prove that the elaboration is coherent: no matter
which (type-correct) binds are chosen, the elaborated program's semantics will
be the same. Pleasingly, the inferred types are easy to read: the polymonad
laws justify (sometimes dramatic) simplifications, but with no effect on a
type's generality.Comment: In Proceedings MSFP 2014, arXiv:1406.153
Coalgebraic Weak Bisimulation from Recursive Equations over Monads
Strong bisimulation for labelled transition systems is one of the most
fundamental equivalences in process algebra, and has been generalised to
numerous classes of systems that exhibit richer transition behaviour. Nearly
all of the ensuing notions are instances of the more general notion of
coalgebraic bisimulation. Weak bisimulation, however, has so far been much less
amenable to a coalgebraic treatment. Here we attempt to close this gap by
giving a coalgebraic treatment of (parametrized) weak equivalences, including
weak bisimulation. Our analysis requires that the functor defining the
transition type of the system is based on a suitable order-enriched monad,
which allows us to capture weak equivalences by least fixpoints of recursive
equations. Our notion is in agreement with existing notions of weak
bisimulations for labelled transition systems, probabilistic and weighted
systems, and simple Segala systems.Comment: final versio
Tracing monadic computations and representing effects
In functional programming, monads are supposed to encapsulate computations,
effectfully producing the final result, but keeping to themselves the means of
acquiring it. For various reasons, we sometimes want to reveal the internals of
a computation. To make that possible, in this paper we introduce monad
transformers that add the ability to automatically accumulate observations
about the course of execution as an effect. We discover that if we treat the
resulting trace as the actual result of the computation, we can find new
functionality in existing monads, notably when working with non-terminating
computations.Comment: In Proceedings MSFP 2012, arXiv:1202.240
A Direct-Style Effect Notation for Sequential and Parallel Programs
Modeling sequential and parallel composition of effectful computations has been investigated in a variety of languages for a long time. In particular, the popular do-notation provides a lightweight effect embedding for any instance of a monad. Idiom bracket notation, on the other hand, provides an embedding for applicatives. First, while monads force effects to be executed sequentially, ignoring potential for parallelism, applicatives do not support sequential effects. Composing sequential with parallel effects remains an open problem. This is even more of an issue as real programs consist of a combination of both sequential and parallel segments. Second, common notations do not support invoking effects in direct-style, instead forcing a rigid structure upon the code.
In this paper, we propose a mixed applicative/monadic notation that retains parallelism where possible, but allows sequentiality where necessary. We leverage a direct-style notation where sequentiality or parallelism is derived from the structure of the code. We provide a mechanisation of our effectful language in Coq and prove that our compilation approach retains the parallelism of the source program
Classical Control, Quantum Circuits and Linear Logic in Enriched Category Theory
We describe categorical models of a circuit-based (quantum) functional
programming language. We show that enriched categories play a crucial role.
Following earlier work on QWire by Paykin et al., we consider both a simple
first-order linear language for circuits, and a more powerful host language,
such that the circuit language is embedded inside the host language. Our
categorical semantics for the host language is standard, and involves cartesian
closed categories and monads. We interpret the circuit language not in an
ordinary category, but in a category that is enriched in the host category. We
show that this structure is also related to linear/non-linear models. As an
extended example, we recall an earlier result that the category of W*-algebras
is dcpo-enriched, and we use this model to extend the circuit language with
some recursive types
- …