类型、能力与效应系统:关于纯度、语义与表达力的视角
Type, Ability, and Effect Systems: Perspectives on Purity, Semantics, and Expressiveness
AI总结:
本文提出基于上下文等价的纯度语义定义,以完备性度量表达力,证明最小效应与能力系统不可比较,并综合类型、能力与效应系统以结合优势、避免弱点。
摘要:
编程受益于纯数学计算与不纯的、有副作用的世界交互之间的清晰分离。现有的强制这种分离的方法包括单子、类型与效应系统以及能力系统。所有这些方法都在精确性与可用性之间存在张力,且每种方法都有不明显的优缺点。本文旨在提高评估此类系统的标准。首先,我们提出一种受上下文等价启发的纯度语义定义,作为独立于任何特定类型规则的基线。其次,我们提出表达力应通过完备性程度来衡量,即有多少语义纯的项可以被类型化为纯的。使用这一度量,我们聚焦于最小有意义效应系统和能力系统,并证明它们是不可比较的,即在表达力上两者互不包含。基于这一结果,我们提出一种综合方案,表明类型、能力与效应系统结合了各自的优势,同时避免了各自的弱点。作为我们形式模型的一部分,我们提供了一个逻辑关系,以促进对各种效应类型规则下纯度及其他属性的证明。
英文摘要:
Programming benefits from a clear separation between pure, mathematical computation and impure, effectful interaction with the world. Existing approaches to enforce this separation include monads, type-and-effect systems, and capability systems. All share a tension between precision and usability, and each one has non-obvious strengths and weaknesses. This paper aims to raise the bar in assessing such systems. First, we propose a semantic definition of purity, inspired by contextual equivalence, as a baseline independent of any specific typing discipline. Second, we propose that expressiveness should be measured by the degree of completeness, i.e., how many semantically pure terms can be typed as pure. Using this measure, we focus on minimal meaningful effect and capability systems and show that they are incomparable, i.e., neither subsumes the other in terms of expressiveness. Based on this result, we propose a synthesis and show that type, ability, and effect systems combine their respective strengths while avoiding their weaknesses. As part of our formal model, we provide a logical relation to facilitate proofs of purity and other properties for a variety of effect typing disciplines.
机构、总结、中文摘要均由AI分析而来,可能存在错误,请以论文正文为准。