[Paper Review] Effective Quotation: relating approaches to language-integrated query
This paper proposes and formally compares two type-safe, language-integrated query approaches—effects in Links and quotation in LINQ—by introducing core calculi Eff and Quot. It establishes their equivalence in expressive power through bidirectional, semantics-preserving translations, demonstrating that both can generate dynamic queries with type safety and resistance to SQL injection.
Language-integrated query techniques have been explored in a number of different language designs. We consider two different, type-safe approaches employed by Links and F#. Both approaches provide rich dynamic query generation capabilities, and thus amount to a form of heterogeneous staged computation, but to date there has been no formal investigation of their relative expressiveness. We present two core calculi Eff and Quot, respectively capturing the essential aspects of language-integrated querying using effects in Links and quotation in LINQ. We show via translations from Eff to Quot and back that the two approaches are equivalent in expressiveness. Based on the translation from Eff to Quot, we extend a simple Links compiler to handle queries.
Motivation & Objective
- To formally compare the expressive power of two prominent language-integrated query techniques: effect-based query generation in Links and quotation-based query generation in LINQ.
- To address the open question of whether one approach can express dynamic queries that the other cannot.
- To provide a foundation for integrating LINQ-style quotation into existing effect-based systems like Links.
- To demonstrate that both approaches are equivalent in expressive power for first-order, nested relational queries.
- To extend a Links compiler with partial query support using the insights from the quotation-based translation.
Proposed method
- Define a core calculus, Eff, to model Links-style query generation using a type-and-effect system that classifies code as executable on the database, host language, or both.
- Define a core calculus, Quot, to model LINQ-style query generation using explicit quotations and run-time manipulation of abstract syntax trees.
- Construct a forward translation from Eff to Quot that preserves query behavior by lifting effectful computations into quoted expressions.
- Construct a backward translation from Quot to Eff that simulates quotation by introducing effectful operations for query construction.
- Use the forward translation to extend a simple Links compiler to support query expressions, validating the practicality of the approach.
- Establish semantic equivalence between the two calculi via bidirectional translations that preserve observable query behavior.
Experimental results
Research questions
- RQ1Are the effect-based and quotation-based approaches to language-integrated querying equally expressive for dynamic query generation?
- RQ2Can every program written in the effect-based style (Eff) be translated into an equivalent program in the quotation-based style (Quot) without loss of behavior?
- RQ3Can every program written in the quotation-based style (Quot) be translated into an equivalent program in the effect-based style (Eff) while preserving type safety and query semantics?
- RQ4Does the translation from Eff to Quot enable practical extensions to existing effect-based compilers, such as supporting query compilation?
- RQ5Can the two approaches be formally related using bidirectional translations that preserve observable query behavior?
Key findings
- The two approaches—effect-based query generation in Links and quotation-based query generation in LINQ—are formally equivalent in expressive power for first-order, nested relational queries.
- A semantics-preserving translation from Eff to Quot enables the extension of a Links compiler with partial support for query compilation, demonstrating practical applicability.
- The backward translation from Quot to Eff shows that quotation-based query construction can be emulated using effect systems, validating the generality of the effect model.
- The translations preserve observable query behavior, indicating that both systems can generate equivalent SQL or in-memory query plans.
- The equivalence result is surprising, as the two approaches appear structurally different, but the formal correspondence reveals a deep conceptual unity.
- The work suggests that future systems could combine the best of both worlds, using quotations to improve extensibility while retaining the performance guarantees of effect systems.
Read this paper
Open the full text in the Nubint reader and ask about any passage as you read.
Read this paper on NubintThis review was generated by AI from the original paper. Please check the paper before citing it.