Modal Effect Types

Wenhao Tang, Leo White, Stephen Dolan, Daniel Hillerström, Sam Lindley, Anton Lorenzen
{"title":"Modal Effect Types","authors":"Wenhao Tang, Leo White, Stephen Dolan, Daniel Hillerström, Sam Lindley, Anton Lorenzen","doi":"arxiv-2407.11816","DOIUrl":null,"url":null,"abstract":"We propose a novel type system for effects and handlers using modal types.\nConventional effect systems attach effects to function types, which can lead to\nverbose effect-polymorphic types, especially for higher-order functions. Our\nmodal effect system provides succinct types for higher-order first-class\nfunctions without losing modularity and reusability. The core idea is to\ndecouple effects from function types and instead to track effects through\nrelative and absolute modalities, which represent transformations on the\nambient effects provided by the context. We formalise the idea of modal effect types in a multimodal System F-style\ncore calculus Met with effects and handlers. Met supports modular effectful\nprogramming via modalities without relying on effect variables. We encode a\npractical fragment of a conventional row-based effect system with effect\npolymorphism, which captures most common use-cases, into Met in order to\nformally demonstrate the expressive power of modal effect types. To recover the\nfull power of conventional effect systems beyond this fragment, we seamlessly\nextend Met to Mete with effect variables. We propose a surface language Metel\nfor Mete with a sound and complete type inference algorithm inspired by\nFreezeML.","PeriodicalId":501197,"journal":{"name":"arXiv - CS - Programming Languages","volume":null,"pages":null},"PeriodicalIF":0.0000,"publicationDate":"2024-07-16","publicationTypes":"Journal Article","fieldsOfStudy":null,"isOpenAccess":false,"openAccessPdf":"","citationCount":"0","resultStr":null,"platform":"Semanticscholar","paperid":null,"PeriodicalName":"arXiv - CS - Programming Languages","FirstCategoryId":"1085","ListUrlMain":"https://doi.org/arxiv-2407.11816","RegionNum":0,"RegionCategory":null,"ArticlePicture":[],"TitleCN":null,"AbstractTextCN":null,"PMCID":null,"EPubDate":"","PubModel":"","JCR":"","JCRName":"","Score":null,"Total":0}
引用次数: 0

Abstract

We propose a novel type system for effects and handlers using modal types. Conventional effect systems attach effects to function types, which can lead to verbose effect-polymorphic types, especially for higher-order functions. Our modal effect system provides succinct types for higher-order first-class functions without losing modularity and reusability. The core idea is to decouple effects from function types and instead to track effects through relative and absolute modalities, which represent transformations on the ambient effects provided by the context. We formalise the idea of modal effect types in a multimodal System F-style core calculus Met with effects and handlers. Met supports modular effectful programming via modalities without relying on effect variables. We encode a practical fragment of a conventional row-based effect system with effect polymorphism, which captures most common use-cases, into Met in order to formally demonstrate the expressive power of modal effect types. To recover the full power of conventional effect systems beyond this fragment, we seamlessly extend Met to Mete with effect variables. We propose a surface language Metel for Mete with a sound and complete type inference algorithm inspired by FreezeML.
模态效果类型
传统的效果系统将效果附加到函数类型上,这会导致冗长的效果多态类型,尤其是对高阶函数而言。我们的模态效果系统为高阶一阶函数提供了简洁的类型,同时又不失模块性和可重用性。其核心思想是将效果与函数类型分离开来,而是通过相关模态和绝对模态来跟踪效果,这些模态表示上下文所提供的环境效果的变换。我们将模态效果类型的想法正式化为具有效果和处理程序的多模态系统 F 风格核心微积分 Met。Met 支持通过模态进行模块化效果编程,而无需依赖效果变量。我们将传统的基于行的效果系统的一个实用片段编码到 Met 中,该片段具有效果多态性,可以捕捉到最常见的用例,从而从形式上展示了模态效果类型的表现力。为了在此片段之外恢复传统效果系统的全部功能,我们将 Met 无缝扩展为带有效果变量的 Mete。我们为 Mete 提出了一种表面语言 Metelfor,它具有受 FreezeML 启发的健全而完整的类型推断算法。
本文章由计算机程序翻译,如有差异,请以英文原文为准。
求助全文
约1分钟内获得全文 求助全文
来源期刊
自引率
0.00%
发文量
0
×
引用
GB/T 7714-2015
复制
MLA
复制
APA
复制
导出至
BibTeX EndNote RefMan NoteFirst NoteExpress
×
提示
您的信息不完整,为了账户安全,请先补充。
现在去补充
×
提示
您因"违规操作"
具体请查看互助需知
我知道了
×
提示
确定
请完成安全验证×
copy
已复制链接
快去分享给好友吧!
我知道了
右上角分享
点击右上角分享
0
联系我们:info@booksci.cn Book学术提供免费学术资源搜索服务,方便国内外学者检索中英文文献。致力于提供最便捷和优质的服务体验。 Copyright © 2023 布克学术 All rights reserved.
京ICP备2023020795号-1
ghs 京公网安备 11010802042870号
Book学术文献互助
Book学术文献互助群
群 号:481959085
Book学术官方微信