forked from rescript-lang/rescript
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathbelt_Map.js
374 lines (313 loc) · 7.04 KB
/
belt_Map.js
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
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
'use strict';
var Curry = require("./curry.js");
var Belt_MapDict = require("./belt_MapDict.js");
function fromArray(data, id) {
var cmp = id.cmp;
return {
cmp: cmp,
data: Belt_MapDict.fromArray(data, cmp)
};
}
function remove(m, x) {
var odata = m.data;
var cmp = m.cmp;
var newData = Belt_MapDict.remove(odata, x, cmp);
if (newData === odata) {
return m;
} else {
return {
cmp: cmp,
data: newData
};
}
}
function removeMany(m, x) {
var cmp = m.cmp;
var newData = Belt_MapDict.removeMany(m.data, x, cmp);
return {
cmp: cmp,
data: newData
};
}
function set(m, key, d) {
var cmp = m.cmp;
return {
cmp: cmp,
data: Belt_MapDict.set(m.data, key, d, cmp)
};
}
function mergeMany(m, e) {
var cmp = m.cmp;
return {
cmp: cmp,
data: Belt_MapDict.mergeMany(m.data, e, cmp)
};
}
function updateU(m, key, f) {
var cmp = m.cmp;
return {
cmp: cmp,
data: Belt_MapDict.updateU(m.data, key, f, cmp)
};
}
function update(m, key, f) {
return updateU(m, key, Curry.__1(f));
}
function split(m, x) {
var cmp = m.cmp;
var match = Belt_MapDict.split(m.data, x, cmp);
var match$1 = match[0];
return [
[
{
cmp: cmp,
data: match$1[0]
},
{
cmp: cmp,
data: match$1[1]
}
],
match[1]
];
}
function mergeU(s1, s2, f) {
var cmp = s1.cmp;
return {
cmp: cmp,
data: Belt_MapDict.mergeU(s1.data, s2.data, f, cmp)
};
}
function merge(s1, s2, f) {
return mergeU(s1, s2, Curry.__3(f));
}
function make(id) {
return {
cmp: id.cmp,
data: undefined
};
}
function isEmpty(map) {
return Belt_MapDict.isEmpty(map.data);
}
function findFirstByU(m, f) {
return Belt_MapDict.findFirstByU(m.data, f);
}
function findFirstBy(m, f) {
return Belt_MapDict.findFirstByU(m.data, Curry.__2(f));
}
function forEachU(m, f) {
Belt_MapDict.forEachU(m.data, f);
}
function forEach(m, f) {
Belt_MapDict.forEachU(m.data, Curry.__2(f));
}
function reduceU(m, acc, f) {
return Belt_MapDict.reduceU(m.data, acc, f);
}
function reduce(m, acc, f) {
return reduceU(m, acc, Curry.__3(f));
}
function everyU(m, f) {
return Belt_MapDict.everyU(m.data, f);
}
function every(m, f) {
return Belt_MapDict.everyU(m.data, Curry.__2(f));
}
function someU(m, f) {
return Belt_MapDict.someU(m.data, f);
}
function some(m, f) {
return Belt_MapDict.someU(m.data, Curry.__2(f));
}
function keepU(m, f) {
return {
cmp: m.cmp,
data: Belt_MapDict.keepU(m.data, f)
};
}
function keep(m, f) {
return keepU(m, Curry.__2(f));
}
function partitionU(m, p) {
var cmp = m.cmp;
var match = Belt_MapDict.partitionU(m.data, p);
return [
{
cmp: cmp,
data: match[0]
},
{
cmp: cmp,
data: match[1]
}
];
}
function partition(m, p) {
return partitionU(m, Curry.__2(p));
}
function mapU(m, f) {
return {
cmp: m.cmp,
data: Belt_MapDict.mapU(m.data, f)
};
}
function map(m, f) {
return mapU(m, Curry.__1(f));
}
function mapWithKeyU(m, f) {
return {
cmp: m.cmp,
data: Belt_MapDict.mapWithKeyU(m.data, f)
};
}
function mapWithKey(m, f) {
return mapWithKeyU(m, Curry.__2(f));
}
function size(map) {
return Belt_MapDict.size(map.data);
}
function toList(map) {
return Belt_MapDict.toList(map.data);
}
function toArray(m) {
return Belt_MapDict.toArray(m.data);
}
function keysToArray(m) {
return Belt_MapDict.keysToArray(m.data);
}
function valuesToArray(m) {
return Belt_MapDict.valuesToArray(m.data);
}
function minKey(m) {
return Belt_MapDict.minKey(m.data);
}
function minKeyUndefined(m) {
return Belt_MapDict.minKeyUndefined(m.data);
}
function maxKey(m) {
return Belt_MapDict.maxKey(m.data);
}
function maxKeyUndefined(m) {
return Belt_MapDict.maxKeyUndefined(m.data);
}
function minimum(m) {
return Belt_MapDict.minimum(m.data);
}
function minUndefined(m) {
return Belt_MapDict.minUndefined(m.data);
}
function maximum(m) {
return Belt_MapDict.maximum(m.data);
}
function maxUndefined(m) {
return Belt_MapDict.maxUndefined(m.data);
}
function get(map, x) {
return Belt_MapDict.get(map.data, x, map.cmp);
}
function getUndefined(map, x) {
return Belt_MapDict.getUndefined(map.data, x, map.cmp);
}
function getWithDefault(map, x, def) {
return Belt_MapDict.getWithDefault(map.data, x, def, map.cmp);
}
function getExn(map, x) {
return Belt_MapDict.getExn(map.data, x, map.cmp);
}
function has(map, x) {
return Belt_MapDict.has(map.data, x, map.cmp);
}
function checkInvariantInternal(m) {
Belt_MapDict.checkInvariantInternal(m.data);
}
function eqU(m1, m2, veq) {
return Belt_MapDict.eqU(m1.data, m2.data, m1.cmp, veq);
}
function eq(m1, m2, veq) {
return eqU(m1, m2, Curry.__2(veq));
}
function cmpU(m1, m2, vcmp) {
return Belt_MapDict.cmpU(m1.data, m2.data, m1.cmp, vcmp);
}
function cmp(m1, m2, vcmp) {
return cmpU(m1, m2, Curry.__2(vcmp));
}
function getData(m) {
return m.data;
}
function getId(m) {
var cmp = m.cmp;
return {
cmp: cmp
};
}
function packIdData(id, data) {
return {
cmp: id.cmp,
data: data
};
}
var Int;
var $$String;
var Dict;
exports.Int = Int;
exports.$$String = $$String;
exports.Dict = Dict;
exports.make = make;
exports.isEmpty = isEmpty;
exports.has = has;
exports.cmpU = cmpU;
exports.cmp = cmp;
exports.eqU = eqU;
exports.eq = eq;
exports.findFirstByU = findFirstByU;
exports.findFirstBy = findFirstBy;
exports.forEachU = forEachU;
exports.forEach = forEach;
exports.reduceU = reduceU;
exports.reduce = reduce;
exports.everyU = everyU;
exports.every = every;
exports.someU = someU;
exports.some = some;
exports.size = size;
exports.toArray = toArray;
exports.toList = toList;
exports.fromArray = fromArray;
exports.keysToArray = keysToArray;
exports.valuesToArray = valuesToArray;
exports.minKey = minKey;
exports.minKeyUndefined = minKeyUndefined;
exports.maxKey = maxKey;
exports.maxKeyUndefined = maxKeyUndefined;
exports.minimum = minimum;
exports.minUndefined = minUndefined;
exports.maximum = maximum;
exports.maxUndefined = maxUndefined;
exports.get = get;
exports.getUndefined = getUndefined;
exports.getWithDefault = getWithDefault;
exports.getExn = getExn;
exports.remove = remove;
exports.removeMany = removeMany;
exports.set = set;
exports.updateU = updateU;
exports.update = update;
exports.mergeMany = mergeMany;
exports.mergeU = mergeU;
exports.merge = merge;
exports.keepU = keepU;
exports.keep = keep;
exports.partitionU = partitionU;
exports.partition = partition;
exports.split = split;
exports.mapU = mapU;
exports.map = map;
exports.mapWithKeyU = mapWithKeyU;
exports.mapWithKey = mapWithKey;
exports.getData = getData;
exports.getId = getId;
exports.packIdData = packIdData;
exports.checkInvariantInternal = checkInvariantInternal;
/* No side effect */