This paper provides a mathematical framework for client-server communication that results in a modular and type-safe architecture. It is informed and motivated by the software engineering practice of developing server backends with a database layer and a frontend, all of which communicate with a notion of request/response. I make use of dependent types to ensure the request/response relation matches and show how this idea fits in the broader context of containers and their morphisms. Using the category of containers and their monoidal products, I define monads on containers that mimic their functional programming counterparts, and using the Kleene star, I describe stateful protocols in the same system.
翻译:本文提出了一种用于客户端-服务器通信的数学框架,该框架可形成模块化且类型安全的体系结构。其设计理念源于软件开发实践中常见的三层架构模式:包含数据库层的服务器后端与前端通过请求/响应机制进行通信。本文利用依值类型确保请求/响应关系的匹配性,并论证该思想如何融入容器及其态射的广义理论框架。通过构建容器范畴及其幺半积,定义了模拟函数式编程对应物的容器单子,并借助克林星算子在同一系统中描述了状态化协议。