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 $\lambda_{\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 $\lambda_{\mathit{sc}}$ on a range of examples.


翻译:代数效应和处理程序已成为函数式编程中处理副作用的一种标准方法。其与其他效应的模块化组合以及语法和语义的清晰分离使它们受到了广泛的关注。然而,并非所有效应都可以被归类为代数效应;有些需要更为复杂的处理。特别是涉及到限定作用域的效应需要特别关注,因为它们的 continuation 由作用域内外两部分组成,并且它们的模块化组合会引入额外的复杂度。这些效应称为 scoped,由于它们在热门库中的适用性和采用率的增长而受到越来越多的关注。虽然已经设计了带有代数效应和处理程序的计算机体系结构,以便于它们的使用,但是还没有类似的支持 scoped effects & handlers 的计算机体系。本文填补了这一空白:我们提出了一个名为 $\lambda_{\mathit{sc}}$ 的计算机体系,该体系原生支持代数效应和 scoped effects & handlers。它解决了支持多态处理程序所需的问题,并明确指定了将未知的 scoped 操作转发给其他处理程序的子句。我们的计算机体系基于 Eff,这是一种代数效应的现有计算机体系,通过 Koka 风格的行多态性进行了扩展,并包括正式语法、操作语义、(类型安全的)类型和效应系统以及类型推导。我们在一系列示例中演示了 $\lambda_{\mathit{sc}}$。

0
下载
关闭预览

相关内容

SC:International Conference for High Performance Computing, Networking, Storage, and Analysis。 Explanation:高性能计算、网络、存储和分析国际会议。 Publisher:IEEE。 SIT: http://dblp.uni-trier.de/db/conf/sc/
【干货书】微积分,第12版
专知会员服务
62+阅读 · 2023年2月17日
不可错过!700+ppt《因果推理》课程!杜克大学Fan Li教程
专知会员服务
68+阅读 · 2022年7月11日
【硬核书】矩阵代数基础,248页pdf
专知会员服务
81+阅读 · 2021年12月9日
【干货书】开放数据结构,Open Data Structures,337页pdf
专知会员服务
16+阅读 · 2021年9月17日
VCIP 2022 Call for Demos
CCF多媒体专委会
1+阅读 · 2022年6月6日
Hierarchically Structured Meta-learning
CreateAMind
23+阅读 · 2019年5月22日
强化学习的Unsupervised Meta-Learning
CreateAMind
17+阅读 · 2019年1月7日
A Technical Overview of AI & ML in 2018 & Trends for 2019
待字闺中
16+阅读 · 2018年12月24日
【推荐】深度学习目标检测全面综述
机器学习研究会
21+阅读 · 2017年9月13日
国家自然科学基金
0+阅读 · 2015年12月31日
国家自然科学基金
0+阅读 · 2015年12月31日
国家自然科学基金
0+阅读 · 2013年12月31日
国家自然科学基金
0+阅读 · 2013年12月31日
国家自然科学基金
0+阅读 · 2013年12月31日
国家自然科学基金
1+阅读 · 2012年12月31日
国家自然科学基金
0+阅读 · 2009年12月31日
国家自然科学基金
0+阅读 · 2009年12月31日
Arxiv
0+阅读 · 2023年6月5日
Arxiv
0+阅读 · 2023年6月2日
Arxiv
0+阅读 · 2023年6月2日
Arxiv
0+阅读 · 2023年6月2日
Arxiv
0+阅读 · 2023年6月2日
VIP会员
相关基金
国家自然科学基金
0+阅读 · 2015年12月31日
国家自然科学基金
0+阅读 · 2015年12月31日
国家自然科学基金
0+阅读 · 2013年12月31日
国家自然科学基金
0+阅读 · 2013年12月31日
国家自然科学基金
0+阅读 · 2013年12月31日
国家自然科学基金
1+阅读 · 2012年12月31日
国家自然科学基金
0+阅读 · 2009年12月31日
国家自然科学基金
0+阅读 · 2009年12月31日
Top
微信扫码咨询专知VIP会员