Wenhao Tang, Leo White, Stephen Dolan, Daniel Hillerström, Sam Lindley, Anton Lorenzen
{"title":"模态效果类型","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":"20 1","pages":""},"PeriodicalIF":0.0000,"publicationDate":"2024-07-16","publicationTypes":"Journal Article","fieldsOfStudy":null,"isOpenAccess":false,"openAccessPdf":"","citationCount":"0","resultStr":"{\"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\":\"20 1\",\"pages\":\"\"},\"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}","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
摘要
传统的效果系统将效果附加到函数类型上,这会导致冗长的效果多态类型,尤其是对高阶函数而言。我们的模态效果系统为高阶一阶函数提供了简洁的类型,同时又不失模块性和可重用性。其核心思想是将效果与函数类型分离开来,而是通过相关模态和绝对模态来跟踪效果,这些模态表示上下文所提供的环境效果的变换。我们将模态效果类型的想法正式化为具有效果和处理程序的多模态系统 F 风格核心微积分 Met。Met 支持通过模态进行模块化效果编程,而无需依赖效果变量。我们将传统的基于行的效果系统的一个实用片段编码到 Met 中,该片段具有效果多态性,可以捕捉到最常见的用例,从而从形式上展示了模态效果类型的表现力。为了在此片段之外恢复传统效果系统的全部功能,我们将 Met 无缝扩展为带有效果变量的 Mete。我们为 Mete 提出了一种表面语言 Metelfor,它具有受 FreezeML 启发的健全而完整的类型推断算法。
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.