The Optics of Language-Integrated Query

09/02/2020
by   J. López-González, et al.
0

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.

READ FULL TEXT

Authors

page 1

page 2

page 3

page 4

01/11/2021

Query Lifting: Language-integrated query for heterogeneous nested collections

Language-integrated query based on comprehension syntax is a powerful te...
03/03/2022

PhD thesis: SQL Comprehension and Synthesis

Structured Query Language (SQL) remains the standard language used in Re...
11/26/2020

Strongly-Normalizing Higher-Order Relational Queries

Language-integrated query is a powerful programming construct allowing d...
07/23/2021

Comprehending nulls

The Nested Relational Calculus (NRC) has been an influential high-level ...
10/25/2019

Rumble: data independence when data is in a mess

This paper introduces Rumble, an engine that executes JSONiq queries on ...
07/05/2019

Type-safe, Polyvariadic Event Correlation

The pivotal role that event correlation technology plays in todays appli...
01/24/2019

TigerGraph: A Native MPP Graph Database

We present TigerGraph, a graph database system built from the ground up ...
This week in AI

Get the week's most popular data science and artificial intelligence research sent straight to your inbox every Saturday.