1
0
mirror of https://github.com/dhil/phd-dissertation synced 2026-03-13 19:18:25 +00:00

Compare commits

...

2 Commits

Author SHA1 Message Date
ea3c6a7345 Structured interface explanation 2021-01-08 16:16:05 +00:00
672d67fc72 WIP 2021-01-08 13:08:01 +00:00

View File

@@ -138,13 +138,18 @@
% operator \emph{async-await} lets the programmer run multiple % operator \emph{async-await} lets the programmer run multiple
% distinct continuations asynchronously and await their results. % distinct continuations asynchronously and await their results.
% %
First-class control operators provide an expressive and efficient First-class control operators provide programmers with an expressive
means for programmers to implement their own control idioms as and efficient means for manipulating control through reification of
shareable libraries. the current control state as a first-class object, enabling
programmers to implement their own control idioms as shareable
libraries.
% %
Effect handlers provide a structured interface for programming with Effect handlers provide a particularly structured approach to
first-class control by separating control reifying operations from programming with first-class control by separating control reifying
their handling. operations from their handling.
In this thesis I develop operational foundations for programming and
implementing effect handlers.
The first strand develops the core calculus of a programming The first strand develops the core calculus of a programming
language with a \emph{structural} notion of effects, as opposed to language with a \emph{structural} notion of effects, as opposed to
@@ -153,13 +158,17 @@
By making crucial use of \emph{row polymorphism} to build and track By making crucial use of \emph{row polymorphism} to build and track
effect signatures. effect signatures.
The second strand studies foundational implementation techniques for The second strand studies \emph{continuation passing style} and
deep, shallow, and parameterised effect handlers. \emph{abstract machine semantics}, which are foundational techniques
that admit a unified basis for implementing deep, shallow, and
parameterised effect handlers in the same environment.
%
Starting from a CPS translation basic Eventually leading to the
notion of \emph{generalised continuation}.
The third strand explores the expressive power of effect handlers. The third strand investigates the expressive power of effect
handlers.
In this thesis I develop foundational techniques for programming and %
implementing effect handlers.
} }
%% Now we start with the actual document. %% Now we start with the actual document.
@@ -4257,36 +4266,42 @@ The term `pure' is heavily overloaded in the programming literature.
\label{ch:unary-handlers} \label{ch:unary-handlers}
% %
Programming with effect handlers is a dichotomy of \emph{performing} Programming with effect handlers is a dichotomy of \emph{performing}
and \emph{handling} of effectful operations -- or alternatively a and \emph{handling} of effectful operations --- or alternatively a
dichotomy of \emph{constructing} and \emph{deconstructing} effects. An dichotomy of \emph{constructing} and \emph{deconstructing} effects. An
operation is a constructor of an effect. By itself an operation has no operation is a constructor of an effect. By itself an operation has no
predefined semantics. A handler deconstructs effects by predefined semantics. A handler deconstructs an effect by
pattern-matching on their operations. By matching on a particular pattern-matching on its operations. By matching on a particular
operation, a handler instantiates the said operation with a particular operation, a handler instantiates the operation with a particular
semantics of its own choosing. The key ingredient to make this work in semantics of its own choosing. The key ingredient to make this work in
practice is \emph{delimited control}. Performing an operation reifies practice is \emph{delimited control}. Performing an operation reifies
the remainder of the computation up to the nearest enclosing handler the remainder of the computation up to the nearest enclosing handler
of the said operation as a continuation. The continuation is provided of the operation as a continuation. This continuation is exposed to
to the programmer via the handler, and it may be manipulated like any the programmer via the handler as a first-class value, and thus, it
other first-class value. may be invoked, discarded, or stored for later use at the discretion
of the programmer.
Effect handlers provide a structured interface for programming with Effect handlers provide a structured and modular interface for
delimited continuations. They are structured in the sense that an programming with delimited control. They are structured in the sense
invocation site of an operation is decoupled from the use site of its that the invocation site of an operation is decoupled from the use
continuation. A continuation is exposed in the corresponding operation site of its continuation. A handler consists of a collection of
cases inside the handler of its operation of provenance. operation clauses, one for each operation it handles. Effect handlers
are modular as a handler will only capture and expose continuations
for operations that it handles, other operation invocations pass
seamlessly through the handler such that the operation can be handled
by another suitable handler. This allows modular construction of
programs, where multiple handlers can be composed to interpret all
effects of the whole program.
I will make a slight change of terminology to disambiguate From here onwards I will make a slight change of terminology to
programmatic continuations, i.e. continuations exposed to the disambiguate programmatic continuations, i.e. continuations exposed to
programmer, from continuations in continuation passing style the programmer, from continuations in continuation passing style
(Chapter~\ref{ch:cps}) and machine continuations (Chapter~\ref{ch:cps}) and continuations in abstract machines
(Chapter~\ref{ch:abstract-machine}). In the remainder of this (Chapter~\ref{ch:abstract-machine}). In the remainder of this
dissertation I refer to programmatic continuations as `resumptions', dissertation I refer to programmatic continuations as `resumptions',
and reserve the term `continuation' for continuations concerning the and reserve the term `continuation' for continuations concerning the
implementation details. implementation details.
% In this chapter we study various flavours of unary effect % In this chapter we study various flavours of unary effect
% handlers~\cite{PlotkinP13}, that is handlers of a single % handlers~\cite{PlotkinP13}, that is handlers of a single
% computation. Concretely, we shall study four variations of effect % computation. Concretely, we shall study four variations of effect