21 research outputs found
Continuation Passing Style for Effect Handlers
We present Continuation Passing Style (CPS) translations for Plotkin and Pretnar's effect handlers with Hillerström and Lindley's row-typed fine-grain call-by-value calculus of effect handlers as the source language. CPS translations of handlers are interesting theoretically, to explain the semantics of handlers, and also offer a practical implementation technique that does not require special support in the target language's runtime. We begin with a first-order CPS translation into untyped lambda calculus which manages a stack of continuations and handlers as a curried sequence of arguments. We then refine the initial CPS translation first by uncurrying it to yield a properly tail-recursive translation and second by making it higher-order in order to contract administrative redexes at translation time. We prove that the higher-order CPS translation simulates effect handler reduction. We have implemented the higher-order CPS translation as a JavaScript backend for the Links programming language
On the Expressive Power of User-Defined Effects: Effect Handlers, Monadic Reflection, Delimited Control
We compare the expressive power of three programming abstractions for
user-defined computational effects: Bauer and Pretnar's effect handlers,
Filinski's monadic reflection, and delimited control without
answer-type-modification. This comparison allows a precise discussion about the
relative expressiveness of each programming abstraction. It also demonstrates
the sensitivity of the relative expressiveness of user-defined effects to
seemingly orthogonal language features. We present three calculi, one per
abstraction, extending Levy's call-by-push-value. For each calculus, we present
syntax, operational semantics, a natural type-and-effect system, and, for
effect handlers and monadic reflection, a set-theoretic denotational semantics.
We establish their basic meta-theoretic properties: safety, termination, and,
where applicable, soundness and adequacy. Using Felleisen's notion of a macro
translation, we show that these abstractions can macro-express each other, and
show which translations preserve typeability. We use the adequate finitary
set-theoretic denotational semantics for the monadic calculus to show that
effect handlers cannot be macro-expressed while preserving typeability either
by monadic reflection or by delimited control. We supplement our development
with a mechanised Abella formalisation
Language-integrated provenance by trace analysis
Language-integrated provenance builds on language-integrated query techniques
to make provenance information explaining query results readily available to
programmers. In previous work we have explored language-integrated approaches
to provenance in Links and Haskell. However, implementing a new form of
provenance in a language-integrated way is still a major challenge. We propose
a self-tracing transformation and trace analysis features that, together with
existing techniques for type-directed generic programming, make it possible to
define different forms of provenance as user code. We present our design as an
extension to a core language for Links called LinksT, give examples showing its
capabilities, and outline its metatheory and key correctness properties.Comment: DBPL 201
Generic Programming with Extensible Data Types; Or, Making Ad Hoc Extensible Data Types Less Ad Hoc
We present a novel approach to generic programming over extensible data
types. Row types capture the structure of records and variants, and can be used
to express record and variant subtyping, record extension, and modular
composition of case branches. We extend row typing to capture generic
programming over rows themselves, capturing patterns including lifting
operations to records and variations from their component types, and the
duality between cases blocks over variants and records of labeled functions,
without placing specific requirements on the fields or constructors present in
the records and variants. We formalize our approach in System R{\omega}, an
extension of F{\omega} with row types, and give a denotational semantics for
(stratified) R{\omega} in Agda.Comment: To appear at: International Conference on Functional Programming 2023
Corrected citations from previous versio
Effects for Efficiency: Asymptotic Speedup with First-Class Control
We study the fundamental efficiency of delimited control. Specifically, we
show that effect handlers enable an asymptotic improvement in runtime
complexity for a certain class of functions. We consider the generic count
problem using a pure PCF-like base language and its extension with
effect handlers . We show that admits an asymptotically
more efficient implementation of generic count than any
implementation. We also show that this efficiency gap remains when
is extended with mutable state. To our knowledge this result is the first of
its kind for control operators
Handling Fibred Algebraic Effects
International audienceWe study algebraic computational effects and their handlers in the dependently typed setting. We describecomputational effects using a generalisation of Plotkin and Pretnar’s effect theories, whose dependentlytyped operations allow us to capture precise notions of computation, e.g., state with location-dependent storetypes and dependently typed update monads. Our treatment of handlers is based on an observation that theirconventional term-level definition leads to unsound program equivalences being derivable in languages thatinclude a notion of homomorphism. We solve this problem by giving handlers a novel type-based treatmentvia a new computation type, the user-defined algebra type, which pairs a value type (the carrier) with a set ofvalue terms (the operations), capturing Plotkin and Pretnar’s insight that effect handlers denote algebras. Wethen show that the conventional presentation of handlers can be routinely derived, and demonstrate that thistype-based treatment of handlers provides a useful mechanism for reasoning about effectful computations.We also equip the resulting language with a sound denotational semantics based on families fibrations