arXivDaily arXiv每日学术速递 周一至周五更新
arXiv 1406.2060cs.PL
收藏

多项式规划

Polymonadic Programming

Michael Hicks, Gavin Bierman, Nataliya Guts, Daan Leijen, Nikhil Swamy

摘要:

Monad是函数式程序员构建有效计算的流行工具。本文提出了多单子,单子的推广。对于所有的a,b,多项式给出了熟悉的一元绑定的更一般的类型。L a ->(a -> M b)-> N b,以组合具有三种不同类型效应的计算,而不仅仅是一种。Polymonads子结构monads和参数化monads,并可以表达其他结构,包括精确的类型和效果系统和信息流跟踪;更一般地说,polymonads对应于泰特的productoid语义模型。我们将展示如何装备一个核心语言(称为Pendida-PM)的语法支持编程与polymonads。类型推断和精心制作在MLDA-PM允许程序员直接编写多元代码在ML类语法-我们的算法计算主要类型,并产生详细的程序,其中绑定显式出现。此外,我们证明了阐述是连贯的:无论选择哪种(类型正确)绑定,阐述程序的语义将是相同的。令人高兴的是,推断出的类型很容易阅读:多元单子定律证明了(有时是戏剧性的)简化,但对类型的一般性没有影响。

英文摘要:

Monads are a popular tool for the working functional programmer to structure effectful computations. This paper presents polymonads, a generalization of monads. Polymonads give the familiar monadic bind the more general type forall a,b. L a -> (a -> M b) -> N b, to compose computations with three different kinds of effects, rather than just one. Polymonads subsume monads and parameterized monads, and can express other constructions, including precise type-and-effect systems and information flow tracking; more generally, polymonads correspond to Tate's productoid semantic model. We show how to equip a core language (called lambda-PM) with syntactic support for programming with polymonads. Type inference and elaboration in lambda-PM allows programmers to write polymonadic code directly in an ML-like syntax--our algorithms compute principal types and produce elaborated programs wherein the binds appear explicitly. Furthermore, we prove that the elaboration is coherent: no matter which (type-correct) binds are chosen, the elaborated program's semantics will be the same. Pleasingly, the inferred types are easy to read: the polymonad laws justify (sometimes dramatic) simplifications, but with no effect on a type's generality.

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

↑