论文标题
语言集成查询的光学器件
The Optics of Language-Integrated Query
论文作者
论文摘要
Monadic综合统治着语言集成查询(LINQ)的领域,这是有充分理由的。实际上,综合与通用编程语言紧密地集成在一起,并与SQL等通用查询语言足够近,以确保其翻译成有效的查询。综合还支持编写可重复使用和组合查询的功能,例如处理嵌套数据和功能抽象的使用。与这些事态发展并联,近年来,光学技术已成为编写程序的选择技术,该程序可以用嵌套组件操纵复杂的数据结构。光学抽象很容易组合,并且原则上允许数据访问和更新。本文试图利用LINQ的光学概念为一种补充基于理解的方法的高级语言。为了做到这一点,我们将光学限制的子集(即getters,offine折叠和折叠)提起到成熟的DSL中。我们命名为Optica的光学语言的类型系统,蒸馏出它们的组成属性,而其代表语义是由标准光学器件提供的。 Optic概念的正式规范可以使范拉霍芬(Van Laarhoven),分配器光学等非标准光学表示形式的定义尤其是XQUERY的限制子集可以将其视为光学表示;它引入了三胞胎,这是一个非标准的语义域,可将视神经表达式标准化并促进SQL查询的产生;它描述了如何从光学表达式中生成基于理解的查询,从而表明两种方法都可以共存。本文还描述了S-Optica,这是使用无标记的最终方法的Scala实现Optica的实现。
Monadic comprehensions reign over the realm of language-integrated query (LINQ), and for good reasons. Indeed, comprehensions are tightly integrated with general purpose programming languages and close enough to common query languages, such as SQL, to guarantee their translation into effective queries. Comprehensions also support features for writing reusable and composable queries, such as the handling of nested data and the use of functional abstractions. In parallel to these developments, optics have emerged in recent years as the technology of choice to write programs that manipulate complex data structures with nested components. Optic abstractions are easily composable and, in principle, permit both data access and updates. This paper attempts to exploit the notion of optic for LINQ as a higher-level language that complements comprehension-based approaches. In order to do this, we lift a restricted subset of optics, namely getters, affine folds and folds, into a full-blown DSL. The type system of the resulting language of optics, that we have named Optica, distills their compositional properties, whereas its denotational semantics is given by standard optics. This formal specification of the concept of optic enables the definition of non-standard optic representations beyond van Laarhoven, profunctor optics, etc. In particular, the paper demonstrates that a restricted subset of XQuery can be understood as an optic representation; it introduces Triplets, a non-standard semantic domain to normalize optic expressions and facilitate the generation of SQL queries; and it describes how to generate comprehension-based queries from optic expressions, thus showing that both approaches can coexist.The paper also describes S-Optica, a Scala implementation of Optica using the tagless-final approach.