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.

[1]  N. D. Gautam The validity of equations of complex algebras , 1957, Arch. Math. Log..

[2]  Paul Hudak,et al.  Monad transformers and modular interpreters , 1995, POPL '95.

[3]  Philip Wadler,et al.  Glasgow Workshop on Functional Programming , 1992 .

[4]  A. Kock Bilinearity and Cartesian Closed Monads. , 1971 .

[5]  Philip S. Mulry,et al.  MONAD COMPOSITIONS I: GENERAL CONSTRUCTIONS AND RECURSIVE DISTRIBUTIVE LAWS , 2007 .

[6]  Jurriaan Rot,et al.  Presenting Distributive Laws , 2013, CALCO.

[7]  Alexander Katovsky,et al.  Category Theory , 2010, Arch. Formal Proofs.

[8]  Tetsuya Sato,et al.  The Giry monad is not strong for the canonical symmetric monoidal closed structure on Meas , 2018, Journal of Pure and Applied Algebra.

[9]  Eugenia Cheng,et al.  Distributive laws for Lawvere theories , 2020 .

[10]  Gordon D. Plotkin,et al.  Combining effects: Sum and tensor , 2006, Theor. Comput. Sci..

[11]  Philip Wadler,et al.  Combining Monads , 1992 .

[12]  Bartek Klin,et al.  Iterated Covariant Powerset is not a Monad , 2018, MFPS.

[13]  Stefan Milius,et al.  Complete Iterativity for Algebras with Effects , 2009, CALCO.

[14]  Aarnout Brombacher,et al.  Probability... , 2009, Qual. Reliab. Eng. Int..

[15]  Dominic R. Verity,et al.  ∞-Categories for the Working Mathematician , 2018 .

[16]  Alexandra Silva,et al.  The Power of Convex Algebras , 2017, CONCUR.

[17]  Alexandra Silva,et al.  Trace semantics via determinization , 2012, J. Comput. Syst. Sci..

[18]  Paul Hudak,et al.  Modular Denotational Semantics for Compiler Construction , 1996, ESOP.

[19]  Alexander Kurz,et al.  On coalgebras over algebras , 2011, Theor. Comput. Sci..

[20]  Dexter Kozen A Completeness Theorem for Kleene Algebras and the Algebra of Regular Events , 1994, Inf. Comput..

[21]  Alexandra Silva,et al.  Cantor meets Scott: semantic foundations for probabilistic networks , 2016, POPL.

[22]  Jurriaan Rot,et al.  Coalgebraic Trace Semantics via Forgetful Logics , 2015, FoSSaCS.

[23]  Alexandra Silva,et al.  A Coalgebraic Decision Procedure for NetKAT , 2015, POPL.

[24]  Bart Jacobs,et al.  Semantics of Weakening and Contraction , 1994, Ann. Pure Appl. Log..

[25]  A. Kock Strong functors and monoidal monads , 1972 .

[26]  Eugenio Moggi,et al.  Notions of Computation and Monads , 1991, Inf. Comput..

[27]  Alexandra Silva,et al.  Probabilistic NetKAT , 2016, ESOP.

[28]  Gordon D. Plotkin,et al.  Notions of Computation Determine Monads , 2002, FoSSaCS.

[29]  Gordon D. Plotkin,et al.  Combining algebraic effects with continuations , 2007, Theor. Comput. Sci..

[30]  John Power,et al.  Combining continuations with other effects , 2004 .

[31]  Daniele Varacca,et al.  Probability, Nondeterminism and Concurrency: Two Denotational Models for Probabilistic Computation , 2003 .

[32]  Nick Benton,et al.  Monads and Effects , 2000, APPSEM.

[33]  Ana Sokolova,et al.  Generic Trace Semantics via Coinduction , 2007, Log. Methods Comput. Sci..