Reference. Do be do be do
Cite
Cited by (11)
Notions of Stack-manipulating Computation and Relative Monads jiang_xue_new_2025
Monads provide a simple and concise interface to user-defined computational effects in functional programming languages. This enables equational reasoning about effects, abstraction over monadic interfaces and the development of monad transformer stacks to allow for multiple effects. Compiler implementors and assembly code programmers similarly virtualize effects, and would benefit from similar abstractions if possible. However, the implementation details of effects seem disconnected from the high-level monad interface: at this lower level much of the design is in the layout of the runtime stack, which is not accessible in a high-level programming language.
We demonstrate that the monadic interface can be faithfully adapted from high-level functional programming to a lower level setting with explicit stack manipulation. We use a polymorphic call-by-push-value (CBPV) calculus as a setting that captures the essence of stack-manipulation, with a type system that allows programs to define domain-specific stack structures. Within this setting, we show that the existing category-theoretic notion of a relative monad can be used to model the stack-based implementation of computational effects. To demonstrate generality, we adapt a variety of standard monads to relative monads. Additionally, we show that stack-manipulating programs can benefit from a generalization of do-notation we call “monadic blocks” that allow all CBPV code to be reinterpreted to work with an arbitrary relative monad. As an application, we show that all relative monads extend automatically to relative monad transformers, a process which is not automatic for monads in pure languages.
Gradual Typing for Effect Handlers new_giovannini_licata_2023
We present a gradually typed language, GrEff, with effects and handlers that supports migration from unchecked to checked effect typing. This serves as a simple model of the integration of an effect typing discipline with an existing effectful typed language that does not track fine-grained effect information. Our language supports a simple module system to model the programming model of gradual migration from unchecked to checked effect typing in the style of Typed Racket.
The surface language GrEff is given semantics by elaboration to a core language Core GrEff. We equip Core GrEff with an inequational theory for reasoning about the semantic error ordering and desired program equivalences for programming with effects and handlers. We derive an operational semantics for the language from the equations provable in the theory. We then show that the theory is sound by constructing an operational logical relations model to prove the graduality theorem. This extends prior work on embedding-projection pair models of gradual typing to handle effect typing and subtyping.
Structured Handling of Scoped Effects yang-2022-structured
Bidirectional Typing dunfield-2021-bidirectional
Gradual Type Theory new_licata_ahmed_2021
Doo bee doo bee doo convent-2020-doo
Effect handlers via generalised continuations hillerstrom-2020-effect
A Semantic Foundation for Sound Gradual Typing new_dissertation_2020
On the expressive power of user-defined effects: Effect handlers, monadic reflection, delimited control forster-2019-on
Gradual Type Theory new_licata_ahmed_2019
Gradually typed languages are designed to support both dynamically typed and statically typed programming styles while preserving the benefits of each. While existing gradual type soundness theorems for these languages aim to show that type-based reasoning is preserved when moving from the fully static setting to a gradual one, these theorems do not imply that correctness of type-based refactorings and optimizations is preserved. Establishing correctness of program transformations is technically difficult, because it requires reasoning about program equivalence, and is often neglected in the metatheory of gradual languages.
In this paper, we propose an axiomatic account of program equivalence in a gradual cast calculus, which we formalize in a logic we call gradual type theory (GTT). Based on Levy’s call-by-push-value, GTT gives an axiomatic account of both call-by-value and call-by-name gradual languages. Based on our axiomatic account we prove many theorems that justify optimizations and refactorings in gradually typed languages. For example, uniqueness principles for gradual type connectives show that if the βη laws hold for a connective, then casts between that connective must be equivalent to the so-called “lazy” cast semantics. Contrapositively, this shows that “eager” cast semantics violates the extensionality of function types. As another example, we show that gradual upcasts are pure functions and, dually, gradual downcasts are strict functions. We show the consistency and applicability of our axiomatic theory by proving that a contract-based implementation using the lazy cast semantics gives a logical relations model of our type theory, where equivalence in GTT implies contextual equivalence of the programs. Since GTT also axiomatizes the dynamic gradual guarantee, our model also establishes this central theorem of gradual typing. The model is parametrized by the implementation of the dynamic types, and so gives a family of implementations that validate type-based optimization and the gradual guarantee.
Continuation Passing Style for Effect Handlers hillerstrom-2017-continuation
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.
Cites 57 works (3 here)
With notes (3)
Productive coprogramming with guarded recursion atkey-2013-productive
Handlers in action kammar-2013-handlers
Applicative programming with effects mcbride-2008-applicative
External (54)
- Type directed compilation of row-typed algebraic effects (2017)
- Liberating effects with rows and handlers (2016)
- Monad transformers and modular algebraic effects (2016)
- Compilation of effect handlers and their applications in concurrency (2016)
- An algebraic approach to typechecking and elaboration (2015)
- Handlers for algebraic effects in Links (2015)
- Mathematics of Program Construction: 12th International Conference, MPC 2015, Königswinter, Germany, June 29 – July 1 (2015)
- Freer monads, more extensible effects (2015)
- Parsec (3.1.9) (2015)
- Turing-Completeness Totally Free (2015)
- Effective concurrency through algebraic effects (2015)
- Trifecta (1.5.2) (2015)
- Fusion for free: efficient algebraic effect handlers (2015)
- Indentation-sensitive parsing for Parsec (2014)
- An effect system for algebraic effects and handlers (2014)
- Koka: Programming with Row Polymorphic Effect Types (2014)
- Algebraic effects and effect handlers for idioms and arrows (2014)
- Inferring algebraic effects (2014)
- Heuristics Entwined with Handlers Combined: From Functional Specification to Logic Programming Implementation (2014)
- Reflection without remorse: revealing a hidden sequence to speed up monadic reflection (2014)
- Effect handlers in scope (2014)
- Wellfounded recursion with copatterns: a unified approach to termination and productivity (2013)
- Programming and reasoning with algebraic effects and dependent types (2013)
- Idris, a general-purpose dependently typed programming language: Design and implementation (2013)
- Extensible effects: an alternative to monad transformers (2013)
- Handling algebraic effects (2013)
- Type inference, Haskell and dependent types (2013)
- Programming with algebraic effects and handlers (2012)
- On the expressive power of user-defined effects: effect handlers, monadic reflection, delimited control (2012)
- Frank (0.3) (2012)
- Kleisli arrows of outrageous fortune (2011)
- Modular rollback through control logging: a pair of twin functional pearls (2011)
- Lightweight monadic programming in ML (2011)
- Monads in action (2010)
- Type inference in context (2010)
- Programming interfaces and basic topology (2009)
- Compiling pattern matching to good decision trees (2008)
- Data types à la carte (2008)
- How might effectful programs look? (2007)
- Links: Web Programming Without Tiers (2006)
- Programming with Arrows (2004)
- Call-by-push-value: a functional/imperative synthesis (2004)
- Algebraic Operations and Generic Effects (2003)
- Notions of Computation Determine Monads (2002)
- Semantics for Algebraic Operations (2001)
- Adequacy for Algebraic Effects (2001)
- Local type inference (2000)
- Representing layered monads (1999)
- The reflexive CHAM and the join-calculus (1996)
- The type and effect discipline (1994)
- The essence of functional programming (1992)
- How to make ad-hoc polymorphism less ad hoc (1989)
- Polymorphic effect systems (1988)
- Modules for standard ML (1984)