We study a model of side-effecting processes obtained by starting from a monad modelling base effects and adjoining free operations using a cofree coalgebra construction; one thus arrives at what one may think of as types of non-wellfounded side-effecting trees, generalizing the infinite resumption monad. Correspondingly, the arising monad transformer has been termed the coinductive generalized resumption transformer. Monads of this kind have received some attention in the recent literature; in particular, it has been shown that they admit guarded iteration. Here, we show that they also admit unguarded iteration, i.e. form complete Elgot monads, provided that the underlying base effect supports unguarded iteration. Moreover, we provide a universal characterization of the coinductive resumption monad transformer in terms of coproducts of complete Elgot monads.T Σ X = νγ. T (X + Σγ) for each object X, assuming enough structure on T , Σ, and the base category. Inhabitants of T Σ X are understood as (possibly) nonterminating processes that proceed in steps, where each step produces side-effects specified by T (e.g. writing to shared global memory, nondeterminism) and performs communication actions specified by Σ. E.g. in the simplest case, Σ is of the form a × (−) b , which may be understood as reading inputs of type b and writing outputs of type a.
CC
Creative Commons2 GONCHAROV, RAUCH, SCHRÖDER, AND JAKOB UNGUARDED RECURSION ON COINDUCTIVE RESUMPTIONS 3Section 5, and recall the coinductive generalized resumption transformer in Section 6, showing in particular that it preserves strength. Sections 7 and 8 contain our main results, showing that the coinductive generalized resumption transformer preserves complete Elgotness and can be seen as freely extending complete Elgot monads with communication actions. We discuss related work in Section 9, and conclude in Section 10.
Example: Unrestricted While LoopsWe proceed to discuss examples, aimed mainly at illustrating the benefits of not being restricted to guarded equations in recursive definitions thanks to complete Elgotness of coinductive resumption monads (Theorem 7.1). We work with the intuitive understanding of monads, T Σ , guardedness, and complete iterativity provided in the introduction, and briefly explain the requisite categorical notation regarding strong monads and distributive categories along the way, deferring a more formal treatment to Sections 4 and 6.Our first example is a simple while-language with actions proposed by Rutten, given by the grammar P, Q : and, following Piróg and Gibbons [32], interpreted in the Kleisli category of a monad M. Here, A ranges over atomic actions interpreted as Kleisli morphisms A : n → M n for some fixed object n, and b over atomic predicates, interpreted as Kleisli morphisms b : n → M (1 + 1) (where we read the left-hand summand as 'false' and the right-hand one as 'true', and 1 denotes the terminal object). We say that A is of output type if A : n → M n has the form A = (M fst) τ id n , p for some p : n → M 1, where fs...