1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
use PhantomData;
use *;
/// The QUANTIFIED collection filter — two operators over a collection column, generic over the
/// element type `T`: `any` asks whether SOME element satisfies a whole element predicate, and
/// `count` asks about the collection's LENGTH. There is no third.
///
/// # What it is FOR: an element with no honest LITERAL form
///
/// [`ListFilter`] and [`SetFilter`] each carry seven slots holding the element itself — six whole
/// collection operands and `has_element` — and putting an element on the wire is what their faces
/// ask [`ToGraphqlInput`](crate::ToGraphqlInput) for. That bound is the right one there and it is a
/// CONSEQUENCE rather than a convention: an operator whose operand is an element cannot be published
/// without publishing the element's literal form.
///
/// A great many element types have no such form that is worth publishing. A detection pair
/// `(code, score)` is the case this kind was cut for: `score` is a float, so
///
/// - **`hasElement` is a lie**. Membership is exact equality, and exact equality against a float
/// operand a client typed is false for every row that is not bit-identical. The operator would
/// compile, render, execute, and answer *no rows* to a question the caller believed they had
/// asked.
/// - **the four ordering operators are unstatable**. `gt` compares two whole collections
/// element-wise and lexicographically, so `gt: [{code: "cat", score: 0.4}]` asks whether this
/// detection list sorts after that one under an order composed of a string's and a float's. There
/// is no reading of that a client can act on, and none this crate could document.
/// - **`eq` and `ne` are the same shape of unusable**. Whole-collection equality over a float-bearing
/// element is exact equality per element, so it inherits `hasElement`'s falseness and multiplies it
/// by the collection's length.
///
/// So the narrow kind is not a subset taken for economy. **A schema publishes only the words it can
/// answer honestly**, and the seven that leave are the seven that could not be.
///
/// # Two KINDS and two NAMES, never one name with a conditional field list
///
/// A `Vec<Detection>` column reaches `DetectionQuantifiedFilter` and a `Vec<String>` column reaches
/// `StringListFilter`; the two are different input objects with different field lists under different
/// names. That is the NAMING CONSTITUTION's own rule — one wire name pins one vocabulary — and it is
/// why this is a type rather than a `ListFilter` whose face drops fields when the element cannot
/// cross. A face that varied its field list by a bound would publish a schema whose shape a client
/// could not predict from the name, and two clients reading `SomethingListFilter` would be reading
/// two different objects.
///
/// It is also the split [`ListFilter`] and [`SetFilter`] already are, and for a related reason: a
/// marker deciding which OPERATORS exist is a second kind rather than a rendering of one.
///
/// # `T` is carried and never held, and that is what the wire face proves
///
/// The element type appears in no slot — it is [`PhantomData`] — so this kind's face asks NOTHING of
/// it. Not [`ToGraphqlInput`](crate::ToGraphqlInput), not [`InputType`](async_graphql::InputType),
/// not [`Send`], not [`Sync`]: read the `where` clause on the [`InputType`](async_graphql::InputType)
/// row below and the only bound there is `VF`'s. **That is the whole deliverable**, stated by the
/// compiler rather than by this paragraph.
///
/// It is carried all the same, for the reason `VF` has a DEFAULT: `QuantifiedFilter<Detection>` is a
/// whole spelling and resolves the element's own filter through the same marker chain
/// `ListFilter<Detection>` resolves it through. Dropping `T` would make every spelling name the
/// element's FILTER — `QuantifiedFilter<DetectionFilter>` — which reads, beside `ListFilter<Detection>`,
/// as a collection of `DetectionFilter`. The parameter list is part of the family law, and a kind
/// that swaps into a collection seat should swap in one word.
///
/// # `VF` is the ELEMENT's filter, and it is what `any` asks with
///
/// [`ListFilter`]'s parameter, in every respect — the same default, reached through
/// `<<T as DefaultMarker>::Marker as ToGraphqlFilter>::Filter`, and a DEFAULT rather than a bound so
/// that an element with no reading at all is still filterable by naming `VF` outright. See it.
///
/// The element's filter is where the element's honest questions live. A detection's own filter names
/// its fields — `code` as an enumeration, `score` as a range — so the narrow collection kind loses
/// nothing a caller could have asked: `any: { score: { gte: 0.8 } }` is the question `hasElement`
/// pretended to be able to ask, and it is answerable.
///
/// # `any` on an EMPTY inner filter is a predicate, and `count` on an empty one is not
///
/// Carried word for word from [`ListFilter::is_empty`], because it is the same two slots and the
/// same quantifier: `∃x ∈ S. true` is `S ≠ ∅`, which is a predicate and not the absence of one,
/// while asking no question about one number excludes no row. The two slots this kind has are exactly
/// the two the wide kinds treat unlike each other, so the reading had to travel with them.
///
/// # There is no `try_map`, and the absence is total rather than partial
///
/// [`ListFilter::try_map`] converts every ELEMENT operand and passes `any` and `count` through
/// untouched. Seven of its nine slots hold elements and this kind has none of them, so the method
/// here would convert nothing and return `Self` under another name. What a nested filter's operands
/// need is its own crossing, exactly as it is one kind over.
///
/// # Examples
///
/// The two operators, and the emptiness reading that separates them:
///
/// ```
/// use ingraph::{GraphqlFilter, QuantifiedFilter, ScalarFilter};
///
/// // A quantified filter over a `Vec<i64>` column, asked in the element's own vocabulary.
/// let some_big = QuantifiedFilter::<i64>::new().with_any(ScalarFilter::new().with_gt(1_000));
/// assert!(!some_big.is_empty());
///
/// // `∃x. true` is *this collection has an element*, so a present `any` is never empty.
/// let non_empty = QuantifiedFilter::<i64>::new().with_any(ScalarFilter::new());
/// assert!(!non_empty.is_empty());
///
/// // A present `count` holding an unasked question is, because nothing quantifies it.
/// let unasked = QuantifiedFilter::<i64>::new().with_count(ScalarFilter::new());
/// assert!(unasked.is_empty());
/// ```
///
/// The seven whole-collection operators are absent from the TYPE, so asking one is a compile error
/// at the call site rather than a refusal at a crossing — the posture [`SetFilter`]'s missing
/// ordering operators already take:
///
/// ```compile_fail,E0599
/// let _ = ingraph::QuantifiedFilter::<i64>::new().with_has_element(1i64);
/// ```
///
/// The positive twin, which must COMPILE — stable rustdoc runs a `compile_fail` block just far
/// enough to see it fail and never checks why, so the pair shares its call shape and one half has to
/// be positive:
///
/// ```
/// use ingraph::{QuantifiedFilter, ScalarFilter};
///
/// let _ = QuantifiedFilter::<i64>::new().with_any(ScalarFilter::new().with_eq(1i64));
/// ```
// Hand-written, where the wide collection kinds derive all three: a derive would put `T: Debug` /
// `Clone` / `PartialEq` on the ELEMENT, which this kind holds only as `PhantomData<fn() -> T>` and
// asks nothing of anywhere else. `BytesFilter`'s reading marker is written out for the same reason
// one file over; here the parameter is an ordinary type that usually answers all three, which is
// what makes the derive's bound invisible rather than harmless — an element type kept out of every
// other bound must not re-enter through a `#[derive]`.
/// The WIRE FACE, written over the two PARAMETERS — [`ListFilter`](super::ListFilter)'s row, for the
/// narrow shape.
///
/// # The `where` clause is the deliverable
///
/// The wide collections ask `T: ToGraphqlInput`, `<T as ToGraphqlInput>::Input: InputType` and
/// `T: Send + Sync`, and every one of those three is spent by a slot holding an ELEMENT. This kind
/// holds none, so it asks for none: **`VF: InputType` is the whole clause**, and an element type with
/// no wire form at all reaches a schema through it.
///
/// `T` is not even asked for [`Send`] and [`Sync`], which
/// [`InputType`](async_graphql::InputType)'s own supertraits would otherwise reach through a slot.
/// `PhantomData<fn() -> T>` is both for every `T` — a function pointer carries no obligation to its
/// return type — which is what the field's own note is about.
///
/// # The NAME comes from the element's FILTER, as the wide collections' names do
///
/// `<Element>QuantifiedFilter`, assembled from `VF::type_name()` with the family suffix taken off —
/// see [`operand_of`](super::operand_of) for why the ELEMENT's own name cannot serve and why the
/// filter's is injective where the element's is not. So a detection's filter named `DetectionFilter`
/// gives `DetectionQuantifiedFilter`, and the wide kind over the same element would be
/// `DetectionListFilter`: two vocabularies, two names, which is the rule this kind exists under.
///
/// `ScalarFilter<usize>` needs no bound of its own: `count` is a cardinality, so it is one registered
/// input object for every element type there is.
/// The NULLABLE row, fed from the same face for the reason every kind's is: nullability is a TYPE
/// here, so a face with no [`NullableFace`](crate::NullableFace) row leaves the wrapper unspellable
/// over it.
///
/// The two slots are rendered by `__ingraph_filter_value_map!` DIRECTLY, where the wide collections
/// each need a function: that macro writes each slot through its own type's
/// [`InputType`](async_graphql::InputType), and the wide kinds' element slots hold a DOMAIN value
/// whose whole point is that it may have no such impl. Both slots here hold a FILTER, and a filter's
/// face is what this row is written beside.