Adequacy for Algebraic Effects with State
In previous work we gave an operational semantics and adequacy theorem for algebraic effects in programming languages. This covered finitary algebraic operations, thereby accommodating ordinary and probabilistic nondeterminism, output, and exceptions (but without handling), together with their combinations. With some extra effort, infinitary operations can also be covered, thereby also accommodating input and state. However one does not thereby obtain the natural operational semantics for state, which employs configurations of programs and states. We propose instead to consider the natural coalgebra of states given by the update and lookup operations; this coalgebra is the final comodel of the Lawvere theory for state. We therefore give an account integrating coalgebras given by comodels of Lawvere theories into the algebraic theory of effects. The coalgebras are used for the dynamics of the state component of the configurations.