foldkit-entity 0.13.0 → 0.15.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +962 -512
- package/dist/collation.d.ts +33 -0
- package/dist/collation.d.ts.map +1 -0
- package/dist/collation.js +46 -0
- package/dist/collation.js.map +1 -0
- package/dist/conformance/index.d.ts +66 -0
- package/dist/conformance/index.d.ts.map +1 -0
- package/dist/conformance/{index.mjs → index.js} +22 -360
- package/dist/conformance/index.js.map +1 -0
- package/dist/conformance/operator.d.ts +115 -0
- package/dist/conformance/operator.d.ts.map +1 -0
- package/dist/conformance/operator.js +354 -0
- package/dist/conformance/operator.js.map +1 -0
- package/dist/conformance/relational.d.ts +240 -0
- package/dist/conformance/relational.d.ts.map +1 -0
- package/dist/conformance/relational.js +425 -0
- package/dist/conformance/relational.js.map +1 -0
- package/dist/conformance/tuples.d.ts +8 -0
- package/dist/conformance/tuples.d.ts.map +1 -0
- package/dist/conformance/tuples.js +43 -0
- package/dist/conformance/tuples.js.map +1 -0
- package/dist/conformance/variants.d.ts +47 -0
- package/dist/conformance/variants.d.ts.map +1 -0
- package/dist/conformance/variants.js +126 -0
- package/dist/conformance/variants.js.map +1 -0
- package/dist/context.d.ts +60 -0
- package/dist/context.d.ts.map +1 -0
- package/dist/context.js +36 -0
- package/dist/context.js.map +1 -0
- package/dist/descriptor.d.ts +33 -0
- package/dist/descriptor.d.ts.map +1 -0
- package/dist/descriptor.js +137 -0
- package/dist/descriptor.js.map +1 -0
- package/dist/entity.d.ts +231 -0
- package/dist/entity.d.ts.map +1 -0
- package/dist/entity.js +435 -0
- package/dist/entity.js.map +1 -0
- package/dist/evaluate.d.ts +204 -0
- package/dist/evaluate.d.ts.map +1 -0
- package/dist/evaluate.js +765 -0
- package/dist/evaluate.js.map +1 -0
- package/dist/expr.d.ts +915 -0
- package/dist/expr.d.ts.map +1 -0
- package/dist/expr.js +1630 -0
- package/dist/expr.js.map +1 -0
- package/dist/held.d.ts +112 -0
- package/dist/held.d.ts.map +1 -0
- package/dist/held.js +155 -0
- package/dist/held.js.map +1 -0
- package/dist/ids.d.ts +8 -0
- package/dist/ids.d.ts.map +1 -0
- package/dist/ids.js +8 -0
- package/dist/ids.js.map +1 -0
- package/dist/index.d.ts +380 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +110 -0
- package/dist/index.js.map +1 -0
- package/dist/invariant.d.ts +123 -0
- package/dist/invariant.d.ts.map +1 -0
- package/dist/invariant.js +236 -0
- package/dist/invariant.js.map +1 -0
- package/dist/jsonSchema.d.ts +3 -0
- package/dist/jsonSchema.d.ts.map +1 -0
- package/dist/jsonSchema.js +17 -0
- package/dist/jsonSchema.js.map +1 -0
- package/dist/law.d.ts +264 -0
- package/dist/law.d.ts.map +1 -0
- package/dist/law.js +111 -0
- package/dist/law.js.map +1 -0
- package/dist/operators.d.ts +170 -0
- package/dist/operators.d.ts.map +1 -0
- package/dist/operators.js +207 -0
- package/dist/operators.js.map +1 -0
- package/dist/readFilter.d.ts +8 -0
- package/dist/readFilter.d.ts.map +1 -0
- package/dist/readFilter.js +23 -0
- package/dist/readFilter.js.map +1 -0
- package/dist/record.d.ts +11 -0
- package/dist/record.d.ts.map +1 -0
- package/dist/record.js +21 -0
- package/dist/record.js.map +1 -0
- package/dist/sets.d.ts +18 -0
- package/dist/sets.d.ts.map +1 -0
- package/dist/sets.js +57 -0
- package/dist/sets.js.map +1 -0
- package/dist/shape.d.ts +23 -0
- package/dist/shape.d.ts.map +1 -0
- package/dist/shape.js +30 -0
- package/dist/shape.js.map +1 -0
- package/dist/tested.d.ts +8 -0
- package/dist/tested.d.ts.map +1 -0
- package/dist/tested.js +25 -0
- package/dist/tested.js.map +1 -0
- package/dist/text.d.ts +27 -0
- package/dist/text.d.ts.map +1 -0
- package/dist/text.js +39 -0
- package/dist/text.js.map +1 -0
- package/dist/variants.d.ts +72 -0
- package/dist/variants.d.ts.map +1 -0
- package/dist/variants.js +76 -0
- package/dist/variants.js.map +1 -0
- package/dist/words.d.ts +17 -0
- package/dist/words.d.ts.map +1 -0
- package/dist/words.js +22 -0
- package/dist/words.js.map +1 -0
- package/dist/write.d.ts +312 -0
- package/dist/write.d.ts.map +1 -0
- package/dist/write.js +520 -0
- package/dist/write.js.map +1 -0
- package/package.json +8 -8
- package/dist/conformance/index.d.mts +0 -274
- package/dist/conformance/index.d.mts.map +0 -1
- package/dist/conformance/index.mjs.map +0 -1
- package/dist/index-hu8IYlNc.d.mts +0 -2228
- package/dist/index-hu8IYlNc.d.mts.map +0 -1
- package/dist/index.d.mts +0 -2
- package/dist/index.mjs +0 -1
- package/dist/src-DBAilaDV.mjs +0 -3061
- package/dist/src-DBAilaDV.mjs.map +0 -1
package/dist/law.d.ts
ADDED
|
@@ -0,0 +1,264 @@
|
|
|
1
|
+
import { Data, Option, Schema } from "effect";
|
|
2
|
+
import { Operator } from "./expr.js";
|
|
3
|
+
/** An operator a law names as a witness: the inverse, or the operator distributed over. */
|
|
4
|
+
type AnyOperator = Operator<ReadonlyArray<Schema.Top>, Schema.Top>;
|
|
5
|
+
/** Which argument a witness stands in. */
|
|
6
|
+
export type Side = 'left' | 'right' | 'both';
|
|
7
|
+
/**
|
|
8
|
+
* A law, over its domain: by default every non-null value of the operator's
|
|
9
|
+
* input schemas; narrowed by `Law.within`.
|
|
10
|
+
*/
|
|
11
|
+
export type Law = Data.TaggedEnum<{
|
|
12
|
+
/** `op(op(a, b), c) = op(a, op(b, c))` */
|
|
13
|
+
Associative: {
|
|
14
|
+
readonly domain: Option.Option<Schema.Top>;
|
|
15
|
+
};
|
|
16
|
+
/** `op(a, b) = op(b, a)` */
|
|
17
|
+
Commutative: {
|
|
18
|
+
readonly domain: Option.Option<Schema.Top>;
|
|
19
|
+
};
|
|
20
|
+
/** `op(a, a) = a` */
|
|
21
|
+
Idempotent: {
|
|
22
|
+
readonly domain: Option.Option<Schema.Top>;
|
|
23
|
+
};
|
|
24
|
+
/** `op(e, a) = a` (left), `op(a, e) = a` (right), or both. */
|
|
25
|
+
Identity: {
|
|
26
|
+
readonly domain: Option.Option<Schema.Top>;
|
|
27
|
+
readonly value: unknown;
|
|
28
|
+
readonly side: Side;
|
|
29
|
+
};
|
|
30
|
+
/** `op(z, a) = z` (left), `op(a, z) = z` (right), or both. */
|
|
31
|
+
Absorbing: {
|
|
32
|
+
readonly domain: Option.Option<Schema.Top>;
|
|
33
|
+
readonly value: unknown;
|
|
34
|
+
readonly side: Side;
|
|
35
|
+
};
|
|
36
|
+
/** `op(a, other(a)) = identity` */
|
|
37
|
+
Inverse: {
|
|
38
|
+
readonly domain: Option.Option<Schema.Top>;
|
|
39
|
+
readonly other: AnyOperator;
|
|
40
|
+
readonly identity: unknown;
|
|
41
|
+
};
|
|
42
|
+
/** `op(a, over(b, c)) = over(op(a, b), op(a, c))` */
|
|
43
|
+
Distributes: {
|
|
44
|
+
readonly domain: Option.Option<Schema.Top>;
|
|
45
|
+
readonly over: AnyOperator;
|
|
46
|
+
};
|
|
47
|
+
/** `a ≤ b` at `position` implies `op(…a…) ≤ op(…b…)`, or `≥` when decreasing. */
|
|
48
|
+
Monotonic: {
|
|
49
|
+
readonly domain: Option.Option<Schema.Top>;
|
|
50
|
+
readonly direction: 'increasing' | 'decreasing';
|
|
51
|
+
readonly position: number;
|
|
52
|
+
};
|
|
53
|
+
/** Folding the result equals folding the arguments first: its text keeps their collation (§7). */
|
|
54
|
+
PreservesCollation: {
|
|
55
|
+
readonly domain: Option.Option<Schema.Top>;
|
|
56
|
+
};
|
|
57
|
+
}>;
|
|
58
|
+
/**
|
|
59
|
+
* A law as JSON says it: what `Operators.describe` lists and evidence names.
|
|
60
|
+
* Its witnesses are values as stored and operators by name; its domain is a
|
|
61
|
+
* JSON Schema, or `null` for the operator's whole input.
|
|
62
|
+
*/
|
|
63
|
+
export declare const LawDescription: Schema.Struct<{
|
|
64
|
+
readonly kind: Schema.String;
|
|
65
|
+
readonly witnesses: Schema.$Record<Schema.String, Schema.Unknown>;
|
|
66
|
+
readonly domain: Schema.Unknown;
|
|
67
|
+
}>;
|
|
68
|
+
export type LawDescription = typeof LawDescription.Type;
|
|
69
|
+
export declare const Law: {
|
|
70
|
+
associative: {
|
|
71
|
+
readonly _tag: "Associative";
|
|
72
|
+
readonly domain: Option.Option<Schema.Top>;
|
|
73
|
+
};
|
|
74
|
+
commutative: {
|
|
75
|
+
readonly _tag: "Commutative";
|
|
76
|
+
readonly domain: Option.Option<Schema.Top>;
|
|
77
|
+
};
|
|
78
|
+
idempotent: {
|
|
79
|
+
readonly _tag: "Idempotent";
|
|
80
|
+
readonly domain: Option.Option<Schema.Top>;
|
|
81
|
+
};
|
|
82
|
+
preservesCollation: {
|
|
83
|
+
readonly _tag: "PreservesCollation";
|
|
84
|
+
readonly domain: Option.Option<Schema.Top>;
|
|
85
|
+
};
|
|
86
|
+
/** `value` leaves the other argument as it is, from `side` (both by default). */
|
|
87
|
+
identity: (value: unknown, side?: Side) => Law;
|
|
88
|
+
/** `value` is the answer whatever the other argument, from `side` (both by default). */
|
|
89
|
+
absorbing: (value: unknown, side?: Side) => Law;
|
|
90
|
+
/** `other` undoes the operator: `op(a, other(a))` is `identity`. */
|
|
91
|
+
inverse: <In extends ReadonlyArray<Schema.Top>, Out extends Schema.Top>(other: Operator<In, Out>, identity: unknown) => Law;
|
|
92
|
+
/** The operator distributes over `over`, from the left. */
|
|
93
|
+
distributes: <In extends ReadonlyArray<Schema.Top>, Out extends Schema.Top>(over: Operator<In, Out>) => Law;
|
|
94
|
+
/** Moving the argument at `position` up moves the result up (or down, decreasing). */
|
|
95
|
+
monotonic: (direction: 'increasing' | 'decreasing', position: number) => Law;
|
|
96
|
+
/**
|
|
97
|
+
* The law over the values `domain` accepts only: a law that holds of the
|
|
98
|
+
* integers and not of every number, say, narrowed so it is tested where it
|
|
99
|
+
* is claimed.
|
|
100
|
+
*/
|
|
101
|
+
within: (law: Law, domain: Schema.Top) => Law;
|
|
102
|
+
$match: {
|
|
103
|
+
<Cases extends { readonly [Tag in "Absorbing" | "Associative" | "Commutative" | "Distributes" | "Idempotent" | "Identity" | "Inverse" | "Monotonic" | "PreservesCollation"]: (args: Extract<{
|
|
104
|
+
readonly _tag: "Absorbing";
|
|
105
|
+
readonly domain: Option.Option<Schema.Top>;
|
|
106
|
+
readonly value: unknown;
|
|
107
|
+
readonly side: Side;
|
|
108
|
+
} | {
|
|
109
|
+
readonly _tag: "Associative";
|
|
110
|
+
readonly domain: Option.Option<Schema.Top>;
|
|
111
|
+
} | {
|
|
112
|
+
readonly _tag: "Commutative";
|
|
113
|
+
readonly domain: Option.Option<Schema.Top>;
|
|
114
|
+
} | {
|
|
115
|
+
readonly _tag: "Distributes";
|
|
116
|
+
readonly domain: Option.Option<Schema.Top>;
|
|
117
|
+
readonly over: AnyOperator;
|
|
118
|
+
} | {
|
|
119
|
+
readonly _tag: "Idempotent";
|
|
120
|
+
readonly domain: Option.Option<Schema.Top>;
|
|
121
|
+
} | {
|
|
122
|
+
readonly _tag: "Identity";
|
|
123
|
+
readonly domain: Option.Option<Schema.Top>;
|
|
124
|
+
readonly value: unknown;
|
|
125
|
+
readonly side: Side;
|
|
126
|
+
} | {
|
|
127
|
+
readonly _tag: "Inverse";
|
|
128
|
+
readonly domain: Option.Option<Schema.Top>;
|
|
129
|
+
readonly other: AnyOperator;
|
|
130
|
+
readonly identity: unknown;
|
|
131
|
+
} | {
|
|
132
|
+
readonly _tag: "Monotonic";
|
|
133
|
+
readonly domain: Option.Option<Schema.Top>;
|
|
134
|
+
readonly direction: 'increasing' | 'decreasing';
|
|
135
|
+
readonly position: number;
|
|
136
|
+
} | {
|
|
137
|
+
readonly _tag: "PreservesCollation";
|
|
138
|
+
readonly domain: Option.Option<Schema.Top>;
|
|
139
|
+
}, {
|
|
140
|
+
readonly _tag: Tag;
|
|
141
|
+
}>) => any; }>(cases: Cases): (value: {
|
|
142
|
+
readonly _tag: "Absorbing";
|
|
143
|
+
readonly domain: Option.Option<Schema.Top>;
|
|
144
|
+
readonly value: unknown;
|
|
145
|
+
readonly side: Side;
|
|
146
|
+
} | {
|
|
147
|
+
readonly _tag: "Associative";
|
|
148
|
+
readonly domain: Option.Option<Schema.Top>;
|
|
149
|
+
} | {
|
|
150
|
+
readonly _tag: "Commutative";
|
|
151
|
+
readonly domain: Option.Option<Schema.Top>;
|
|
152
|
+
} | {
|
|
153
|
+
readonly _tag: "Distributes";
|
|
154
|
+
readonly domain: Option.Option<Schema.Top>;
|
|
155
|
+
readonly over: AnyOperator;
|
|
156
|
+
} | {
|
|
157
|
+
readonly _tag: "Idempotent";
|
|
158
|
+
readonly domain: Option.Option<Schema.Top>;
|
|
159
|
+
} | {
|
|
160
|
+
readonly _tag: "Identity";
|
|
161
|
+
readonly domain: Option.Option<Schema.Top>;
|
|
162
|
+
readonly value: unknown;
|
|
163
|
+
readonly side: Side;
|
|
164
|
+
} | {
|
|
165
|
+
readonly _tag: "Inverse";
|
|
166
|
+
readonly domain: Option.Option<Schema.Top>;
|
|
167
|
+
readonly other: AnyOperator;
|
|
168
|
+
readonly identity: unknown;
|
|
169
|
+
} | {
|
|
170
|
+
readonly _tag: "Monotonic";
|
|
171
|
+
readonly domain: Option.Option<Schema.Top>;
|
|
172
|
+
readonly direction: 'increasing' | 'decreasing';
|
|
173
|
+
readonly position: number;
|
|
174
|
+
} | {
|
|
175
|
+
readonly _tag: "PreservesCollation";
|
|
176
|
+
readonly domain: Option.Option<Schema.Top>;
|
|
177
|
+
}) => import("effect/Unify").Unify<ReturnType<Cases["Absorbing" | "Associative" | "Commutative" | "Distributes" | "Idempotent" | "Identity" | "Inverse" | "Monotonic" | "PreservesCollation"]>>;
|
|
178
|
+
<Cases extends { readonly [Tag in "Absorbing" | "Associative" | "Commutative" | "Distributes" | "Idempotent" | "Identity" | "Inverse" | "Monotonic" | "PreservesCollation"]: (args: Extract<{
|
|
179
|
+
readonly _tag: "Absorbing";
|
|
180
|
+
readonly domain: Option.Option<Schema.Top>;
|
|
181
|
+
readonly value: unknown;
|
|
182
|
+
readonly side: Side;
|
|
183
|
+
} | {
|
|
184
|
+
readonly _tag: "Associative";
|
|
185
|
+
readonly domain: Option.Option<Schema.Top>;
|
|
186
|
+
} | {
|
|
187
|
+
readonly _tag: "Commutative";
|
|
188
|
+
readonly domain: Option.Option<Schema.Top>;
|
|
189
|
+
} | {
|
|
190
|
+
readonly _tag: "Distributes";
|
|
191
|
+
readonly domain: Option.Option<Schema.Top>;
|
|
192
|
+
readonly over: AnyOperator;
|
|
193
|
+
} | {
|
|
194
|
+
readonly _tag: "Idempotent";
|
|
195
|
+
readonly domain: Option.Option<Schema.Top>;
|
|
196
|
+
} | {
|
|
197
|
+
readonly _tag: "Identity";
|
|
198
|
+
readonly domain: Option.Option<Schema.Top>;
|
|
199
|
+
readonly value: unknown;
|
|
200
|
+
readonly side: Side;
|
|
201
|
+
} | {
|
|
202
|
+
readonly _tag: "Inverse";
|
|
203
|
+
readonly domain: Option.Option<Schema.Top>;
|
|
204
|
+
readonly other: AnyOperator;
|
|
205
|
+
readonly identity: unknown;
|
|
206
|
+
} | {
|
|
207
|
+
readonly _tag: "Monotonic";
|
|
208
|
+
readonly domain: Option.Option<Schema.Top>;
|
|
209
|
+
readonly direction: 'increasing' | 'decreasing';
|
|
210
|
+
readonly position: number;
|
|
211
|
+
} | {
|
|
212
|
+
readonly _tag: "PreservesCollation";
|
|
213
|
+
readonly domain: Option.Option<Schema.Top>;
|
|
214
|
+
}, {
|
|
215
|
+
readonly _tag: Tag;
|
|
216
|
+
}>) => any; }>(value: {
|
|
217
|
+
readonly _tag: "Absorbing";
|
|
218
|
+
readonly domain: Option.Option<Schema.Top>;
|
|
219
|
+
readonly value: unknown;
|
|
220
|
+
readonly side: Side;
|
|
221
|
+
} | {
|
|
222
|
+
readonly _tag: "Associative";
|
|
223
|
+
readonly domain: Option.Option<Schema.Top>;
|
|
224
|
+
} | {
|
|
225
|
+
readonly _tag: "Commutative";
|
|
226
|
+
readonly domain: Option.Option<Schema.Top>;
|
|
227
|
+
} | {
|
|
228
|
+
readonly _tag: "Distributes";
|
|
229
|
+
readonly domain: Option.Option<Schema.Top>;
|
|
230
|
+
readonly over: AnyOperator;
|
|
231
|
+
} | {
|
|
232
|
+
readonly _tag: "Idempotent";
|
|
233
|
+
readonly domain: Option.Option<Schema.Top>;
|
|
234
|
+
} | {
|
|
235
|
+
readonly _tag: "Identity";
|
|
236
|
+
readonly domain: Option.Option<Schema.Top>;
|
|
237
|
+
readonly value: unknown;
|
|
238
|
+
readonly side: Side;
|
|
239
|
+
} | {
|
|
240
|
+
readonly _tag: "Inverse";
|
|
241
|
+
readonly domain: Option.Option<Schema.Top>;
|
|
242
|
+
readonly other: AnyOperator;
|
|
243
|
+
readonly identity: unknown;
|
|
244
|
+
} | {
|
|
245
|
+
readonly _tag: "Monotonic";
|
|
246
|
+
readonly domain: Option.Option<Schema.Top>;
|
|
247
|
+
readonly direction: 'increasing' | 'decreasing';
|
|
248
|
+
readonly position: number;
|
|
249
|
+
} | {
|
|
250
|
+
readonly _tag: "PreservesCollation";
|
|
251
|
+
readonly domain: Option.Option<Schema.Top>;
|
|
252
|
+
}, cases: Cases): import("effect/Unify").Unify<ReturnType<Cases["Absorbing" | "Associative" | "Commutative" | "Distributes" | "Idempotent" | "Identity" | "Inverse" | "Monotonic" | "PreservesCollation"]>>;
|
|
253
|
+
};
|
|
254
|
+
/**
|
|
255
|
+
* The operators a law, as JSON, calls besides its own (`inverse`'s and
|
|
256
|
+
* `distributes`' witnesses), by name: evidence of it is of their
|
|
257
|
+
* implementations too, and goes when one of them is replaced.
|
|
258
|
+
*/
|
|
259
|
+
witnessesNamed: (law: LawDescription) => ReadonlyArray<string>;
|
|
260
|
+
/** The law as JSON: its kind, its witnesses (operators by name) and its domain's JSON Schema. */
|
|
261
|
+
describe: (law: Law) => LawDescription;
|
|
262
|
+
};
|
|
263
|
+
export {};
|
|
264
|
+
//# sourceMappingURL=law.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
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OAAO,OAAO,OAAO;;;eAsBrB,QAAA,OAAO,OAAO,OAAO;eAAqB,MAAA;;;eApB3C,QAAA,OAAO,OAAO,OAAO;;;eAGjC,QAAA,OAAO,OAAO,OAAO;eACtB;eACD,MAAA;;;eAUE,QAAA,OAAO,OAAO,OAAO;eACtB,OAAA;eACG;;;eAMF,QAAA,OAAO,OAAO,OAAO;eAClB;eACD;;;eAGkB,QAAA,OAAO,OAAO,OAAO;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;eAnBzC,QAAA,OAAO,OAAO,OAAO;eACtB;eACD,MAAA;;;eAfe,QAAA,OAAO,OAAO,OAAO;;;eAErB,QAAA,OAAO,OAAO,OAAO;;;eAsBrB,QAAA,OAAO,OAAO,OAAO;eAAqB,MAAA;;;eApB3C,QAAA,OAAO,OAAO,OAAO;;;eAGjC,QAAA,OAAO,OAAO,OAAO;eACtB;eACD,MAAA;;;eAUE,QAAA,OAAO,OAAO,OAAO;eACtB,OAAA;eACG;;;eAMF,QAAA,OAAO,OAAO,OAAO;eAClB;eACD;;;eAGkB,QAAA,OAAO,OAAO,OAAO;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;EA8D5D,iBAAc,KAAQ,mBAAiB;;EAMvC,WAAQ,KAAQ,QAAM"}
|
package/dist/law.js
ADDED
|
@@ -0,0 +1,111 @@
|
|
|
1
|
+
import { Data, Option, Schema } from "effect";
|
|
2
|
+
import { jsonSchemaOf } from "./jsonSchema.js";
|
|
3
|
+
// src/law.ts
|
|
4
|
+
/**
|
|
5
|
+
* Laws an operator declares (expr-operations-DESIGN §10): equations every
|
|
6
|
+
* implementation of it keeps over a domain. A law describes; nothing rewrites a
|
|
7
|
+
* body by one. `Conformance.laws` tests an implementation against them, and
|
|
8
|
+
* what it finds is evidence recorded in that implementation's table.
|
|
9
|
+
*/
|
|
10
|
+
const Laws = Data.taggedEnum();
|
|
11
|
+
const unnarrowed = { domain: Option.none() };
|
|
12
|
+
/**
|
|
13
|
+
* A law as JSON says it: what `Operators.describe` lists and evidence names.
|
|
14
|
+
* Its witnesses are values as stored and operators by name; its domain is a
|
|
15
|
+
* JSON Schema, or `null` for the operator's whole input.
|
|
16
|
+
*/
|
|
17
|
+
const LawDescription = Schema.Struct({
|
|
18
|
+
kind: Schema.String,
|
|
19
|
+
witnesses: Schema.Record(Schema.String, Schema.Unknown),
|
|
20
|
+
domain: Schema.Unknown
|
|
21
|
+
});
|
|
22
|
+
/** An operator by its id, and its version when that is not the first. */
|
|
23
|
+
const nameOf = (operator) => operator.descriptor.version === 1 ? operator.descriptor.id : `${operator.descriptor.id}@${operator.descriptor.version}`;
|
|
24
|
+
const Law = {
|
|
25
|
+
associative: Laws.Associative(unnarrowed),
|
|
26
|
+
commutative: Laws.Commutative(unnarrowed),
|
|
27
|
+
idempotent: Laws.Idempotent(unnarrowed),
|
|
28
|
+
preservesCollation: Laws.PreservesCollation(unnarrowed),
|
|
29
|
+
/** `value` leaves the other argument as it is, from `side` (both by default). */
|
|
30
|
+
identity: (value, side = "both") => Laws.Identity({
|
|
31
|
+
...unnarrowed,
|
|
32
|
+
value,
|
|
33
|
+
side
|
|
34
|
+
}),
|
|
35
|
+
/** `value` is the answer whatever the other argument, from `side` (both by default). */
|
|
36
|
+
absorbing: (value, side = "both") => Laws.Absorbing({
|
|
37
|
+
...unnarrowed,
|
|
38
|
+
value,
|
|
39
|
+
side
|
|
40
|
+
}),
|
|
41
|
+
/** `other` undoes the operator: `op(a, other(a))` is `identity`. */
|
|
42
|
+
inverse: (other, identity) => Laws.Inverse({
|
|
43
|
+
...unnarrowed,
|
|
44
|
+
other,
|
|
45
|
+
identity
|
|
46
|
+
}),
|
|
47
|
+
/** The operator distributes over `over`, from the left. */
|
|
48
|
+
distributes: (over) => Laws.Distributes({
|
|
49
|
+
...unnarrowed,
|
|
50
|
+
over
|
|
51
|
+
}),
|
|
52
|
+
/** Moving the argument at `position` up moves the result up (or down, decreasing). */
|
|
53
|
+
monotonic: (direction, position) => Laws.Monotonic({
|
|
54
|
+
...unnarrowed,
|
|
55
|
+
direction,
|
|
56
|
+
position
|
|
57
|
+
}),
|
|
58
|
+
/**
|
|
59
|
+
* The law over the values `domain` accepts only: a law that holds of the
|
|
60
|
+
* integers and not of every number, say, narrowed so it is tested where it
|
|
61
|
+
* is claimed.
|
|
62
|
+
*/
|
|
63
|
+
within: (law, domain) => Object.freeze({
|
|
64
|
+
...law,
|
|
65
|
+
domain: Option.some(domain)
|
|
66
|
+
}),
|
|
67
|
+
$match: Laws.$match,
|
|
68
|
+
/**
|
|
69
|
+
* The operators a law, as JSON, calls besides its own (`inverse`'s and
|
|
70
|
+
* `distributes`' witnesses), by name: evidence of it is of their
|
|
71
|
+
* implementations too, and goes when one of them is replaced.
|
|
72
|
+
*/
|
|
73
|
+
witnessesNamed: (law) => [law.witnesses["other"], law.witnesses["over"]].filter((name) => typeof name === "string"),
|
|
74
|
+
/** The law as JSON: its kind, its witnesses (operators by name) and its domain's JSON Schema. */
|
|
75
|
+
describe: (law) => {
|
|
76
|
+
const witnesses = Laws.$match(law, {
|
|
77
|
+
Associative: () => ({}),
|
|
78
|
+
Commutative: () => ({}),
|
|
79
|
+
Idempotent: () => ({}),
|
|
80
|
+
PreservesCollation: () => ({}),
|
|
81
|
+
Identity: ({ value, side }) => ({
|
|
82
|
+
value,
|
|
83
|
+
side
|
|
84
|
+
}),
|
|
85
|
+
Absorbing: ({ value, side }) => ({
|
|
86
|
+
value,
|
|
87
|
+
side
|
|
88
|
+
}),
|
|
89
|
+
Inverse: ({ other, identity }) => ({
|
|
90
|
+
other: nameOf(other),
|
|
91
|
+
identity
|
|
92
|
+
}),
|
|
93
|
+
Distributes: ({ over }) => ({ over: nameOf(over) }),
|
|
94
|
+
Monotonic: ({ direction, position }) => ({
|
|
95
|
+
direction,
|
|
96
|
+
position
|
|
97
|
+
})
|
|
98
|
+
});
|
|
99
|
+
return {
|
|
100
|
+
kind: law._tag.charAt(0).toLowerCase() + law._tag.slice(1),
|
|
101
|
+
witnesses,
|
|
102
|
+
domain: Option.match(law.domain, {
|
|
103
|
+
onNone: () => null,
|
|
104
|
+
onSome: jsonSchemaOf
|
|
105
|
+
})
|
|
106
|
+
};
|
|
107
|
+
}
|
|
108
|
+
};
|
|
109
|
+
export { Law, LawDescription };
|
|
110
|
+
|
|
111
|
+
//# sourceMappingURL=law.js.map
|
package/dist/law.js.map
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"law.js","names":[],"sources":["../src/law.ts"],"sourcesContent":["/**\n * Laws an operator declares (expr-operations-DESIGN §10): equations every\n * implementation of it keeps over a domain. A law describes; nothing rewrites a\n * body by one. `Conformance.laws` tests an implementation against them, and\n * what it finds is evidence recorded in that implementation's table.\n */\nimport { Data, Option, Schema } from 'effect'\nimport type { Operator } from './expr.js'\nimport { jsonSchemaOf } from './jsonSchema.js'\n\n/** An operator a law names as a witness: the inverse, or the operator distributed over. */\ntype AnyOperator = Operator<ReadonlyArray<Schema.Top>, Schema.Top>\n\n/** Which argument a witness stands in. */\nexport type Side = 'left' | 'right' | 'both'\n\n/**\n * A law, over its domain: by default every non-null value of the operator's\n * input schemas; narrowed by `Law.within`.\n */\nexport type Law = Data.TaggedEnum<{\n /** `op(op(a, b), c) = op(a, op(b, c))` */\n Associative: { readonly domain: Option.Option<Schema.Top> }\n /** `op(a, b) = op(b, a)` */\n Commutative: { readonly domain: Option.Option<Schema.Top> }\n /** `op(a, a) = a` */\n Idempotent: { readonly domain: Option.Option<Schema.Top> }\n /** `op(e, a) = a` (left), `op(a, e) = a` (right), or both. */\n Identity: {\n readonly domain: Option.Option<Schema.Top>\n readonly value: unknown\n readonly side: Side\n }\n /** `op(z, a) = z` (left), `op(a, z) = z` (right), or both. */\n Absorbing: {\n readonly domain: Option.Option<Schema.Top>\n readonly value: unknown\n readonly side: Side\n }\n /** `op(a, other(a)) = identity` */\n Inverse: {\n readonly domain: Option.Option<Schema.Top>\n readonly other: AnyOperator\n readonly identity: unknown\n }\n /** `op(a, over(b, c)) = over(op(a, b), op(a, c))` */\n Distributes: { readonly domain: Option.Option<Schema.Top>; readonly over: AnyOperator }\n /** `a ≤ b` at `position` implies `op(…a…) ≤ op(…b…)`, or `≥` when decreasing. */\n Monotonic: {\n readonly domain: Option.Option<Schema.Top>\n readonly direction: 'increasing' | 'decreasing'\n readonly position: number\n }\n /** Folding the result equals folding the arguments first: its text keeps their collation (§7). */\n PreservesCollation: { readonly domain: Option.Option<Schema.Top> }\n}>\n\nconst Laws = Data.taggedEnum<Law>()\nconst unnarrowed = { domain: Option.none<Schema.Top>() }\n\n/**\n * A law as JSON says it: what `Operators.describe` lists and evidence names.\n * Its witnesses are values as stored and operators by name; its domain is a\n * JSON Schema, or `null` for the operator's whole input.\n */\nexport const LawDescription = Schema.Struct({\n kind: Schema.String,\n witnesses: Schema.Record(Schema.String, Schema.Unknown),\n domain: Schema.Unknown,\n})\nexport type LawDescription = typeof LawDescription.Type\n\n/** An operator by its id, and its version when that is not the first. */\nconst nameOf = (operator: AnyOperator): string =>\n operator.descriptor.version === 1\n ? operator.descriptor.id\n : `${operator.descriptor.id}@${operator.descriptor.version}`\n\nexport const Law = {\n associative: Laws.Associative(unnarrowed),\n commutative: Laws.Commutative(unnarrowed),\n idempotent: Laws.Idempotent(unnarrowed),\n preservesCollation: Laws.PreservesCollation(unnarrowed),\n /** `value` leaves the other argument as it is, from `side` (both by default). */\n identity: (value: unknown, side: Side = 'both'): Law =>\n Laws.Identity({ ...unnarrowed, value, side }),\n /** `value` is the answer whatever the other argument, from `side` (both by default). */\n absorbing: (value: unknown, side: Side = 'both'): Law =>\n Laws.Absorbing({ ...unnarrowed, value, side }),\n /** `other` undoes the operator: `op(a, other(a))` is `identity`. */\n inverse: <In extends ReadonlyArray<Schema.Top>, Out extends Schema.Top>(\n other: Operator<In, Out>,\n identity: unknown,\n ): Law => Laws.Inverse({ ...unnarrowed, other, identity }),\n /** The operator distributes over `over`, from the left. */\n distributes: <In extends ReadonlyArray<Schema.Top>, Out extends Schema.Top>(\n over: Operator<In, Out>,\n ): Law => Laws.Distributes({ ...unnarrowed, over }),\n /** Moving the argument at `position` up moves the result up (or down, decreasing). */\n monotonic: (direction: 'increasing' | 'decreasing', position: number): Law =>\n Laws.Monotonic({ ...unnarrowed, direction, position }),\n /**\n * The law over the values `domain` accepts only: a law that holds of the\n * integers and not of every number, say, narrowed so it is tested where it\n * is claimed.\n */\n within: (law: Law, domain: Schema.Top): Law =>\n Object.freeze({ ...law, domain: Option.some(domain) }),\n\n $match: Laws.$match,\n\n /**\n * The operators a law, as JSON, calls besides its own (`inverse`'s and\n * `distributes`' witnesses), by name: evidence of it is of their\n * implementations too, and goes when one of them is replaced.\n */\n witnessesNamed: (law: LawDescription): ReadonlyArray<string> =>\n [law.witnesses['other'], law.witnesses['over']].filter(\n (name): name is string => typeof name === 'string',\n ),\n\n /** The law as JSON: its kind, its witnesses (operators by name) and its domain's JSON Schema. */\n describe: (law: Law): LawDescription => {\n const witnesses: Record<string, unknown> = Laws.$match(law, {\n Associative: () => ({}),\n Commutative: () => ({}),\n Idempotent: () => ({}),\n PreservesCollation: () => ({}),\n Identity: ({ value, side }) => ({ value, side }),\n Absorbing: ({ value, side }) => ({ value, side }),\n Inverse: ({ other, identity }) => ({ other: nameOf(other), identity }),\n Distributes: ({ over }) => ({ over: nameOf(over) }),\n Monotonic: ({ direction, position }) => ({ direction, position }),\n })\n return {\n kind: law._tag.charAt(0).toLowerCase() + law._tag.slice(1),\n witnesses,\n domain: Option.match(law.domain, {\n onNone: () => null,\n onSome: jsonSchemaOf,\n }),\n }\n },\n}\n"],"mappings":";;;;;;;;;AAyDA,MAAM,OAAO,KAAK,WAAgB;AAClC,MAAM,aAAa,EAAE,QAAQ,OAAO,KAAiB,EAAE;;;;;;AAOvD,MAAa,iBAAiB,OAAO,OAAO;CAC1C,MAAM,OAAO;CACb,WAAW,OAAO,OAAO,OAAO,QAAQ,OAAO,OAAO;CACtD,Q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,IAAI,EAAE;GACjD,YAAY,EAAE,WAAW,gBAAgB;IAAE;IAAW;GAAS;EACjE,CAAC;EACD,OAAO;GACL,MAAM,IAAI,KAAK,OAAO,CAAC,CAAC,CAAC,YAAY,IAAI,IAAI,KAAK,MAAM,CAAC;GACzD;GACA,QAAQ,OAAO,MAAM,IAAI,QAAQ;IAC/B,cAAc;IACd,QAAQ;GACV,CAAC;EACH;CACF;AACF"}
|
|
@@ -0,0 +1,170 @@
|
|
|
1
|
+
import { Data, Option, Schema } from "effect";
|
|
2
|
+
import { Collation } from "./collation.js";
|
|
3
|
+
import { Operator, OperatorDescriptor, OperatorTable } from "./expr.js";
|
|
4
|
+
import { LawDescription } from "./law.js";
|
|
5
|
+
import { testedByRunner } from "./tested.js";
|
|
6
|
+
/** What an implementation is told besides its arguments. */
|
|
7
|
+
export interface OperatorContext {
|
|
8
|
+
/** The collation the call compares text under, from its operator's `collation` rule. */
|
|
9
|
+
readonly collation: Option.Option<Collation>;
|
|
10
|
+
}
|
|
11
|
+
/** One operator's in-memory implementation: a pure function of stored values. */
|
|
12
|
+
export interface MemoryImplementation {
|
|
13
|
+
readonly operator: OperatorDescriptor;
|
|
14
|
+
readonly run: (args: ReadonlyArray<unknown>, context: OperatorContext) => unknown;
|
|
15
|
+
}
|
|
16
|
+
/**
|
|
17
|
+
* What is known of a law of an implementation, past its operator claiming it
|
|
18
|
+
* (expr-operations-DESIGN §10.3): `Tested`, it passed `Conformance.laws`'
|
|
19
|
+
* cases; `Proven`, a proof elsewhere says so under its assumptions, recorded
|
|
20
|
+
* and never checked here.
|
|
21
|
+
*/
|
|
22
|
+
export type Evidence = Data.TaggedEnum<{
|
|
23
|
+
Tested: {
|
|
24
|
+
readonly operator: string;
|
|
25
|
+
readonly law: LawDescription;
|
|
26
|
+
readonly implementation: string;
|
|
27
|
+
readonly cases: number;
|
|
28
|
+
readonly seed: number;
|
|
29
|
+
};
|
|
30
|
+
Proven: {
|
|
31
|
+
readonly operator: string;
|
|
32
|
+
readonly law: LawDescription;
|
|
33
|
+
readonly reference: string;
|
|
34
|
+
readonly assumptions: ReadonlyArray<string>;
|
|
35
|
+
};
|
|
36
|
+
}>;
|
|
37
|
+
export declare const Evidence: Data.TaggedEnum.Constructor<{
|
|
38
|
+
readonly _tag: "Proven";
|
|
39
|
+
readonly operator: string;
|
|
40
|
+
readonly law: LawDescription;
|
|
41
|
+
readonly reference: string;
|
|
42
|
+
readonly assumptions: ReadonlyArray<string>;
|
|
43
|
+
} | {
|
|
44
|
+
readonly _tag: "Tested";
|
|
45
|
+
readonly operator: string;
|
|
46
|
+
readonly law: LawDescription;
|
|
47
|
+
readonly implementation: string;
|
|
48
|
+
readonly cases: number;
|
|
49
|
+
readonly seed: number;
|
|
50
|
+
}>;
|
|
51
|
+
/** A record of a law passing `Conformance.laws`' cases. */
|
|
52
|
+
export type TestedEvidence = Extract<Evidence, {
|
|
53
|
+
readonly _tag: 'Tested';
|
|
54
|
+
}>;
|
|
55
|
+
/**
|
|
56
|
+
* An operator as JSON, by its signature and never its body (a defined
|
|
57
|
+
* operator says `defined`, not what it means): what a server can publish of
|
|
58
|
+
* what a body may call, and a client compare with what it runs. Its schemas
|
|
59
|
+
* are each argument's and the result's stored side, as JSON Schemas.
|
|
60
|
+
*/
|
|
61
|
+
export declare const OperatorDescription: Schema.Struct<{
|
|
62
|
+
/** By id, and `@version` past the first: what tables, evidence and refusals name. */
|
|
63
|
+
readonly name: Schema.String;
|
|
64
|
+
readonly id: Schema.String;
|
|
65
|
+
readonly version: Schema.Int;
|
|
66
|
+
readonly description: Schema.NullOr<Schema.String>;
|
|
67
|
+
readonly input: Schema.$Array<Schema.$Record<Schema.String, Schema.Unknown>>;
|
|
68
|
+
readonly output: Schema.$Record<Schema.String, Schema.Unknown>;
|
|
69
|
+
readonly nulls: Schema.Literals<readonly ["strict", "handled"]>;
|
|
70
|
+
readonly collation: Schema.Literals<readonly ["none", "operands", "required"]>;
|
|
71
|
+
readonly laws: Schema.$Array<Schema.Struct<{
|
|
72
|
+
readonly kind: Schema.String;
|
|
73
|
+
readonly witnesses: Schema.$Record<Schema.String, Schema.Unknown>;
|
|
74
|
+
readonly domain: Schema.Unknown;
|
|
75
|
+
}>>;
|
|
76
|
+
readonly defined: Schema.Boolean;
|
|
77
|
+
}>;
|
|
78
|
+
export type OperatorDescription = typeof OperatorDescription.Type;
|
|
79
|
+
/** One operator a table implements, as `Operators.describeTable` lists it: described, with its evidence. */
|
|
80
|
+
export interface ImplementedOperator extends OperatorDescription {
|
|
81
|
+
readonly evidence: ReadonlyArray<Evidence>;
|
|
82
|
+
}
|
|
83
|
+
/** The in-memory interpreter's implementations, by operator. */
|
|
84
|
+
export interface MemoryOperators extends OperatorTable {
|
|
85
|
+
readonly _tag: 'MemoryOperators';
|
|
86
|
+
readonly get: (operator: OperatorDescriptor) => Option.Option<MemoryImplementation['run']>;
|
|
87
|
+
/**
|
|
88
|
+
* The operator it implements under a name (`id`, or `id@version` past the
|
|
89
|
+
* first): how a computed assignment carried as data finds what to run.
|
|
90
|
+
*/
|
|
91
|
+
readonly named: (name: string) => Option.Option<OperatorDescriptor>;
|
|
92
|
+
/** Whether each answer is checked against its operator's output schema: for tests. */
|
|
93
|
+
readonly checked: boolean;
|
|
94
|
+
readonly implementations: ReadonlyArray<MemoryImplementation>;
|
|
95
|
+
/** What is known of its implementations' laws: `Operators.withEvidence`. */
|
|
96
|
+
readonly evidence: ReadonlyArray<Evidence>;
|
|
97
|
+
}
|
|
98
|
+
type StoredOf<S extends Schema.Top> = Schema.Codec.Encoded<S>;
|
|
99
|
+
export declare const Operators: {
|
|
100
|
+
/**
|
|
101
|
+
* An implementation of a strict operator: a pure function of its arguments'
|
|
102
|
+
* stored values, never given a null (the kernel answers null, or unknown, for
|
|
103
|
+
* one first), and told the call's collation last.
|
|
104
|
+
*
|
|
105
|
+
* ```ts
|
|
106
|
+
* Operators.implement(startsWith, (text, prefix, { collation }) => text.startsWith(prefix))
|
|
107
|
+
* ```
|
|
108
|
+
*/
|
|
109
|
+
implement: <In extends ReadonlyArray<Schema.Top>, Out extends Schema.Top>(operator: Operator<In, Out>, run: (...args: [...{ readonly [K in keyof In]: NonNullable<StoredOf<In[K]>>; }, OperatorContext]) => StoredOf<Out>) => MemoryImplementation;
|
|
110
|
+
/**
|
|
111
|
+
* An implementation of an operator declared `nulls: 'handled'`: given nulls
|
|
112
|
+
* as they are, it answers for them; a predicate answers `null` for unknown.
|
|
113
|
+
*/
|
|
114
|
+
implementHandlingNulls: <In extends ReadonlyArray<Schema.Top>, Out extends Schema.Top>(operator: Operator<In, Out>, run: (...args: [...{ readonly [K in keyof In]: StoredOf<In[K]>; }, OperatorContext]) => StoredOf<Out> | null) => MemoryImplementation;
|
|
115
|
+
/** A table of implementations. One operator implemented twice, or two under one name, is refused. */
|
|
116
|
+
memory: (...implementations: ReadonlyArray<MemoryImplementation>) => MemoryOperators;
|
|
117
|
+
/** Both tables' implementations. An operator both implement is refused: say which wins with `override`. */
|
|
118
|
+
merge: (left: MemoryOperators, right: MemoryOperators) => MemoryOperators;
|
|
119
|
+
/**
|
|
120
|
+
* The table with these implementations in place of its own for the same
|
|
121
|
+
* operators. Evidence of a replaced implementation goes with it: it was
|
|
122
|
+
* that implementation's.
|
|
123
|
+
*/
|
|
124
|
+
override: (base: MemoryOperators, ...implementations: ReadonlyArray<MemoryImplementation>) => MemoryOperators;
|
|
125
|
+
/**
|
|
126
|
+
* The table with what is known of its implementations' laws recorded: each
|
|
127
|
+
* record of an operator it implements and a law that operator declares.
|
|
128
|
+
* `Conformance.laws` gives `Tested` records, each of the implementation it
|
|
129
|
+
* ran, and a table takes only those of its own; `Evidence.Proven` says a
|
|
130
|
+
* proof elsewhere covers one.
|
|
131
|
+
*/
|
|
132
|
+
withEvidence: (base: MemoryOperators, evidence: ReadonlyArray<Evidence>) => MemoryOperators;
|
|
133
|
+
/**
|
|
134
|
+
* The memory implementation `Conformance.laws` tested a record on; none for
|
|
135
|
+
* a record of a runner (`Conformance.lawsBy`) or a proof.
|
|
136
|
+
*/
|
|
137
|
+
testedOn: (record: Evidence) => Option.Option<MemoryImplementation>;
|
|
138
|
+
/**
|
|
139
|
+
* Whether `Conformance.lawsBy` made a record, through a runner: what an SQL
|
|
140
|
+
* table takes. Which runner it was, the database's or another, is the
|
|
141
|
+
* caller's word; a record built by hand, copied, or tested in memory is not.
|
|
142
|
+
*/
|
|
143
|
+
testedByRunner: typeof testedByRunner;
|
|
144
|
+
/**
|
|
145
|
+
* Each operator the table implements, by name, with the laws it declares and
|
|
146
|
+
* the evidence the table records of them: what a server can publish of how
|
|
147
|
+
* it runs a body. JSON as it is.
|
|
148
|
+
*/
|
|
149
|
+
describeTable: (base: MemoryOperators) => ReadonlyArray<ImplementedOperator>;
|
|
150
|
+
/**
|
|
151
|
+
* An operator as JSON (`OperatorDescription`): its name, version and
|
|
152
|
+
* description, each argument's and its result's stored side as a JSON
|
|
153
|
+
* Schema (as JSON carries it: a number also admits the strings `"Infinity"`,
|
|
154
|
+
* `"-Infinity"` and `"NaN"`), its null and collation rules, its laws, and
|
|
155
|
+
* whether it is defined. Its signature, never its body.
|
|
156
|
+
*/
|
|
157
|
+
describe: (operator: {
|
|
158
|
+
readonly descriptor: OperatorDescriptor;
|
|
159
|
+
}) => OperatorDescription;
|
|
160
|
+
/**
|
|
161
|
+
* The table, checking every answer against its operator's output schema, so
|
|
162
|
+
* an implementation that answers the wrong kind fails where it answered. For
|
|
163
|
+
* tests: it costs a decode per call.
|
|
164
|
+
*/
|
|
165
|
+
checked: (base: MemoryOperators) => MemoryOperators;
|
|
166
|
+
/** The kernel's own operators (`Text.startsWith`): every memory interpreter's default. */
|
|
167
|
+
kernel: MemoryOperators;
|
|
168
|
+
};
|
|
169
|
+
export {};
|
|
170
|
+
//# sourceMappingURL=operators.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"operators.d.ts","names":[],"sources":["../src/operators.ts"],"mappings":";;;;;;iBAeiB;;WAEN,WAAW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