Formalizing the signatures of operators and statements #5277
Replies: 2 comments
-
Incidentally after review |
Beta Was this translation helpful? Give feedback.
-
Since If we generalize the |
Beta Was this translation helpful? Give feedback.
-
The improvements mentioned in issue #111 provide a way to describe the signatures of EdgeDB operators and built-ins.
-A
, also+
A
A
NOT A
A
bool
A+B
, also-
,/
,*
, etc.A
,B
A
A AND B
, alsoOR
A
,B
bool
A = B
, also!=
A
,B
bool
A ?= B
OPTIONAL A
,OPTIONAL B
bool
A ?? B
OPTIONAL A
,SET OF B
SET OF A
A IF B ELSE C
SET OF A
,B
,SET OF C
SET OF A
EXISTS A
SET OF A
bool
DISTINCT A
SET OF A
SET OF A
A UNION B
SET OF A
,SET OF B
SET OF A
, actually a set of union type ofA
andB
A IN B
, alsoNOT IN
A
,SET OF B
bool
UPDATE A FILTER B SET ...
A
,SET OF B
A
SELECT A FILTER B ORDER BY C OFFSET D LIMIT E
A
,SET OF B
,OPTIONAL C
,OPTIONAL D
,OPTIONAL E
SET OF A
WITH CARDINALITY '1' SELECT A ...
A
INSERT A
A
DELETE A
A
A
UPDATE A FILTER B SET ...
A
,SET OF B
A
Incidentally, the syntax sugar proposed in #109 can now be rewritten as
{}??A
, which will renderA
aSET OF
parameter in the expression. The reason why we want the second parameter of??
to be aSET OF
is the practicality of typical usage for defaults. Consider:If
Default
were not inside aSET OF
, then on element-wise evaluation one of the tuple elements would always be{}
because of theFILTER
.FSET OF
is a placeholder name for "fenceless SET OF", meaning that all by itself the function does not distribute over union, but when composed with anything else, it does (and behaves like an element-wise). This property is needed to express howLIMIT
andORDER BY
work (and whyA
andSELECT A ORDER BY A
are equivalent).Typically all clauses have signature of the type
FSET OF a CLAUSE SET OF b
. Some clauses have additional restrictions.ORDER BY
requires its second argument to be a singleton.LIMIT
andOFFSET
not only require the second argument to be singleton, but also unrelated to the first argument.Beta Was this translation helpful? Give feedback.
All reactions