Equational Theories and Monads from Polynomial Cayley Representations [chapter]

Maciej Piróg, Piotr Polesiuk, Filip Sieczkowski
2019 Green Chemistry and Sustainable Technology  
We generalise Cayley's theorem for monoids by providing an explicit formula for a (multi-sorted) equational theory represented by the type P X → X, where P is an arbitrary polynomial endofunctor with natural coefficients. From the computational perspective, examples of effects given by such theories include backtracking nondeterminism (obtained with the original Cayley representation X → X), finite mutable state (obtained with n → X, for a constant n), and their different combinations (via n ×
more » ... → X or X n → X). Moreover, we show that monads induced by such theories are implementable using the type formers available in programming languages based on a polymorphic λ-calculus, both as compositions of algebraic datatypes and as continuation-like monads. We give a set-theoretic model of the latter in terms of Barr-dinatural transformations. We also introduce CayMon, a tool that takes a polynomial as an input and generates the corresponding equational theory together with the two implementations of the induced monad in Haskell.
doi:10.1007/978-3-030-17127-8_26 dblp:conf/fossacs/PirogPS19 fatcat:5v6j3zvhxfe3rcuuj7r5wiu2wu