Calculus expression; List comprehension; Set abstraction; ZF-expression
The comprehension comes from ideas of mathematical set theory. It originated as a way of defining sets of values so as to avoid the famous paradoxes of early set theory, by starting from other well-defined sets and using some carefully chosen constructors and filters. The values in the sets could be tuples of basic values, which suits the relational model, or they could be object identifiers, which fits with ODMG object data models , or they could be tagged variant records which fit well with semi-structured data. They could even be sets, lists or bags defined by other comprehensions.
The abstract structure of a comprehension precisely describes almost all the computations done in functional query languages, despite their very different surface syntax. Better still, it allows many optimizations to be expressed as well defined mathematical transformations.
Consider an example, using...