arXivDaily arXiv每日学术速递 周一至周五更新
arXiv周末暂无论文更新,休息一下吧,周末愉快~~
arXiv 2304.09697cs.PL
收藏

作用域效应与处理程序的演算

A Calculus for Scoped Effects & Handlers

Roger Bosman, Birthe van den Berg, Wenhao Tang, Tom Schrijvers

AI总结:

针对函数式编程中作用域效应缺乏原生支持的问题,提出λₛc演算,原生支持代数与作用域效应及处理程序,扩展行多态性并提供多态处理程序和显式子句,填补了相关演算空白。

摘要:

代数效应与处理程序已成为函数式编程中处理副作用的标准方法,其与其他效应的模块化组合以及语法与语义的清晰分离使其吸引了广泛受众。然而,并非所有效应都可归类为代数效应;部分效应需要更复杂的处理。特别是具有或创建限定作用域的效应需要特殊处理,因为它们的延续由作用域内和作用域外两部分组成,且其模块化组合会引入额外复杂性。这些效应被称为作用域效应,因其适用性不断提升并被主流库采用而受到关注。尽管已有内置代数效应与处理程序的演算以方便其使用,但类似地支持作用域效应与处理程序的演算尚不存在。本工作填补了这一空白:提出λₛc演算,原生支持代数与作用域效应及处理程序,满足多态处理程序需求,并为将未知作用域操作转发至其他处理程序提供显式子句。该演算基于现有代数效应演算Eff,扩展Koka风格的行多态性,包含形式语法、操作语义、(类型安全的)类型-效应系统及类型推断,我们通过一系列示例展示了λₛc的效果。

英文摘要:

Algebraic effects & handlers have become a standard approach for side-effects in functional programming. Their modular composition with other effects and clean separation of syntax and semantics make them attractive to a wide audience. However, not all effects can be classified as algebraic; some need a more sophisticated handling. In particular, effects that have or create a delimited scope need special care, as their continuation consists of two parts-in and out of the scope-and their modular composition introduces additional complexity. These effects are called scoped and have gained attention by their growing applicability and adoption in popular libraries. While calculi have been designed with algebraic effects & handlers built in to facilitate their use, a calculus that supports scoped effects & handlers in a similar manner does not yet exist. This work fills this gap: we present $λ_{\mathit{sc}}$, a calculus with native support for both algebraic and scoped effects & handlers. It addresses the need for polymorphic handlers and explicit clauses for forwarding unknown scoped operations to other handlers. Our calculus is based on Eff, an existing calculus for algebraic effects, extended with Koka-style row polymorphism, and consists of a formal grammar, operational semantics, a (type-safe) type-and-effect system and type inference. We demonstrate $λ_{\mathit{sc}}$ on a range of examples.

机构、总结、中文摘要均由AI分析而来,可能存在错误,请以论文正文为准。

↑