当前位置: X-MOL 学术arXiv.cs.PL › 论文详情
Our official English website, www.x-mol.net, welcomes your feedback! (Note: you will need to create a separate account there.)
The Optics of Language-Integrated Query
arXiv - CS - Programming Languages Pub Date : 2020-09-02 , DOI: arxiv-2009.00997
J. L\'opez-Gonz\'alez, Juan M. Serrano

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.

中文翻译:

语言集成查询的光学

Monadic Comprehension 统治了语言集成查询 (LINQ) 领域,这是有充分理由的。实际上,推导式与通用编程语言紧密集成,并且与常见的查询语言(例如 SQL)足够接近,以保证将其转换为有效的查询。推导式还支持编写可重用和可组合查询的功能,例如处理嵌套数据和使用功能抽象。与这些发展并行的是,近年来,光学已成为编写使用嵌套组件处理复杂数据结构的程序的首选技术。光学抽象很容易组合,并且原则上允许数据访问和更新。本文试图将 LINQ 的光学概念作为一种高级语言来补充基于理解的方法。为了做到这一点,我们将有限的光学子集(即吸气剂、仿射折叠和折叠)提升到成熟的 DSL 中。最终的光学语言的类型系统,我们命名为 Optica,提炼了它们的组成属性,而其指称语义是由标准光学给出的。这种对光学概念的正式规范使得能够定义超出 van Laarhoven、profunctor 光学等的非标准光学表示。特别是,该论文证明了 XQuery 的受限子集可以理解为光学表示;它引入了 Triplets,这是一个非标准语义域,用于规范光学表达式并促进 SQL 查询的生成;
更新日期:2020-09-03
down
wechat
bug