Effects and handlers¶
QVR has algebraic effects with handlers
(Plotkin and Power, 2003; Plotkin and Pretnar, 2009). An effect declaration names a set of operations,
the requests a computation may make, and gives their types. An effect instance is one named
occurrence of an effect interface, so two instances of one interface are handled separately
(Bauer and Pretnar, 2015). A computation's effect row lists the instances it may request from, and
a handler answers the requests made to one instance. Two instances of State[Int] thus share an
interface and remain distinct effects.
Declare an interface¶
left and right below are two integer state cells. Both accept the requests get and put,
but a request names its instance, so the row of exchange records two separate state
dependencies:
effect State[S : Type]
get : Unit -> S
put : S -> Unit
instance left : State[Int]
instance right : State[Int]
define exchange(next : Int) : Int !{left, right} =
let previous <- perform left.get()
perform right.put(next)
return previous
Square brackets bind static parameters of the interface or of an operation. An operation's
argument types precede ->. An operation with no arguments may be written Unit -> T or in the
nullary form the grammar admits. A request always names its instance, as in
perform left.get(), and this is what keeps left and right apart in the row.
The static arguments select an applied interface, while the operation's value arguments are given when a request runs. Programs, computations, and constructors use the same distinction between static specialization and runtime values, as described in the parameter reference. Introducing a static parameter does not itself perform the operation.
Prelude interfaces¶
These interfaces need no source declaration:
| Interface | Principal operation | Purpose |
|---|---|---|
Random |
sample[A](Site[A], Sampleable[A]) -> A |
draw or replay a random value at a named site |
Score |
add(LogWeight) -> Unit |
add a log density or a log factor to the run's weight |
State[S] |
get, put |
mutable state under a handler |
Abort[E] |
abort[A](E) -> A |
typed early exit |
Choose |
choose[A](A[Fin n]) -> A |
nondeterministic choice among alternatives |
Weight[K] |
add(K) -> Unit |
accumulate a weight in the semiring K |
Compute[X, A] |
apply(X) -> A |
call a Python value held by the running process |
Param |
get[A](String) -> A |
look up a learned parameter by name |
Every probabilistic program performs through two built-in instances, random : Random and
score : Score. A module that declares a
deduction or a parser built from rule schemata gains two
interfaces: Search, whose choose[a, n] picks one entry of a tensor of n alternatives, and
Settle, whose stop carries the value an iteration stopped at, whether the stop certifies it,
and the residual of its last two iterates. The module cannot declare an effect of either name
itself. Structural declarations create
Compute instances, which a caller reaches through Program.run rather than by writing the
requests.
Effect rows¶
A computation's signature ends in its effect row. A row with a row variable as its tail is open, and a computation whose row is open can be used under any instances the tail stands for, which is row polymorphism over effects (Leijen, 2014):
| Row | Meaning |
|---|---|
!{} |
closed and pure |
!{left, right} |
exactly these instances |
!{robust | rho} |
robust and whatever instances the row variable rho stands for |
!{robust | rho lacks robust} |
the same, with rho constrained not to contain robust |
Rows contain instances, not interface names. A call contributes its callee's row after static
substitution, and a perform contributes the instance it names. An if or a case joins the rows
of all its reachable branches, and since coverage is conservative, a branch the checker cannot
prove impossible still contributes its effects.
A lacks constraint keeps a row polymorphic computation that adds an instance of its own from
duplicating one already in the caller's tail. It is needed when an abstraction handles or
introduces an instance name that the tail could otherwise contain.
Handler declarations¶
A handler declares the interface it handles, its input and answer types, its parameters if it has any, its options, one return clause, and one clause per operation:
effect Robust
shrink : Real -> Real
instance robust : Robust
handler half_weight for Robust : Real -> Real [coverage=total, forwards=none, implementation=authored]
return x =>
return x
shrink(x : Real) resumes 1 =>
resume(0.5 * x)
define robustify(x : Real) : Real !{} =
handle robust with half_weight in
let adjusted <- perform robust.shrink(x)
return adjusted
The return clause receives the value of a computation that finishes. An operation clause
receives the request's arguments and may call resume, which continues the suspended computation
with a value. In robustify(8.0), the request robust.shrink(8.0) reaches half_weight, whose
clause resumes with 4.0, so adjusted is 4.0, and the return clause passes 4.0 through.
QVR handlers are deep: the handler is reinstalled around the computation it resumes, so later requests in that computation reach the same handler (Plotkin and Pretnar, 2009; Kammar et al., 2013). Effects that a clause body performs itself go only to outer handlers.
Handler parameters¶
A handler may carry values from one request to the next in parameters, typed binders that every
clause reads (Leijen, 2017; Bauer and Pretnar, 2015). They follow the answer type, handle gives
their first values, and resume(v) with (e) gives the values they have while the continuation runs:
effect State[S : Type]
get : Unit -> S
put : S -> Unit
handler cell[S : Type, A : Type] for State[S] : A -> A with (s : S) [coverage=total, forwards=none, implementation=authored]
return x =>
return x
get resumes 1 =>
resume(s)
put(v : S) resumes 1 =>
resume() with (v)
define counted(seed : Int) : Int !{} =
with instance c : State[Int] in
handle c with cell[Int, Int](seed) in
let before <- perform c.get()
perform c.put(before + 1)
let after <- perform c.get()
return after
counted(3) installs cell with s at 3. The clause for put continues the computation with
s at 4, so the second get reads 4, and counted(3) returns 4.
- A
resumewithoutwithkeeps the parameters, as the clause forgetdoes. With it,resumegives one value per parameter, in order. - The return clause reads the parameters, so a handler of type
A -> A * Scan answer with the final state,return (x, s). - A clause of grade
omegagives each resumption the parameters it names. The parameters belong to the resumed continuation, so two resumptions never share an update. - The parameters are part of the handler's signature in the serialized module. A foreign handler declares none, since its state belongs to its provider.
A handler that never updates its parameter is a reader, and one whose return clause answers an accumulated parameter is a writer:
effect Reader[R : Type]
ask : Unit -> R
effect Writer
tell : Real -> Unit
handler reading[R : Type, A : Type] for Reader[R] : A -> A with (r : R) [coverage=total, forwards=none, implementation=authored]
return x =>
return x
ask resumes 1 =>
resume(r)
handler writing[A : Type] for Writer : A -> A * Real with (written : Real) [coverage=total, forwards=none, implementation=authored]
return x =>
return (x, written)
tell(v : Real) resumes 1 =>
resume() with (written + v)
Handler options¶
| Option | Values | Meaning |
|---|---|---|
coverage |
total, partial |
whether every operation of the interface has a clause |
forwards |
none, unknown |
whether a partial handler passes requests without a clause to an outer handler |
implementation |
authored, foreign |
whether the clauses have QVR bodies or are given by a runtime provider |
introduces |
instance names | the effects the handler's own clauses perform, which the row of the handled computation gains. A clause that performs any other effect is rejected |
A total handler removes the instance it handles from the row of its body, and a partial handler leaves it there. Forwarding and coverage are separate options: a request for an operation that a partial, nonforwarding handler has no clause for is an error, not an implicit request to an outer handler.
Resumption grades¶
A resumption grade says how many times a handler clause may resume its continuation, that is, the rest of the computation after the request. The grades are the usage multiplicities of substructural type systems, as in quantitative type theory (Atkey, 2018):
| Grade | Contract | Typical clause |
|---|---|---|
0 |
never resumes | an abort |
aff |
resumes at most once | a clause that may stop the computation |
1 |
resumes exactly once | a state read or update |
omega |
resumes any number of times | a search clause that explores each alternative |
[lower, upper] |
resumes within the inclusive integer bounds | an isolated clause with finitely many alternatives |
Finite intervals require 0 <= lower <= upper and upper >= 2. Their
native installation handles one nominal operation in a named computation.
The clause and its resumed continuation can bind and branch on Boolean,
unit and product values. They can also use scalar Real values with the
built-in addition, subtraction, multiplication and greater-than comparison.
The continuation returns without handling another request. The
QIEC runtime contract describes the checks.
In a clause of grade omega, traverse(xs, x -> resume(x)) resumes once per entry of a tensor of
statically known extent and binds the tensor of the answers.
The checker records each clause's grade, and the
reference machine, the library's interpreter for
its core language, enforces it. A grade of omega
lets the continuation run more than once, which also repeats the requests that follow. Each
handler installed in that continuation must thus be one the runtime can copy for a second
resumption.
Scoped instances¶
with instance creates an instance that exists only inside its block:
effect State[S : Type]
get : Unit -> S
put : S -> Unit
handler fixed_reply for State[Int] : Int -> Int [coverage=total, forwards=none, implementation=authored]
return x =>
return x
get resumes 1 =>
resume(7)
put(s : Int) resumes 1 =>
resume(unit)
define local_read() : Int !{} =
with instance cell : State[Int] in
handle cell with fixed_reply in
perform cell.put(3)
let value <- perform cell.get()
return value
fixed_reply answers every get with 7 and ignores the value given to put, so local_read()
returns 7 after put(3). The parameterized handler cell carries the value
of put to later get requests instead.
A total handler must remove the scoped instance before control leaves the block, or the checker
reports qiec-instance-escape. Two nested with instance cell ... blocks create two instances,
though the inner name shadows the outer.
Named static operations¶
A scoped_operation is a scoped operation in the sense of hefty algebras
(Bach Poulsen and van der Rest, 2023): a computation argument and an elaboration into an algebraic
handler. It names a checked authored handler, the effect instance
it handles, and the closed row of its inline computation argument. At a use,
brackets list the local scalar values the body may read, and parentheses pass
values to the handler. The result row retains the other declared instances.
The Reader example
runs the same body with two nominal instances of one effect.
Higher-order operations¶
An operation whose arguments are computations is higher-order. Declared with an elaborator and
no body_effects, every request to its instance is replaced by the elaborator's clause at the
request, so the computation arguments run under the handlers in scope there
(Bach Poulsen and van der Rest, 2023):
effect Env
ask : Unit -> Real
instance env : Env
effect Local
local : (Real -> Real) * (Unit -> Real !{env}) -> Real
instance scoping : Local
handler reading for Env : Real -> Real with (r : Real) [coverage=total, forwards=none, implementation=authored]
return x =>
return x
ask resumes 1 =>
resume(r)
define under(value : Real, body : Unit -> Real !{env}) : Real !{} =
handle env with reading(value) in
body(unit)
handler local_elaboration for Local : Real -> Real [coverage=total, forwards=none, introduces=!{env}, implementation=authored]
return x =>
return x
local(change : Real -> Real, body : Unit -> Real !{env}) resumes 1 =>
let current <- perform env.ask()
let changed <- change(current)
let result <- under(changed, body)
resume(result)
scoped_operation local_binding [instance=scoping, elaborator=local_elaboration]
define double(x : Real) : Real !{} =
return 2.0 * x
define read_env(u : Unit) : Real !{env} =
perform env.ask()
define inside() : Real !{scoping} =
handle env with reading(100.0) in
let x <- perform scoping.local(double, read_env)
let y <- perform env.ask()
return x + 0.0 * y
inside() returns 200.0: the elaboration reads the environment the request sees (100.0).
Handled algebraically by an outer handler, the same clause would read the outer environment. The
elaborator's clauses each resume once, in tail position; a request to an elaborated instance
performs what its elaborator introduces, and an elaborated instance is not handled
(qiec-elaboration). An elaboration may request another elaborated operation.
Generic code and open rows¶
A computation whose row ends in a row variable does not know which instances the variable stands for. When such a computation installs a handler for an instance around a call or a function application whose row reaches that instance only through the variable, the request does not belong to it: it tunnels past the handler to the next handler of the instance outside (Biernacki et al., 2020; Zhang and Myers, 2019). Generic code cannot handle an instance it was not given:
effect Robust
shrink : Real -> Real
instance robust : Robust
handler half_weight for Robust : Real -> Real [coverage=total, forwards=none, implementation=authored]
return x =>
return x
shrink(x : Real) resumes 1 =>
resume(0.5 * x)
handler tenth for Robust : Real -> Real [coverage=total, forwards=none, implementation=authored]
return x =>
return x
shrink(x : Real) resumes 1 =>
resume(0.1 * x)
define generic(f : Real -> Real !{| rho}) : Real !{| rho} =
handle robust with half_weight in
let own <- perform robust.shrink(8.0)
let theirs <- f(10.0)
return own + theirs
define shrunk(x : Real) : Real !{robust} =
perform robust.shrink(x)
define caller() : Real !{} =
handle robust with tenth in
generic(shrunk)
caller() returns 5.0. The request generic makes itself reaches half_weight (8.0 becomes
4.0), and the request shrunk makes reaches tenth (10.0 becomes 1.0), although
half_weight was installed between them. Elaboration wraps the application f(10.0) in a mask
of robust, a term that routes the requests of its body past the innermost handler of that
instance, once per handler of the instance the computation installs around it. The kernel rejects
a body in which a handler could intercept such a request without a mask (qiec-tunnel).
A row variable declared lacks an instance cannot carry it, so a computation typed
!{| rho lacks robust} needs no mask, and a caller cannot instantiate rho with robust. A call
that is given an instance explicitly and may also reach it through a variable that does not lack
it is refused, since a handler could not tell the two requests apart; declare the variable lacks
the instance.
Effects across modules¶
An effect interface, its instances, and its handlers are ordinary declarations, so a module can
export them. A generic module declares the interfaces and instances it performs on, and an
experiment module exports handler bundles for them. Linking the two is installation: the module
that runs the experiment installs the experiment's handlers on the generic module's instances.
The four files below are one package. The generic module discourse declares the interfaces it
performs on, exports an instance of each, and judges a sentence by performing on them:
export family Sentence : Type
constructor Fact : Int -> Sentence
constructor Not : Sentence -> Sentence
constructor And : Sentence * Sentence -> Sentence
export effect World
holds : Int -> Bool
export effect Readout
report : Bool -> Real
export instance world : World
export instance readout : Readout
export define truth(s : Sentence) : Bool !{world} =
case s motive => Bool
Fact(n) =>
let b <- perform world.holds(n)
return b
Not(p) =>
let b <- truth(p)
return not b
And(p, q) =>
let b <- truth(p)
if b then
let c <- truth(q)
return c
else
return false
export define judgment(s : Sentence) : Real !{world, readout} =
let b <- truth(s)
let r <- perform readout.report(b)
return r
Two experiment modules each export a handler for one of those interfaces:
import discourse as D
export handler parity for D.World : Real -> Real [coverage=total, forwards=none, implementation=authored]
return x =>
return x
holds(n : Int) resumes 1 =>
let half = n / 2
resume(2 * half == n)
import discourse as D
export handler event for D.Readout : Real -> Real [coverage=total, forwards=none, implementation=authored]
return x =>
return x
report(b : Bool) resumes 1 =>
if b then
resume(1.0)
else
resume(0.0)
The module that runs the experiment installs them:
import discourse as D
import boolean_worlds as B
import readouts as R
export define rate(a : Int, b : Int) : Real !{} =
let s = D.And(D.Fact(a), D.Not(D.Fact(b)))
handle D.readout with R.event in
handle D.world with B.parity in
D.judgment(s)
A downstream module adds a readout by exporting another handler for D.Readout; the generic
module is not edited. A module can install a handler only for an instance it can name, so code
cannot intercept another module's instance that module does not export.
Laws as local theories¶
An effect_law without handlers is a local theory of its instance (Lukšič and Pretnar, 2020): it states
an equation that the code using the instance relies on, and every handler installed for the
instance, in this module or in any module linked to it, is checked against it.
effect World
holds : Bool -> Bool
instance world : World
define read_twice(f : Bool) : Bool !{world} =
let first <- perform world.holds(f)
let second <- perform world.holds(f)
if first then
return second
else
if second then
return false
else
return true
define agreed(f : Bool) : Bool !{} =
return true
effect_law stable_reading [instance=world, operations=[holds], left=read_twice, right=agreed]
handler identity_world for World : Bool -> Bool [coverage=total, forwards=none, implementation=authored]
return x =>
return x
holds(f : Bool) resumes 1 =>
resume(f)
define judge(f : Bool) : Bool !{} =
handle world with identity_world in
read_twice(f)
identity_world answers every read of a fact the same way, so the law is checked for it. A handler
that answered the second read differently from the first would be refused at compile time with
qiec-effect-law and the counterexample. The method option selects the finite, polynomial, or
rational check, as for a law with handlers. A law the method cannot decide for a handler is
recorded as assumed for that handler, never as checked.
Discharged handlers¶
A handler whose clauses are written in QVR can be discharged: a computation that installs it is
rewritten to an equal one with no handler, in which the answer of its clause stands in place of each
request. counted above discharges to return seed + 1. The compiled runtime, which computes
gradients, and the transpile targets that render no handler read the rewritten computation, so a
program that calls counted is fit and exported to
Stan, BUGS, and JAGS. The checked module keeps the handler, the reference machine runs it, and the
targets that render handlers render it.
A tail-resumptive handler is compiled first, by evidence passing [@xie2020evidently;
@xie2021generalized]. Its clauses resume once, in tail position, keep the handler's parameters,
and perform nothing, and its return clause makes no request, as with identity_world, reading,
and half_weight above. Each request it answers becomes the clause's code at the request site, and
each computation the request is reached through is specialized to the handler, receiving its
parameters as arguments. No continuation is captured, so recursion, a case on a value known only
at run time, and loops compile alike. A specialized computation that makes requests of its own
outside the handler keeps the ordinary discharge below, since its call frame would carry a new
name in their addresses.
Every other grade is discharged by one rule, which puts the continuation in place of each resume.
A grade 0 clause under an if becomes a choice between the clause's answer and the rest of the
computation, and a clause that resumes once per entry of a tensor becomes the tensor of the answers.
Where the branches of an if change a handler's parameters, the changed values become conditional
values.
A computation keeps its handlers, and the diagnostic names the handler and the clause, when
- it installs a foreign handler;
- it makes a request that every handler of the instance forwards and no outer handler of the computation answers;
- it makes a request to a handler that is not tail-resumptive in a recursive call, so that how often a clause resumes depends on the values of the run;
- it analyzes a family value known only at run time with
case, and the branches do not continue alike; - it keeps a mask over a handler that evidence passing does not compile; the targets that render
handler frames render the mask, and Stan, BUGS, and JAGS, which render none, refuse it with
qiec:capability:tunnel; - the rewritten computation would have more than 2048 statements. A clause that resumes \(m\) times copies the rest of the computation \(m\) times, so \(n\) such requests in sequence make \(m^n\) copies, and a conditional whose branches differ in \(k\) values is stated \(k\) times.
The semantics states the rewriting and why it keeps the value of the computation.
One-shot clauses under multi-shot handlers¶
A clause of grade 1 or aff holds a one-shot resumption until it resumes. If it makes a request
before then that a multi-shot handler answers, each shot runs the rest of the clause with the same
resumption. The checker refuses a module in which two shots can each reach that resumption
(qiec-linearity) (Tang et al., 2024). It follows the clause from the request once per value the
multi-shot clause resumes with, decides branches whose conditions are known constants, and counts a
shot that reaches a clause of grade 0 before resuming as spent nothing, so a shot that aborts is
admitted:
effect Fork
split : Real -> Real
effect Relay
pass : Real -> Real
effect Escape
stop : Real -> Real
instance branch : Fork
instance relay : Relay
instance escape : Escape
handler cut for Escape : Real -> Real [coverage=total, forwards=none, implementation=authored]
stop(v : Real) resumes 0 =>
return 10.0
handler twice for Fork : Real -> Real [coverage=total, forwards=none, implementation=authored]
return x =>
return x
split(v : Real) resumes omega =>
let first <- resume(0.0 - 1.0)
let second <- resume(v + 1.0)
return first + second
handler early for Relay : Real -> Real [coverage=total, forwards=none, introduces=!{branch, escape}, implementation=authored]
return x =>
return x
pass(v : Real) resumes 1 =>
let w <- perform branch.split(v)
if w < 0.0 then
let gone <- perform escape.stop(w)
resume(gone)
else
resume(w)
define run(x : Real) : Real !{} =
handle escape with cut in
handle branch with twice in
handle relay with early in
perform relay.pass(x)
The first shot of twice resumes with -1.0, which early sends to cut, so only the second
shot resumes early's resumption. With resume(v) as the first shot, both could, and the module
is refused.
Foreign handlers and providers¶
A handler declared implementation=foreign gives only the signature of each clause, with no
=> body. A runtime provider binds such a handler to an implementation held in the running
Python process (see runtime providers), the closest
standard notion being a foreign function interface.
The serialized module holds the handler's type, its operation coverage, and its grades, but no
callable. At invocation, the selected provider binds the handler's stable identifier to an
implementation. A provider configuration file holds provider names and data only, and it cannot
inject code.
A foreign handler may also declare what its clauses compute, in the
foreign field of its checked
definition: a semiring sum over alternatives, a semiring product of added weights, an enumeration
of a finite draw, or the settlement of an iteration. The core provider builds such a handler from
that statement and the laws of the named semiring, and never from the handler's name
(foreign handler semantics). The handlers that a deduction D
generates, D.search, D.collect, and D.settle, are declared this way.
The built-in core provider gives the implementations that program execution, deductions, and the
prelude use. A structural model composes core with a provider that holds its compiled PyTorch
modules.
Common failures¶
- Request absent from the row. Add the instance to the row, or make the row polymorphic when the abstraction should keep the caller's effects.
- Wrong applied interface.
State[Int]andState[String]are distinct, and a handler must match the instance's exact application. - Instance escape. Handle a scoped instance before leaving its block.
- Grade violation. Make the number of
resumecalls agree with the declared grade. - Missing provider. Attach a provider that implements the foreign handler, or write an authored handler.
- Interception through an open row (
qiec-tunnel). Declare the row variablelacksthe instance, or pass the instance explicitly instead of through the variable. - One-shot resumption copied (
qiec-linearity). Resume before making the request a multi-shot handler answers, or make the shots that should not resume abort through a clause of grade0. - Elaboration refused (
qiec-elaboration). End each elaborator clause in one tail resumption, give it no parameters and an identity return, and do not install a handler for the elaborated instance. - Law refuted by an installed handler (
qiec-effect-law). Change the handler so the law holds at the reported counterexample, or remove the law if the code does not rely on it.
The effects tutorial builds and traces an authored handler.
Cited sources¶
Gordon Plotkin and John Power. Algebraic Operations and Generic Effects. Applied Categorical Structures, 11:69–94, 2003. URL: https://link.springer.com/article/10.1023/A:1023064908962, doi:10.1023/A:1023064908962.
Gordon Plotkin and Matija Pretnar. Handlers of Algebraic Effects. In Programming Languages and Systems, volume 5502 of Lecture Notes in Computer Science, 80–94. Springer, 2009. URL: https://link.springer.com/chapter/10.1007/978-3-642-00590-9_7, doi:10.1007/978-3-642-00590-9_7.
Andrej Bauer and Matija Pretnar. Programming with Algebraic Effects and Handlers. Journal of Logical and Algebraic Methods in Programming, 84(1):108–123, 2015. URL: https://www.sciencedirect.com/science/article/pii/S2352220814000194, doi:10.1016/j.jlamp.2014.02.001.
Daan Leijen. Koka: Programming with Row Polymorphic Effect Types. In Proceedings of the 5th Workshop on Mathematically Structured Functional Programming (MSFP), volume 153 of Electronic Proceedings in Theoretical Computer Science, 100–126. 2014. doi:10.4204/EPTCS.153.8.
Ohad Kammar, Sam Lindley, and Nicolas Oury. Handlers in Action. In Proceedings of the 18th ACM SIGPLAN International Conference on Functional Programming (ICFP), 145–158. 2013. doi:10.1145/2500365.2500590.
Daan Leijen. Type Directed Compilation of Row-Typed Algebraic Effects. In Proceedings of the 44th ACM SIGPLAN Symposium on Principles of Programming Languages (POPL), 486–499. 2017. doi:10.1145/3009837.3009872.
Robert Atkey. Syntax and Semantics of Quantitative Type Theory. In Proceedings of the 33rd Annual ACM/IEEE Symposium on Logic in Computer Science (LICS), 56–65. 2018. doi:10.1145/3209108.3209189.
Casper Bach Poulsen and Cas van der Rest. Hefty Algebras: Modular Elaboration of Higher-Order Algebraic Effects. Proceedings of the ACM on Programming Languages, 2023. doi:10.1145/3571255.
Dariusz Biernacki, Maciej Piróg, Piotr Polesiuk, and Filip Sieczkowski. Binders by Day, Labels by Night: Effect Instances via Lexically Scoped Handlers. Proceedings of the ACM on Programming Languages, 4(POPL):1–29, 2020. doi:10.1145/3371116.
Yizhou Zhang and Andrew C. Myers. Abstraction-Safe Effect Handlers via Tunneling. Proceedings of the ACM on Programming Languages, 2019. doi:10.1145/3290318.
Žiga Lukšič and Matija Pretnar. Local Algebraic Effect Theories. Journal of Functional Programming, 2020. doi:10.1017/S0956796819000212.
Wenhao Tang, Daniel Hillerström, Sam Lindley, and J. Garrett Morris. Soundly Handling Linearity. Proceedings of the ACM on Programming Languages, 2024. doi:10.1145/3632896.