930 research outputs found
No value restriction is needed for algebraic effects and handlers
We present a straightforward, sound Hindley-Milner polymorphic type system
for algebraic effects and handlers in a call-by-value calculus, which allows
type variable generalisation of arbitrary computations, not just values. This
result is surprising. On the one hand, the soundness of unrestricted
call-by-value Hindley-Milner polymorphism is known to fail in the presence of
computational effects such as reference cells and continuations. On the other
hand, many programming examples can be recast to use effect handlers instead of
these effects. Analysing the expressive power of effect handlers with respect
to state effects, we claim handlers cannot express reference cells, and show
they can simulate dynamically scoped state
Inferring Algebraic Effects
We present a complete polymorphic effect inference algorithm for an ML-style
language with handlers of not only exceptions, but of any other algebraic
effect such as input & output, mutable references and many others. Our main aim
is to offer the programmer a useful insight into the effectful behaviour of
programs. Handlers help here by cutting down possible effects and the resulting
lengthy output that often plagues precise effect systems. Additionally, we
present a set of methods that further simplify the displayed types, some even
by deliberately hiding inferred information from the programmer
Koka: Programming with Row Polymorphic Effect Types
We propose a programming model where effects are treated in a disciplined
way, and where the potential side-effects of a function are apparent in its
type signature. The type and effect of expressions can also be inferred
automatically, and we describe a polymorphic type inference system based on
Hindley-Milner style inference. A novel feature is that we support polymorphic
effects through row-polymorphism using duplicate labels. Moreover, we show that
our effects are not just syntactic labels but have a deep semantic connection
to the program. For example, if an expression can be typed without an exn
effect, then it will never throw an unhandled exception. Similar to Haskell's
`runST` we show how we can safely encapsulate stateful operations. Through the
state effect, we can also safely combine state with let-polymorphism without
needing either imperative type variables or a syntactic value restriction.
Finally, our system is implemented fully in a new language called Koka and has
been used successfully on various small to medium-sized sample programs ranging
from a Markdown processor to a tier-splitted chat application. You can try out
Koka live at www.rise4fun.com/koka/tutorial.Comment: In Proceedings MSFP 2014, arXiv:1406.153
A generic operational metatheory for algebraic effects
We provide a syntactic analysis of contextual preorder and equivalence for a polymorphic programming language with effects. Our approach applies uniformly across a range of algebraic effects, and incorporates, as instances: errors, input/output, global state, nondeterminism, probabilistic choice, and combinations thereof. Our approach is to extend Plotkin and Power’s structural operational semantics for algebraic effects (FoSSaCS 2001) with a primitive “basic preorder” on ground type computation trees. The basic preorder is used to derive notions of contextual preorder and equivalence on program terms. Under mild assumptions on this relation, we prove fundamental properties of contextual preorder (hence equivalence) including extensionality properties and a characterisation via applicative contexts, and we provide machinery for reasoning about polymorphism using relational parametricity
Handling polymorphic algebraic effects
Algebraic effects and handlers are a powerful abstraction mechanism to
represent and implement control effects. In this work, we study their extension
with parametric polymorphism that allows abstracting not only expressions but
also effects and handlers. Although polymorphism makes it possible to reuse and
reason about effect implementations more effectively, it has long been known
that a naive combination of polymorphic effects and let-polymorphism breaks
type safety. Although type safety can often be gained by restricting let-bound
expressions---e.g., by adopting value restriction or weak polymorphism---we
propose a complementary approach that restricts handlers instead of let-bound
expressions. Our key observation is that, informally speaking, a handler is
safe if resumptions from the handler do not interfere with each other. To
formalize our idea, we define a call-by-value lambda calculus that supports
let-polymorphism and polymorphic algebraic effects and handlers, design a type
system that rejects interfering handlers, and prove type safety of our
calculus.Comment: Added the errata for the ESOP'19 paper (page 28
A Purely Functional Computer Algebra System Embedded in Haskell
We demonstrate how methods in Functional Programming can be used to implement
a computer algebra system. As a proof-of-concept, we present the
computational-algebra package. It is a computer algebra system implemented as
an embedded domain-specific language in Haskell, a purely functional
programming language. Utilising methods in functional programming and prominent
features of Haskell, this library achieves safety, composability, and
correctness at the same time. To demonstrate the advantages of our approach, we
have implemented advanced Gr\"{o}bner basis algorithms, such as Faug\`{e}re's
and , in a composable way.Comment: 16 pages, Accepted to CASC 201
On CSP and the Algebraic Theory of Effects
We consider CSP from the point of view of the algebraic theory of effects,
which classifies operations as effect constructors or effect deconstructors; it
also provides a link with functional programming, being a refinement of Moggi's
seminal monadic point of view. There is a natural algebraic theory of the
constructors whose free algebra functor is Moggi's monad; we illustrate this by
characterising free and initial algebras in terms of two versions of the stable
failures model of CSP, one more general than the other. Deconstructors are
dealt with as homomorphisms to (possibly non-free) algebras.
One can view CSP's action and choice operators as constructors and the rest,
such as concealment and concurrency, as deconstructors. Carrying this programme
out results in taking deterministic external choice as constructor rather than
general external choice. However, binary deconstructors, such as the CSP
concurrency operator, provide unresolved difficulties. We conclude by
presenting a combination of CSP with Moggi's computational {\lambda}-calculus,
in which the operators, including concurrency, are polymorphic. While the paper
mainly concerns CSP, it ought to be possible to carry over similar ideas to
other process calculi
- …