bend-schema 0.1.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/LICENSE +21 -0
- package/README.md +230 -0
- package/core/LAWS.bend +379 -0
- package/core/LICENSE +23 -0
- package/core/PROOF.bend +4527 -0
- package/core/core.bend +1585 -0
- package/dist-core/core.d.mts +188 -0
- package/dist-core/core.mjs +2974 -0
- package/package.json +41 -0
- package/src/codec.ts +177 -0
- package/src/gen-cli.ts +61 -0
- package/src/gen.ts +96 -0
- package/src/index.ts +350 -0
|
@@ -0,0 +1,188 @@
|
|
|
1
|
+
// Generated by bend-emit from core.bend. Do not edit; rebuild.
|
|
2
|
+
export type BendList<T> = { $: "Nil" } | { $: "Con"; head: T; tail: BendList<T> };
|
|
3
|
+
export type BendMaybe<T> = { $: "None" } | { $: "Some"; value: T };
|
|
4
|
+
export type BendResult<E, A> = { $: "Fail"; error: E } | { $: "Done"; value: A };
|
|
5
|
+
export type BendEither<A, B> = { $: "Inl"; value: A } | { $: "Inr"; value: B };
|
|
6
|
+
export type BendUnit = { $: "Unit" };
|
|
7
|
+
|
|
8
|
+
export type Raw = { $: "RNum"; "n": bigint } | { $: "RBool"; "b": boolean } | { $: "RNull" } | { $: "RStr"; "s": string } | { $: "RBad" } | { $: "RTooBig" } | { $: "RMissing" } | { $: "RNil" } | { $: "RCons"; "head": Raw; "tail": Raw } | { $: "REnd" } | { $: "RKey"; "key": string; "val": Raw; "rest": Raw };
|
|
9
|
+
export type Schema = { $: "SNat" } | { $: "SNatIn"; "lo": bigint; "hi": bigint } | { $: "SStr" } | { $: "SStrLen"; "lo": bigint; "hi": bigint; "s": Schema } | { $: "SOpt"; "inner": Schema } | { $: "SList"; "elem": Schema } | { $: "SField"; "name": string; "s": Schema; "rest": Schema } | { $: "SEnd" } | { $: "SRule"; "s": Schema; "tag": bigint } | { $: "SStrict"; "s": Schema } | { $: "STagged"; "key": string; "name": string; "s": Schema; "rest": Schema } | { $: "STagEnd"; "key": string } | { $: "SBool" } | { $: "STrue" } | { $: "SEnum"; "names": BendList<string> } | { $: "SVariant"; "name": string; "s": Schema; "rest": Schema } | { $: "SVEnd" } | { $: "STuple"; "s": Schema; "rest": Schema } | { $: "STEnd" } | { $: "SOptional"; "inner": Schema } | { $: "SListLen"; "lo": bigint; "hi": bigint; "s": Schema };
|
|
10
|
+
export type Step = { $: "AtIndex"; "i": bigint } | { $: "AtField"; "skip": bigint; "name": string } | { $: "BoundAt"; "i": bigint; "key": string } | { $: "AtKey"; "key": string };
|
|
11
|
+
export type Why = { $: "Missing" } | { $: "NotNat" } | { $: "NotString" } | { $: "NotBool" } | { $: "NotList" } | { $: "NotObject" } | { $: "NoElements" } | { $: "OpenNotLast" } | { $: "LastNotOpen" } | { $: "NotIncreasing"; "prev": bigint; "got": bigint } | { $: "NotTrue" } | { $: "NotOneOf" } | { $: "NoVariant" } | { $: "TwoVariants" } | { $: "TooShort" } | { $: "TooLong" } | { $: "LengthNotIn"; "lo": bigint; "hi": bigint } | { $: "NotIn"; "lo": bigint; "hi": bigint } | { $: "UnknownKey" } | { $: "RepeatedKey"; "key": string } | { $: "TooLarge" } | { $: "CountNotIn"; "lo": bigint; "hi": bigint };
|
|
12
|
+
export type Err = { $: "Err"; "path": BendList<Step>; "why": Why };
|
|
13
|
+
export type Both<A, B> = { $: "Both"; "a": A; "b": B };
|
|
14
|
+
|
|
15
|
+
export declare function pick_raw(b: boolean, x: Raw, y: Raw): Raw;
|
|
16
|
+
export declare function lookup(name: string, r: Raw): Raw;
|
|
17
|
+
export declare function pick_bool(b: boolean, x: boolean, y: boolean): boolean;
|
|
18
|
+
export declare function is_rnil(r: Raw): boolean;
|
|
19
|
+
export declare function is_missing(v: Raw): boolean;
|
|
20
|
+
export declare function in_names(x: string, names: BendList<string>): boolean;
|
|
21
|
+
export declare function none_present(s: Schema, r: Raw): boolean;
|
|
22
|
+
export declare function key_names(s: Schema): BendList<string>;
|
|
23
|
+
export declare function no_extra(ns: BendList<string>, r: Raw): boolean;
|
|
24
|
+
export declare function drop_key(k: string, r: Raw): Raw;
|
|
25
|
+
export declare function is_str(n: string, v: Raw): boolean;
|
|
26
|
+
export declare function is_tag(k: string, n: string, r: Raw): boolean;
|
|
27
|
+
export declare function in_err(b: boolean, w: Why): BendMaybe<Err>;
|
|
28
|
+
export declare function str_len_ok(lo: bigint, hi: bigint, x: string): boolean;
|
|
29
|
+
export declare function num_ok(lo: bigint, hi: bigint, n: bigint): boolean;
|
|
30
|
+
export declare function len_ok(lo: bigint, hi: bigint, r: Raw): boolean;
|
|
31
|
+
export declare function str_len_in(lo: bigint, hi: bigint, r: Raw): BendMaybe<Err>;
|
|
32
|
+
export declare function nat_in(lo: bigint, hi: bigint, r: Raw): BendMaybe<Err>;
|
|
33
|
+
export declare function is_bool(r: Raw): boolean;
|
|
34
|
+
export declare function raw_list(r: Raw): boolean;
|
|
35
|
+
export declare function raw_len(r: Raw): bigint;
|
|
36
|
+
export declare function count_ok(lo: bigint, hi: bigint, r: Raw): boolean;
|
|
37
|
+
export declare function list_len_ok(lo: bigint, hi: bigint, r: Raw): boolean;
|
|
38
|
+
export declare function has_key(k: string, r: Raw): boolean;
|
|
39
|
+
export declare function key_once_at(r: Raw, b: boolean, name: string): boolean;
|
|
40
|
+
export declare function key_once(name: string, r: Raw): boolean;
|
|
41
|
+
export declare function key_err(b: boolean, name: string): BendMaybe<Err>;
|
|
42
|
+
export declare function here(w: Why): BendMaybe<Err>;
|
|
43
|
+
export declare function under(st: Step, m: BendMaybe<Err>): BendMaybe<Err>;
|
|
44
|
+
export declare function len_err(lo: bigint, hi: bigint, r: Raw): BendMaybe<Err>;
|
|
45
|
+
export declare function later_l_path(p: BendList<Step>): BendList<Step>;
|
|
46
|
+
export declare function later_l(m: BendMaybe<Err>): BendMaybe<Err>;
|
|
47
|
+
export declare function later_i_path(p: BendList<Step>): BendList<Step>;
|
|
48
|
+
export declare function later_i(m: BendMaybe<Err>): BendMaybe<Err>;
|
|
49
|
+
export declare function later_f_path(p: BendList<Step>): BendList<Step>;
|
|
50
|
+
export declare function later_f(m: BendMaybe<Err>): BendMaybe<Err>;
|
|
51
|
+
export declare function first(m: BendMaybe<Err>, n: BendMaybe<Err>): BendMaybe<Err>;
|
|
52
|
+
export declare function missing_or(r: Raw, w: Why): Why;
|
|
53
|
+
export declare function pick_err(b: boolean, x: BendMaybe<Err>, y: BendMaybe<Err>): BendMaybe<Err>;
|
|
54
|
+
export declare function true_err(b: boolean): BendMaybe<Err>;
|
|
55
|
+
export declare function enum_err(b: boolean): BendMaybe<Err>;
|
|
56
|
+
export declare function dup_err(s: Schema, r: Raw): BendMaybe<Err>;
|
|
57
|
+
export declare function extra_err(ns: BendList<string>, r: Raw): BendMaybe<Err>;
|
|
58
|
+
export declare function tag_err(k: string, r: Raw): BendMaybe<Err>;
|
|
59
|
+
export declare function count_err(lo: bigint, hi: bigint, r: Raw): BendMaybe<Err>;
|
|
60
|
+
export declare function guard(b: boolean, m: BendMaybe<Why>): BendMaybe<Why>;
|
|
61
|
+
export declare function nat_in_defect(lo: bigint, hi: bigint, r: Raw, p: BendList<Step>): BendMaybe<Why>;
|
|
62
|
+
export declare function bool_defect(r: Raw, p: BendList<Step>): BendMaybe<Why>;
|
|
63
|
+
export declare function no_rule(tag: bigint, r: Raw): BendMaybe<Err>;
|
|
64
|
+
export declare function first_why(m: BendMaybe<Why>, n: BendMaybe<Why>): BendMaybe<Why>;
|
|
65
|
+
export declare function step_eq(x: Step, y: Step): boolean;
|
|
66
|
+
export declare function path_eq(x: BendList<Step>, y: BendList<Step>): boolean;
|
|
67
|
+
export declare function rule_defect(m: BendMaybe<Err>, p: BendList<Step>): BendMaybe<Why>;
|
|
68
|
+
export declare function not_list(x: Raw, p: BendList<Step>): BendMaybe<Why>;
|
|
69
|
+
export declare function not_object(x: Raw, p: BendList<Step>): BendMaybe<Why>;
|
|
70
|
+
export declare function nat_defect(r: Raw, p: BendList<Step>): BendMaybe<Why>;
|
|
71
|
+
export declare function str_defect(r: Raw, p: BendList<Step>): BendMaybe<Why>;
|
|
72
|
+
export declare function pick_why(b: boolean, x: BendMaybe<Why>, y: BendMaybe<Why>): BendMaybe<Why>;
|
|
73
|
+
export declare function true_defect(r: Raw, p: BendList<Step>): BendMaybe<Why>;
|
|
74
|
+
export declare function enum_defect(names: BendList<string>, r: Raw, p: BendList<Step>): BendMaybe<Why>;
|
|
75
|
+
export declare function no_variant(p: BendList<Step>): BendMaybe<Why>;
|
|
76
|
+
export declare function dup_defect(s: Schema, r: Raw, p: BendList<Step>): BendMaybe<Why>;
|
|
77
|
+
export declare function at_end(w: Why, p: BendList<Step>): BendMaybe<Why>;
|
|
78
|
+
export declare function extra_defect(ns: BendList<string>, r: Raw, p: BendList<Step>): BendMaybe<Why>;
|
|
79
|
+
export declare function tag_defect(k: string, r: Raw, p: BendList<Step>): BendMaybe<Why>;
|
|
80
|
+
export declare function tag_key_defect(b: boolean, k: string, p: BendList<Step>): BendMaybe<Why>;
|
|
81
|
+
export declare function check0(s: Schema, r: Raw): BendMaybe<Err>;
|
|
82
|
+
export declare function conforms0(s: Schema, r: Raw): boolean;
|
|
83
|
+
export declare function is_chain(s: Schema): boolean;
|
|
84
|
+
export declare function is_object(r: Raw): boolean;
|
|
85
|
+
export declare function one_if_there(b: boolean): bigint;
|
|
86
|
+
export declare function count_present(s: Schema, r: Raw): bigint;
|
|
87
|
+
export declare function tuple_of(ss: BendList<Schema>): Schema;
|
|
88
|
+
export declare function at_raw(r: Raw, i: bigint): Raw;
|
|
89
|
+
export declare function count_unknown(ns: BendList<string>, r: Raw): bigint;
|
|
90
|
+
export declare function true_unit(b: boolean): BendMaybe<BendUnit>;
|
|
91
|
+
export declare function nullish(r: Raw): boolean;
|
|
92
|
+
export declare function opt_at(s: Schema): boolean;
|
|
93
|
+
export declare function nullable(s: Schema): boolean;
|
|
94
|
+
export declare function no_key(k: string, s: Schema): boolean;
|
|
95
|
+
export declare function fresh_f(n: string, s: Schema): boolean;
|
|
96
|
+
export declare function fresh_v(n: string, s: Schema): boolean;
|
|
97
|
+
export declare function is_keyed(s: Schema): boolean;
|
|
98
|
+
export declare function fresh_t(k: string, n: string, s: Schema): boolean;
|
|
99
|
+
export declare function wf(s: Schema): boolean;
|
|
100
|
+
|
|
101
|
+
declare const core: {
|
|
102
|
+
"pick_raw"(b: boolean, x: Raw, y: Raw): Raw;
|
|
103
|
+
"lookup"(name: string, r: Raw): Raw;
|
|
104
|
+
"pick_bool"(b: boolean, x: boolean, y: boolean): boolean;
|
|
105
|
+
"is_rnil"(r: Raw): boolean;
|
|
106
|
+
"is_missing"(v: Raw): boolean;
|
|
107
|
+
"in_names"(x: string, names: BendList<string>): boolean;
|
|
108
|
+
"none_present"(s: Schema, r: Raw): boolean;
|
|
109
|
+
"key_names"(s: Schema): BendList<string>;
|
|
110
|
+
"no_extra"(ns: BendList<string>, r: Raw): boolean;
|
|
111
|
+
"drop_key"(k: string, r: Raw): Raw;
|
|
112
|
+
"is_str"(n: string, v: Raw): boolean;
|
|
113
|
+
"is_tag"(k: string, n: string, r: Raw): boolean;
|
|
114
|
+
"in_err"(b: boolean, w: Why): BendMaybe<Err>;
|
|
115
|
+
"str_len_ok"(lo: bigint, hi: bigint, x: string): boolean;
|
|
116
|
+
"num_ok"(lo: bigint, hi: bigint, n: bigint): boolean;
|
|
117
|
+
"len_ok"(lo: bigint, hi: bigint, r: Raw): boolean;
|
|
118
|
+
"str_len_in"(lo: bigint, hi: bigint, r: Raw): BendMaybe<Err>;
|
|
119
|
+
"nat_in"(lo: bigint, hi: bigint, r: Raw): BendMaybe<Err>;
|
|
120
|
+
"is_bool"(r: Raw): boolean;
|
|
121
|
+
"raw_list"(r: Raw): boolean;
|
|
122
|
+
"raw_len"(r: Raw): bigint;
|
|
123
|
+
"count_ok"(lo: bigint, hi: bigint, r: Raw): boolean;
|
|
124
|
+
"list_len_ok"(lo: bigint, hi: bigint, r: Raw): boolean;
|
|
125
|
+
"has_key"(k: string, r: Raw): boolean;
|
|
126
|
+
"key_once_at"(r: Raw, b: boolean, name: string): boolean;
|
|
127
|
+
"key_once"(name: string, r: Raw): boolean;
|
|
128
|
+
"key_err"(b: boolean, name: string): BendMaybe<Err>;
|
|
129
|
+
"here"(w: Why): BendMaybe<Err>;
|
|
130
|
+
"under"(st: Step, m: BendMaybe<Err>): BendMaybe<Err>;
|
|
131
|
+
"len_err"(lo: bigint, hi: bigint, r: Raw): BendMaybe<Err>;
|
|
132
|
+
"later_l_path"(p: BendList<Step>): BendList<Step>;
|
|
133
|
+
"later_l"(m: BendMaybe<Err>): BendMaybe<Err>;
|
|
134
|
+
"later_i_path"(p: BendList<Step>): BendList<Step>;
|
|
135
|
+
"later_i"(m: BendMaybe<Err>): BendMaybe<Err>;
|
|
136
|
+
"later_f_path"(p: BendList<Step>): BendList<Step>;
|
|
137
|
+
"later_f"(m: BendMaybe<Err>): BendMaybe<Err>;
|
|
138
|
+
"first"(m: BendMaybe<Err>, n: BendMaybe<Err>): BendMaybe<Err>;
|
|
139
|
+
"missing_or"(r: Raw, w: Why): Why;
|
|
140
|
+
"pick_err"(b: boolean, x: BendMaybe<Err>, y: BendMaybe<Err>): BendMaybe<Err>;
|
|
141
|
+
"true_err"(b: boolean): BendMaybe<Err>;
|
|
142
|
+
"enum_err"(b: boolean): BendMaybe<Err>;
|
|
143
|
+
"dup_err"(s: Schema, r: Raw): BendMaybe<Err>;
|
|
144
|
+
"extra_err"(ns: BendList<string>, r: Raw): BendMaybe<Err>;
|
|
145
|
+
"tag_err"(k: string, r: Raw): BendMaybe<Err>;
|
|
146
|
+
"count_err"(lo: bigint, hi: bigint, r: Raw): BendMaybe<Err>;
|
|
147
|
+
"guard"(b: boolean, m: BendMaybe<Why>): BendMaybe<Why>;
|
|
148
|
+
"nat_in_defect"(lo: bigint, hi: bigint, r: Raw, p: BendList<Step>): BendMaybe<Why>;
|
|
149
|
+
"bool_defect"(r: Raw, p: BendList<Step>): BendMaybe<Why>;
|
|
150
|
+
"no_rule"(tag: bigint, r: Raw): BendMaybe<Err>;
|
|
151
|
+
"first_why"(m: BendMaybe<Why>, n: BendMaybe<Why>): BendMaybe<Why>;
|
|
152
|
+
"step_eq"(x: Step, y: Step): boolean;
|
|
153
|
+
"path_eq"(x: BendList<Step>, y: BendList<Step>): boolean;
|
|
154
|
+
"rule_defect"(m: BendMaybe<Err>, p: BendList<Step>): BendMaybe<Why>;
|
|
155
|
+
"not_list"(x: Raw, p: BendList<Step>): BendMaybe<Why>;
|
|
156
|
+
"not_object"(x: Raw, p: BendList<Step>): BendMaybe<Why>;
|
|
157
|
+
"nat_defect"(r: Raw, p: BendList<Step>): BendMaybe<Why>;
|
|
158
|
+
"str_defect"(r: Raw, p: BendList<Step>): BendMaybe<Why>;
|
|
159
|
+
"pick_why"(b: boolean, x: BendMaybe<Why>, y: BendMaybe<Why>): BendMaybe<Why>;
|
|
160
|
+
"true_defect"(r: Raw, p: BendList<Step>): BendMaybe<Why>;
|
|
161
|
+
"enum_defect"(names: BendList<string>, r: Raw, p: BendList<Step>): BendMaybe<Why>;
|
|
162
|
+
"no_variant"(p: BendList<Step>): BendMaybe<Why>;
|
|
163
|
+
"dup_defect"(s: Schema, r: Raw, p: BendList<Step>): BendMaybe<Why>;
|
|
164
|
+
"at_end"(w: Why, p: BendList<Step>): BendMaybe<Why>;
|
|
165
|
+
"extra_defect"(ns: BendList<string>, r: Raw, p: BendList<Step>): BendMaybe<Why>;
|
|
166
|
+
"tag_defect"(k: string, r: Raw, p: BendList<Step>): BendMaybe<Why>;
|
|
167
|
+
"tag_key_defect"(b: boolean, k: string, p: BendList<Step>): BendMaybe<Why>;
|
|
168
|
+
"check0"(s: Schema, r: Raw): BendMaybe<Err>;
|
|
169
|
+
"conforms0"(s: Schema, r: Raw): boolean;
|
|
170
|
+
"is_chain"(s: Schema): boolean;
|
|
171
|
+
"is_object"(r: Raw): boolean;
|
|
172
|
+
"one_if_there"(b: boolean): bigint;
|
|
173
|
+
"count_present"(s: Schema, r: Raw): bigint;
|
|
174
|
+
"tuple_of"(ss: BendList<Schema>): Schema;
|
|
175
|
+
"at_raw"(r: Raw, i: bigint): Raw;
|
|
176
|
+
"count_unknown"(ns: BendList<string>, r: Raw): bigint;
|
|
177
|
+
"true_unit"(b: boolean): BendMaybe<BendUnit>;
|
|
178
|
+
"nullish"(r: Raw): boolean;
|
|
179
|
+
"opt_at"(s: Schema): boolean;
|
|
180
|
+
"nullable"(s: Schema): boolean;
|
|
181
|
+
"no_key"(k: string, s: Schema): boolean;
|
|
182
|
+
"fresh_f"(n: string, s: Schema): boolean;
|
|
183
|
+
"fresh_v"(n: string, s: Schema): boolean;
|
|
184
|
+
"is_keyed"(s: Schema): boolean;
|
|
185
|
+
"fresh_t"(k: string, n: string, s: Schema): boolean;
|
|
186
|
+
"wf"(s: Schema): boolean;
|
|
187
|
+
};
|
|
188
|
+
export default core;
|