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
//! What a type projects to under one named STATE — the type-level half of "the element of a
//! collection", written once so that nothing has to re-derive it.
//!
//! [`State<S>`](State) is a map from a type and a state to another type. The state is a type-level
//! NAME rather than a value: `<Vec<Tag> as State<Extracted<Inner>>>::Output` is `Tag`, and the only
//! thing `Extracted<Inner>` does is pick which of a type's projections is meant.
//!
//! # Why a state parameter, where an associated type would fit today
//!
//! One trait with one `type Inner` would answer the single question this crate asks now. It would
//! also be the last question that trait could answer: a type has SEVERAL projections — a map's key,
//! a map's value, a nesting flattened all the way down — and a trait keyed on the type alone answers
//! once. The state is what makes the answer per (type, question) instead of per type, which is the
//! same split [`marker`](crate::marker) makes for interpretations one level up.
//!
//! Only the states with a consumer are declared. `Extracted<Inner>` has one — the collection and
//! nullable markers check their inner marker against it — and [`Identity`] is the base case that
//! makes the layer total. A map key and a map value have no consumer in this crate and no rows here.
//!
//! # What the coherence bound above it buys
//!
//! `ListMarker<Vec<Tag>, ScalarMarker<u8>>` names a list of `Tag` whose elements are read as `u8`,
//! which is not a reading of anything. The marker's own bound refuses it by asking this layer what
//! `Vec<Tag>` holds and requiring the inner marker to mark that — see
//! [`ListMarker`](crate::ListMarker). Without a projection layer the two halves could only be
//! checked by hand, which is to say not at all.
//!
//! # A downstream container joins by writing one impl
//!
//! [`State`] is this crate's trait, so `impl State<Extracted<Inner>> for TheirVec<T>` names a local
//! type and is legal where `impl ToGraphqlFilter for TheirVec<T>` is `E0117`. That impl is what a
//! downstream collection needs before a composed marker can name it, and it is the same shape the
//! two rows below have.
/// What `Self` projects to under the state `S`.
///
/// The state names WHICH projection is meant, so one type answers as many times as it has
/// projections. See the module note for why the question is not an associated type on a trait of
/// its own.
/// The state that changes nothing — every type projects to itself.
///
/// The layer's base case, and it is inhabited by a blanket rather than by a row per type: *the type
/// itself* is an answer every type has. What it buys is that a consumer generic over the state has
/// somewhere to put the unwrapped position, instead of special-casing it outside the layer.
;
/// The state that reads what a container HOLDS — the sub-state of [`Extracted`] this crate uses.
///
/// `Vec<T>` and `Option<T>` both hold a `T`, and both say so below. What "holds" means is the
/// container's to state: it is one row per container, never a formula, for the reason
/// [`BytesFilterMarker`](crate::BytesFilterMarker) states its answer rather than computing one.
;
/// A projection that reaches INTO a type, parameterised by which part is meant.
///
/// Two levels rather than one — `Extracted<Inner>` instead of a bare `Inner` — because the states
/// that will join it are siblings of [`Inner`] and not of [`Identity`]: a map's key and a map's
/// value are both extractions, and both differ from the identity in the same way. Naming the family
/// keeps that visible in the type.
>);
/// A sequence holds its element type.
/// An optional column holds the type it may hold — the projection the null test is applied OVER.