arXivDaily arXiv每日学术速递 周一至周五更新
感恩节,周五至周末无更新,大家顺遂。周一再来吧
arXiv 1905.10728cs.PLcs.LOcs.SE
收藏

使用类应用程序表达式编程

Programming with Applicative-like expressions

Jan Malakhovski, Sergei Soloviev

摘要:

事实上,Application类型类允许人们以无变量的组合风格来表达简单的解析器,这在Haskell程序员中很受欢迎,因为它的概念简单,易于使用,以及对于半自动代码生成(元编程)的有用性。我们注意到,这样的应用计算可以被解释为提供一种机制,通过子计算来构造具有“端口”“可插入”的数据类型。我们观察到,正是这个属性使它们在实践中比使用传统合成构建相同计算的通常方式更加方便。我们将这种观察提炼成一个更一般的代数结构(和/或表达技术)“类应用”计算,并演示了这种结构的其他几个实例。我们之所以对所有这些感兴趣,是因为上述实例允许我们在单个构造函数的简单数据类型之间表示任意转换(类似于应用解析如何允许从字符流变换到这样的数据类型)使用紧密遵循常规应用计算的样式,因此极大地简化了(如果不是完全自动化的话)许多函数程序中存在的大量样板代码。

英文摘要:

The fact that Applicative type class allows one to express simple parsers in a variable-less combinatorial style is well appreciated among Haskell programmers for its conceptual simplicity, ease of use, and usefulness for semi-automated code generation (metaprogramming). We notice that such Applicative computations can be interpreted as providing a mechanism to construct a data type with "ports" "pluggable" by subcomputations. We observe that it is this property that makes them so much more convenient in practice than the usual way of building the same computations using conventional composition. We distill this observation into a more general algebraic structure of (and/or technique for expressing) "Applicative-like" computations and demonstrate several other instances of this structure. Our interest in all of this comes from the fact that the aforementioned instances allow us to express arbitrary transformations between simple data types of a single constructor (similarly to how Applicative parsing allows to transform from streams of Chars to such data types) using a style that closely follows conventional Applicative computations, thus greatly simplifying (if not completely automating away) a lot of boiler-plate code present in many functional programs.

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

↑