Monads for Behaviour

Maciej Piróg, Jeremy Gibbons
2013 Electronical Notes in Theoretical Computer Science  
The monads used to model effectful computations traditionally concentrate on the 'destination'-the final results of the program. However, sometimes we are also interested in the 'journey'-the intermediate course of a computation-especially when reasoning about non-terminating interactive systems. In this article we claim that a necessary property of a monad for it to be able to describe the behaviour of a program is complete iterativity. We show how an ordinary monad can be modified to disclose
more » ... more about its internal computational behaviour, by applying an associated transformer to a completely iterative monad. To illustrate this, we introduce two new constructions: a coinductive cousin of Cenciarelli and Moggi's generalised resumption transformer, and States-a State-like monad that accumulates the intermediate states. { properties of coproducts } M (id + gr ΣK 2 ) · M (id + gr ΣK 2 + id ΣK 2 ) · M (id + Ση K K + Σ(η K K · µ K ) + ΣKµ K ) · flat Id+ΣK,ΣK 2 +ΣK 3 · M (α + id ΣK 2 + id ΣK 3 ) · flat K+ΣK 2 ,ΣK 3 · M (α K + id ΣK 3 ) · α K 2
doi:10.1016/j.entcs.2013.09.019 fatcat:jbgafplr7jfjbgwania3lzrl6y