Layer by layer - Combining Monads
Fredrik Dahlqvist, Louis Parlant, Alexandra Silva

TL;DR
This paper presents a categorical method for incrementally constructing programming languages by layering monads, including techniques for building distributive laws or identifying obstacles, demonstrated through imperative, non-deterministic, and probabilistic layers.
Contribution
It introduces a systematic approach to compose language layers via monads, addressing algebraic obstacles and providing approximant languages when direct composition is not possible.
Findings
Seamless composition of imperative and non-deterministic layers
Identification of obstacles in combining probabilistic choice with other layers
Development of a best approximant language similar to ProbNetKAT
Abstract
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.
Peer Reviews
No public reviews on file for this paper yet. If you reviewed it on a platform where reviews are public (OpenReview, ICLR, NeurIPS, ICML), you can paste yours below so the community can read it here.
Videos
No videos yet. Explain this paper in a talk, walkthrough, or lecture? Add one.
