741 research outputs found
Polymonadic Programming
Monads are a popular tool for the working functional programmer to structure
effectful computations. This paper presents polymonads, a generalization of
monads. Polymonads give the familiar monadic bind the more general type forall
a,b. L a -> (a -> M b) -> N b, to compose computations with three different
kinds of effects, rather than just one. Polymonads subsume monads and
parameterized monads, and can express other constructions, including precise
type-and-effect systems and information flow tracking; more generally,
polymonads correspond to Tate's productoid semantic model. We show how to equip
a core language (called lambda-PM) with syntactic support for programming with
polymonads. Type inference and elaboration in lambda-PM allows programmers to
write polymonadic code directly in an ML-like syntax--our algorithms compute
principal types and produce elaborated programs wherein the binds appear
explicitly. Furthermore, we prove that the elaboration is coherent: no matter
which (type-correct) binds are chosen, the elaborated program's semantics will
be the same. Pleasingly, the inferred types are easy to read: the polymonad
laws justify (sometimes dramatic) simplifications, but with no effect on a
type's generality.Comment: In Proceedings MSFP 2014, arXiv:1406.153
How functional programming mattered
In 1989 when functional programming was still considered a niche topic, Hughes wrote a visionary paper arguing convincingly ‘why functional programming matters’. More than two decades have passed. Has functional programming really mattered? Our answer is a resounding ‘Yes!’. Functional programming is now at the forefront of a new generation of programming technologies, and enjoying increasing popularity and influence. In this paper, we review the impact of functional programming, focusing on how it has changed the way we may construct programs, the way we may verify programs, and fundamentally the way we may think about programs
Localization and the interface between quantum mechanics, quantum field theory and quantum gravity I (The two antagonistic localizations and their asymptotic compatibility)
It is shown that there are significant conceptual differences between QM and
QFT which make it difficult to view the latter as just a relativistic extension
of the principles of QM. At the root of this is a fundamental distiction
between Born-localization in QM (which in the relativistic context changes its
name to Newton-Wigner localization) and modular localization which is the
localization underlying QFT, after one separates it from its standard
presentation in terms of field coordinates. The first comes with a probability
notion and projection operators, whereas the latter describes causal
propagation in QFT and leads to thermal aspects of locally reduced finite
energy states. The Born-Newton-Wigner localization in QFT is only applicable
asymptotically and the covariant correlation between asymptotic in and out
localization projectors is the basis of the existence of an invariant
scattering matrix. In this first part of a two part essay the modular
localization (the intrinsic content of field localization) and its
philosophical consequences take the center stage. Important physical
consequences of vacuum polarization will be the main topic of part II. Both
parts together form a rather comprehensive presentation of known consequences
of the two antagonistic localization concepts, including the those of its
misunderstandings in string theory.Comment: 63 pages corrections, reformulations, references adde
Runners in action
Runners of algebraic effects, also known as comodels, provide a mathematical
model of resource management. We show that they also give rise to a programming
concept that models top-level external resources, as well as allows programmers
to modularly define their own intermediate "virtual machines". We capture the
core ideas of programming with runners in an equational calculus
, which we equip with a sound and coherent
denotational semantics that guarantees the linear use of resources and
execution of finalisation code. We accompany with
examples of runners in action, provide a prototype language implementation in
OCaml, as well as a Haskell library based on .Comment: ESOP 2020 final version + online appendi
The modern landscape of managing effects for the working programmer
The management of side effects is a crucial aspect of modern programming, especially in concurrent and distributed systems. This thesis analyses different approaches for managing side effects in programming languages, specifically focusing on unrestricted side effects, monads, and algebraic effects and handlers. Unrestricted side effects, used in mainstream imperative programming languages, can make programs difficult to reason about. Monads offer a solution to this problem by describing side effects in a composable and referentially transparent way but many find them cumbersome to use. Algebraic effects and handlers can address some of the shortcomings of monads by providing a way to model effects in more modular and flexible way. The thesis discusses the advantages and disadvantages of each of these approaches and compares them based on factors such as expressiveness, safety, and constraints they place on how programs must be implemented. The thesis focuses on ZIO, a Scala library for concurrent and asynchronous programming, which revolves around a ZIO monad with three type parameters. With those three parameters ZIO can encode the majority of practically useful effects in a single monad. ZIO takes inspiration from algebraic effects, combining them with monadic effects. The library provides a range of features, such as declarative concurrency, error handling, and resource management. The thesis presents examples of using ZIO to manage side effects in practical scenarios, highlighting its strengths over other approaches. The applicability of ZIO is evaluated by implementing a server side application using ZIO, and analyzing observations from the development process
Scoped effects as parameterized algebraic theories
Notions of computation can be modelled by monads. Algebraic effects offer a characterization of monads in terms of algebraic
operations and equational axioms, where operations are basic programming features, such as reading or updating the state, and axioms specify
observably equivalent expressions. However, many useful programming
features depend on additional mechanisms such as delimited scopes or
dynamically allocated resources. Such mechanisms can be supported via
extensions to algebraic effects including scoped effects and parameterized algebraic theories. We present a fresh perspective on scoped effects
by translation into a variation of parameterized algebraic theories. The
translation enables a new approach to equational reasoning for scoped
effects and gives rise to an alternative characterization of monads in
terms of generators and equations involving both scoped and algebraic
operations. We demonstrate the power of our fresh perspective by way of
equational characterizations of several known models of scoped effects
Monadic Augment And Generalized Short Cut Fusion
Monads are commonplace programming devices that are used to uniformly structure computations;in particular, they are often used to mimic the effects of impure features suchas state, error handling, and I/O. This paper further develops the monadic programmingparadigm by investigating the extent to which monadic computations can be optimisedby using generalisations of short cut fusion to eliminate monadic structures whose solepurpose is to \glue together" monadic program components.Ghani, Uustalu, and Vene have recently shown that every inductive type has an associatedbuild combinator and an associated short cut fusion rule. They have also used thenotion of a parameterised monad to describe those monads that give rise to inductive types,and have shown that the standard augment combinators and cata/augment fusion rulesfor algebraic data types can be generalised to xed points of all parameterised monads.We revisit these augment combinators and generalised short cut fusion rules for such typesbut consider them from a functional programming perspective, rather than a categoricalone. In addition to making the category-theoretic ideas of Ghani, Uustalu, and Venemore easily accessible to a wider audience of functional programmers, we demonstratetheir practical applicability by developing nontrivial application programs and performingmodest benchmarking on them. We also show how the cata/augment rules can serve asthe basis for deriving additional generic fusion laws, thus opening the way for an algebraof fusion. Finally, we oer deep theoretical insights, arguing that the augment combinatorsare monadic in nature, and thus that the cata/build and cata/augment rules arearguably the best generally applicable fusion rules obtainable
Combining and Relating Control Effects and their Semantics
Combining local exceptions and first class continuations leads to programs
with complex control flow, as well as the possibility of expressing powerful
constructs such as resumable exceptions. We describe and compare games models
for a programming language which includes these features, as well as
higher-order references. They are obtained by contrasting methodologies: by
annotating sequences of moves with "control pointers" indicating where
exceptions are thrown and caught, and by composing the exceptions and
continuations monads.
The former approach allows an explicit representation of control flow in
games for exceptions, and hence a straightforward proof of definability (full
abstraction) by factorization, as well as offering the possibility of a
semantic approach to control flow analysis of exception-handling. However,
establishing soundness of such a concrete and complex model is a non-trivial
problem. It may be resolved by establishing a correspondence with the monad
semantics, based on erasing explicit exception moves and replacing them with
control pointers.Comment: In Proceedings COS 2013, arXiv:1309.092
- …