一种面向顺序与并行程序的直接风格效应表示法
A Direct-Style Effect Notation for Sequential and Parallel Programs
AI总结:
针对现有效应表示法无法兼顾顺序与并行效应、不支持直接风格调用的问题,本文提出混合应用函子/单子的直接风格效应表示法,并通过Coq机械化验证其编译可保留源程序并行性。
摘要:
长期以来,学界已在多种编程语言中研究了带效应计算的顺序与并行组合建模问题。其中,流行的do-notation(do表示法)可为任意单子实例提供轻量级的效应嵌入,而Idiom bracket notation(习语括号表示法)则为应用函子提供嵌入。首先,单子强制效应按顺序执行,忽略了并行化潜力,而应用函子不支持顺序效应。如何组合顺序与并行效应仍是一个开放问题,由于实际程序由顺序和并行片段混合构成,这一问题愈发突出。其次,现有常用表示法不支持以直接风格调用效应,反而给代码强加了僵化的结构。\n本文提出一种混合的应用函子/单子表示法,它在可行时保留并行性,同时在必要时允许顺序性。我们采用直接风格表示法,其顺序性或并行性可从代码结构中推导得出。我们在Coq中对该带效应语言进行了机械化建模,并证明我们的编译方法能够保留源程序的并行性。
英文摘要:
Modeling sequential and parallel composition of effectful computations has been investigated in a variety of languages for a long time. In particular, the popular do-notation provides a lightweight effect embedding for any instance of a monad. Idiom bracket notation, on the other hand, provides an embedding for applicatives. First, while monads force effects to be executed sequentially, ignoring potential for parallelism, applicatives do not support sequential effects. Composing sequential with parallel effects remains an open problem. This is even more of an issue as real programs consist of a combination of both sequential and parallel segments. Second, common notations do not support invoking effects in direct-style, instead forcing a rigid structure upon the code. In this paper, we propose a mixed applicative/monadic notation that retains parallelism where possible, but allows sequentiality where necessary. We leverage a direct-style notation where sequentiality or parallelism is derived from the structure of the code. We provide a mechanisation of our effectful language in Coq and prove that our compilation approach retains the parallelism of the source program.
机构、总结、中文摘要均由AI分析而来,可能存在错误,请以论文正文为准。