๐ค AI Summary
This paper addresses the lack of composability in monadic containers by systematically characterizing distributive laws between themโensuring their composition retains monadic structure. Using category theory and container theory, it establishes, for the first time, structured necessary and sufficient conditions for the existence and uniqueness of distributive laws between monadic containers. The work provides a complete classification โzooโ unifying distributive laws for monadic containers, comonadic containers, and their mutual interactions. All core results are fully formalized and verified in Cubical Agda. This advances the theory of verifiable distributive laws for higher-order algebraic data types, filling a foundational gap in the modular composition of computational effects in functional programming. It delivers a rigorous algebraic and formal foundation for effectful program composition.
๐ Abstract
Containers are used to carve out a class of strictly positive data types in terms of shapes and positions. They can be interpreted via a fully-faithful functor into endofunctors on Set. Monadic containers are those containers whose interpretation as a Set functor carries a monad structure. The category of containers is closed under container composition and is a monoidal category, whereas monadic containers do not in general compose. In this paper, we develop a characterisation of distributive laws of monadic containers. Distributive laws were introduced as a sufficient condition for the composition of the underlying functors of two monads to also carry a monad structure. Our development parallels Ahman and Uustalu's characterisation of distributive laws of directed containers, i.e. containers whose Set functor interpretation carries a comonad structure. Furthermore, by combining our work with theirs, we construct characterisations of mixed distributive laws (i.e. of directed containers over monadic containers and vice versa), thereby completing the 'zoo' of container characterisations of (co)monads and their distributive laws. We have found these characterisations amenable to development of existence and uniqueness proofs of distributive laws, particularly in the mechanised setting of Cubical Agda, in which most of the theory of this paper has been formalised.