4,154 research outputs found
Layer by layer - Combining Monads
We develop a method to incrementally construct programming languages. Our
approach is categorical: each layer of the language is described as a monad.
Our method either (i) concretely builds a distributive law between two monads,
i.e. layers of the language, which then provides a monad structure to the
composition of layers, or (ii) identifies precisely the algebraic obstacles to
the existence of a distributive law and gives a best approximant language. The
running example will involve three layers: a basic imperative language enriched
first by adding non-determinism and then probabilistic choice. The first
extension works seamlessly, but the second encounters an obstacle, which
results in a best approximant language structurally very similar to the
probabilistic network specification language ProbNetKAT
Distributive laws for Lawvere theories
Distributive laws give a way of combining two algebraic structures expressed
as monads; in this paper we propose a theory of distributive laws for combining
algebraic structures expressed as Lawvere theories. We propose four approaches,
involving profunctors, monoidal profunctors, an extension of the free
finite-product category 2-monad from Cat to Prof, and factorisation systems
respectively. We exhibit comparison functors between CAT and each of these new
frameworks to show that the distributive laws between the Lawvere theories
correspond in a suitable way to distributive laws between their associated
finitary monads. The different but equivalent formulations then provide,
between them, a framework conducive to generalisation, but also an explicit
description of the composite theories arising from distributive laws.Comment: 30 pages, presented at CT2011, lightly edited 2019 for publication in
Compositionalit
Constructing applicative functors
Applicative functors define an interface to computation that is more general, and correspondingly weaker, than that of monads. First used in parser libraries, they are now seeing a wide range of applications. This paper sets out to explore the space of non-monadic applicative functors useful in programming. We work with a generalization, lax monoidal functors, and consider several methods of constructing useful functors of this type, just as transformers are used to construct computational monads. For example, coends, familiar to functional programmers as existential types, yield a range of useful applicative functors, including left Kan extensions. Other constructions are final fixed points, a limited sum construction, and a generalization of the semi-direct product of monoids. Implementations in Haskell are included where possible
Exploring the Boundaries of Monad Tensorability on Set
We study a composition operation on monads, equivalently presented as large
equational theories. Specifically, we discuss the existence of tensors, which
are combinations of theories that impose mutual commutation of the operations
from the component theories. As such, they extend the sum of two theories,
which is just their unrestrained combination. Tensors of theories arise in
several contexts; in particular, in the semantics of programming languages, the
monad transformer for global state is given by a tensor. We present two main
results: we show that the tensor of two monads need not in general exist by
presenting two counterexamples, one of them involving finite powerset (i.e. the
theory of join semilattices); this solves a somewhat long-standing open
problem, and contrasts with recent results that had ruled out previously
expected counterexamples. On the other hand, we show that tensors with bounded
powerset monads do exist from countable powerset upwards
- …