A Categorical Model for Stateful Stream Programming

We define key constructions to mix context and stateful computations in the aim of providing a compositional semantics for stateful stream functions. We mechanize the construction of this model of computation by leveraging the Yang-Baxter equation to define new distributive laws between monads and comonads, extending the result of Uustalu and Vene to the case of a distributive law of the listval comonad over the stateoption monad. We justify our construction with the proof of a no-go theorem for the distributive law of the nonempty list comonad over the state monad. We give a computational interpretation, and use the Kleisli category of the resulting distributive law to define a semantics for a minimal yet powerful calculus of imperative stream processing functions. Along the way, we provide illustrative examples to clarify key concepts of the calculus and demonstrate the applicability of its formalization in a stateful implementation of the infinite sieve of Eratosthenes using the Rocq proof assistant.

Data and Resources

Additional Info

Field Value
Source https://inria.hal.science/hal-05451358
Author Lion, Benjamin, Nowak, David, Talpin, Jean-Pierre
Maintainer CCSD
Last Updated November 29, 2026, 11:31 (UTC)
Created November 29, 2026, 11:31 (UTC)
Identifier hal-05451358
Language en
Rights https://creativecommons.org/licenses/by/4.0/
contributor Centre Inria de l'Université de Rennes ; Institut National de Recherche en Informatique et en Automatique (Inria)
creator Lion, Benjamin
date 2026-11-29T00:00:00
harvest_object_id 13c7f162-9665-4cd5-b7dc-84c7109feba6
harvest_source_id 3374d638-d20b-4672-ba96-a23232d55657
harvest_source_title test moissonnage SELUNE
metadata_modified 2026-04-29T00:00:00
set_spec type:UNDEFINED