@magnusopera/fscript 0.80.1 → 0.81.1

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.
@@ -8,12 +8,13 @@ import { Span, Position } from "./Span.js";
8
8
  import { printf, toText, join, concat } from "../fable_modules/fable-library-js.5.13.0/String.js";
9
9
  import { curry2, disposeSafe, getEnumerator, equals as equals_1, compare, comparePrimitives, int64ToString } from "../fable_modules/fable-library-js.5.13.0/Util.js";
10
10
  import { ofArray, collect, tryFindIndex, choose, tryFind as tryFind_1, tryPick as tryPick_1, append, reverse, zip, fold as fold_1, singleton, forAll as forAll_1, empty, cons, tail as tail_2, head as head_2, isEmpty, forAll2, length, map } from "../fable_modules/fable-library-js.5.13.0/List.js";
11
- import { map as map_1, containsKey, FSharpMap__Add, fold, empty as empty_1, FSharpMap__Remove, FSharpMap__get_IsEmpty, FSharpMap__ContainsKey, add, FSharpMap__TryFind, tryFind, toSeq, ofList, FSharpMap__get_Item, forAll, FSharpMap__get_Keys, FSharpMap__get_Count, toList } from "../fable_modules/fable-library-js.5.13.0/Map.js";
11
+ import { keys, map as map_1, containsKey, FSharpMap__Add, fold, empty as empty_1, FSharpMap__Remove, FSharpMap__get_IsEmpty, FSharpMap__ContainsKey, add, FSharpMap__TryFind, tryFind, toSeq, ofList, FSharpMap__get_Item, forAll, FSharpMap__get_Keys, FSharpMap__get_Count, toList } from "../fable_modules/fable-library-js.5.13.0/Map.js";
12
12
  import { op_Modulus, op_Division, op_Multiply, op_Subtraction, op_Addition, toInt64_unchecked, compare as compare_1, equals } from "../fable_modules/fable-library-js.5.13.0/BigInt.js";
13
13
  import { contains, ofSeq } from "../fable_modules/fable-library-js.5.13.0/Set.js";
14
+ import { ofExterns, typeDefinitions, invoke, matches, $007CRecordFields$007C_$007C } from "./HostInterop.js";
14
15
  import { Ast_spanOfExpr, Expr, Ast_spanOfPattern, TypeRef } from "./Ast.js";
15
- import { filter, length as length_1, foldBack, head as head_3, tryPick } from "../fable_modules/fable-library-js.5.13.0/Seq.js";
16
- import { some } from "../fable_modules/fable-library-js.5.13.0/Option.js";
16
+ import { toList as toList_1, filter, length as length_1, foldBack, head as head_3, exists, tryPick } from "../fable_modules/fable-library-js.5.13.0/Seq.js";
17
+ import { some, toArray } from "../fable_modules/fable-library-js.5.13.0/Option.js";
17
18
  import { StringBuilder__Append_Z721C83C5, StringBuilder_$ctor } from "../fable_modules/fable-library-js.5.13.0/System.Text.js";
18
19
  import { builtinReservedNames } from "./BuiltinSignatures.js";
19
20
  import { typeDefs as typeDefs_3 } from "./BuiltinTypes.js";
@@ -84,33 +85,129 @@ function literalToValue(lit) {
84
85
  }
85
86
 
86
87
  function valueToInterpolationString(v) {
88
+ let matchResult, i, f, b, s, xs, xs_1, fields, fields_1, value_2, caseName_1, caseName_2, value_3, t, caseName_3;
87
89
  switch (v.tag) {
90
+ case 1: {
91
+ matchResult = 1;
92
+ i = v.fields[0];
93
+ break;
94
+ }
95
+ case 2: {
96
+ matchResult = 2;
97
+ f = v.fields[0];
98
+ break;
99
+ }
100
+ case 3: {
101
+ matchResult = 3;
102
+ b = v.fields[0];
103
+ break;
104
+ }
105
+ case 4: {
106
+ matchResult = 4;
107
+ s = v.fields[0];
108
+ break;
109
+ }
110
+ case 5: {
111
+ matchResult = 5;
112
+ xs = v.fields[0];
113
+ break;
114
+ }
115
+ case 6: {
116
+ matchResult = 6;
117
+ xs_1 = v.fields[0];
118
+ break;
119
+ }
120
+ case 7: {
121
+ matchResult = 7;
122
+ fields = v.fields[0];
123
+ break;
124
+ }
125
+ case 16: {
126
+ matchResult = 7;
127
+ fields = v.fields[0].Fields;
128
+ break;
129
+ }
130
+ case 8: {
131
+ matchResult = 8;
132
+ fields_1 = v.fields[0];
133
+ break;
134
+ }
135
+ case 9: {
136
+ if (v.fields[0] != null) {
137
+ matchResult = 10;
138
+ value_2 = v.fields[0];
139
+ }
140
+ else {
141
+ matchResult = 9;
142
+ }
143
+ break;
144
+ }
145
+ case 10: {
146
+ if (v.fields[2] != null) {
147
+ matchResult = 12;
148
+ caseName_2 = v.fields[1];
149
+ value_3 = v.fields[2];
150
+ }
151
+ else {
152
+ matchResult = 11;
153
+ caseName_1 = v.fields[1];
154
+ }
155
+ break;
156
+ }
157
+ case 12: {
158
+ matchResult = 13;
159
+ t = v.fields[0];
160
+ break;
161
+ }
162
+ case 13: {
163
+ matchResult = 14;
164
+ break;
165
+ }
166
+ case 14: {
167
+ matchResult = 15;
168
+ break;
169
+ }
170
+ case 11: {
171
+ matchResult = 16;
172
+ caseName_3 = v.fields[1];
173
+ break;
174
+ }
175
+ case 15: {
176
+ matchResult = 17;
177
+ break;
178
+ }
179
+ default:
180
+ matchResult = 0;
181
+ }
182
+ switch (matchResult) {
183
+ case 0:
184
+ return "()";
88
185
  case 1:
89
- return int64ToString(v.fields[0]);
186
+ return int64ToString(i);
90
187
  case 2:
91
- return v.fields[0].toString();
188
+ return f.toString();
92
189
  case 3:
93
- if (v.fields[0]) {
190
+ if (b) {
94
191
  return "true";
95
192
  }
96
193
  else {
97
194
  return "false";
98
195
  }
99
196
  case 4:
100
- return v.fields[0];
197
+ return s;
101
198
  case 5: {
102
- const arg = join(";", map(valueToInterpolationString, v.fields[0]));
199
+ const arg = join(";", map(valueToInterpolationString, xs));
103
200
  return toText(printf("[%s]"))(arg);
104
201
  }
105
202
  case 6: {
106
- const arg_1 = join(", ", map(valueToInterpolationString, v.fields[0]));
203
+ const arg_1 = join(", ", map(valueToInterpolationString, xs_1));
107
204
  return toText(printf("(%s)"))(arg_1);
108
205
  }
109
206
  case 7: {
110
207
  const arg_4 = join("; ", map((tupledArg) => {
111
208
  const arg_3 = valueToInterpolationString(tupledArg[1]);
112
209
  return toText(printf("%s = %s"))(tupledArg[0])(arg_3);
113
- }, toList(v.fields[0])));
210
+ }, toList(fields)));
114
211
  return toText(printf("{ %s }"))(arg_4);
115
212
  }
116
213
  case 8: {
@@ -120,41 +217,33 @@ function valueToInterpolationString(v) {
120
217
  arg_5 = ((key.tag === 1) ? int64ToString(key.fields[0]) : ((key.tag === 2) ? (key.fields[0] ? "true" : "false") : ((key.tag === 3) ? concat(key.fields[0], ".", key.fields[1]) : concat("\"", key.fields[0], "\""))));
121
218
  const arg_6 = valueToInterpolationString(tupledArg_1[1]);
122
219
  return toText(printf("%s => %s"))(arg_5)(arg_6);
123
- }, toList(v.fields[0])));
220
+ }, toList(fields_1)));
124
221
  return toText(printf("map { %s }"))(arg_7);
125
222
  }
126
223
  case 9:
127
- if (v.fields[0] != null) {
128
- const value_2 = v.fields[0];
129
- const arg_8 = valueToInterpolationString(value_2);
130
- return toText(printf("Some %s"))(arg_8);
131
- }
132
- else {
133
- return "None";
134
- }
135
- case 10:
136
- if (v.fields[2] != null) {
137
- const value_3 = v.fields[2];
138
- const arg_10 = valueToInterpolationString(value_3);
139
- return toText(printf("%s %s"))(v.fields[1])(arg_10);
140
- }
141
- else {
142
- return v.fields[1];
143
- }
224
+ return "None";
225
+ case 10: {
226
+ const arg_8 = valueToInterpolationString(value_2);
227
+ return toText(printf("Some %s"))(arg_8);
228
+ }
229
+ case 11:
230
+ return caseName_1;
144
231
  case 12: {
145
- const arg_11 = Types_typeToString(v.fields[0]);
232
+ const arg_10 = valueToInterpolationString(value_3);
233
+ return toText(printf("%s %s"))(caseName_2)(arg_10);
234
+ }
235
+ case 13: {
236
+ const arg_11 = Types_typeToString(t);
146
237
  return toText(printf("<type %s>"))(arg_11);
147
238
  }
148
- case 13:
149
- return "<task>";
150
239
  case 14:
151
- return "<fun>";
152
- case 11:
153
- return toText(printf("<ctor %s>"))(v.fields[1]);
240
+ return "<task>";
154
241
  case 15:
155
- return "<extern>";
242
+ return "<fun>";
243
+ case 16:
244
+ return toText(printf("<ctor %s>"))(caseName_3);
156
245
  default:
157
- return "()";
246
+ return "<extern>";
158
247
  }
159
248
  }
160
249
 
@@ -162,14 +251,28 @@ function valueEquals(a_mut, b_mut) {
162
251
  valueEquals:
163
252
  while (true) {
164
253
  const a = a_mut, b = b_mut;
165
- let matchResult, x, y, x_1, y_1, x_2, y_2, x_3, y_3, xs, ys, xs_1, ys_1, xf, yf, xf_1, yf_1, x_8, y_8, cx, cy, px, py, tx, ty, tx_1, ty_1, tx_2, ty_2;
254
+ let matchResult, x, y, x_1, y_1, x_2, y_2, x_3, y_3, xs, ys, xs_1, ys_1, xf, yf;
166
255
  switch (a.tag) {
167
256
  case 0: {
168
257
  if (b.tag === 0) {
169
258
  matchResult = 0;
170
259
  }
171
260
  else {
172
- matchResult = 14;
261
+ const activePatternResult = $007CRecordFields$007C_$007C(a);
262
+ if (activePatternResult != null) {
263
+ const activePatternResult_1 = $007CRecordFields$007C_$007C(b);
264
+ if (activePatternResult_1 != null) {
265
+ matchResult = 7;
266
+ xf = activePatternResult;
267
+ yf = activePatternResult_1;
268
+ }
269
+ else {
270
+ matchResult = 8;
271
+ }
272
+ }
273
+ else {
274
+ matchResult = 8;
275
+ }
173
276
  }
174
277
  break;
175
278
  }
@@ -180,7 +283,21 @@ function valueEquals(a_mut, b_mut) {
180
283
  y = b.fields[0];
181
284
  }
182
285
  else {
183
- matchResult = 14;
286
+ const activePatternResult_2 = $007CRecordFields$007C_$007C(a);
287
+ if (activePatternResult_2 != null) {
288
+ const activePatternResult_3 = $007CRecordFields$007C_$007C(b);
289
+ if (activePatternResult_3 != null) {
290
+ matchResult = 7;
291
+ xf = activePatternResult_2;
292
+ yf = activePatternResult_3;
293
+ }
294
+ else {
295
+ matchResult = 8;
296
+ }
297
+ }
298
+ else {
299
+ matchResult = 8;
300
+ }
184
301
  }
185
302
  break;
186
303
  }
@@ -191,7 +308,21 @@ function valueEquals(a_mut, b_mut) {
191
308
  y_1 = b.fields[0];
192
309
  }
193
310
  else {
194
- matchResult = 14;
311
+ const activePatternResult_4 = $007CRecordFields$007C_$007C(a);
312
+ if (activePatternResult_4 != null) {
313
+ const activePatternResult_5 = $007CRecordFields$007C_$007C(b);
314
+ if (activePatternResult_5 != null) {
315
+ matchResult = 7;
316
+ xf = activePatternResult_4;
317
+ yf = activePatternResult_5;
318
+ }
319
+ else {
320
+ matchResult = 8;
321
+ }
322
+ }
323
+ else {
324
+ matchResult = 8;
325
+ }
195
326
  }
196
327
  break;
197
328
  }
@@ -202,7 +333,21 @@ function valueEquals(a_mut, b_mut) {
202
333
  y_2 = b.fields[0];
203
334
  }
204
335
  else {
205
- matchResult = 14;
336
+ const activePatternResult_6 = $007CRecordFields$007C_$007C(a);
337
+ if (activePatternResult_6 != null) {
338
+ const activePatternResult_7 = $007CRecordFields$007C_$007C(b);
339
+ if (activePatternResult_7 != null) {
340
+ matchResult = 7;
341
+ xf = activePatternResult_6;
342
+ yf = activePatternResult_7;
343
+ }
344
+ else {
345
+ matchResult = 8;
346
+ }
347
+ }
348
+ else {
349
+ matchResult = 8;
350
+ }
206
351
  }
207
352
  break;
208
353
  }
@@ -213,7 +358,21 @@ function valueEquals(a_mut, b_mut) {
213
358
  y_3 = b.fields[0];
214
359
  }
215
360
  else {
216
- matchResult = 14;
361
+ const activePatternResult_8 = $007CRecordFields$007C_$007C(a);
362
+ if (activePatternResult_8 != null) {
363
+ const activePatternResult_9 = $007CRecordFields$007C_$007C(b);
364
+ if (activePatternResult_9 != null) {
365
+ matchResult = 7;
366
+ xf = activePatternResult_8;
367
+ yf = activePatternResult_9;
368
+ }
369
+ else {
370
+ matchResult = 8;
371
+ }
372
+ }
373
+ else {
374
+ matchResult = 8;
375
+ }
217
376
  }
218
377
  break;
219
378
  }
@@ -224,7 +383,21 @@ function valueEquals(a_mut, b_mut) {
224
383
  ys = b.fields[0];
225
384
  }
226
385
  else {
227
- matchResult = 14;
386
+ const activePatternResult_10 = $007CRecordFields$007C_$007C(a);
387
+ if (activePatternResult_10 != null) {
388
+ const activePatternResult_11 = $007CRecordFields$007C_$007C(b);
389
+ if (activePatternResult_11 != null) {
390
+ matchResult = 7;
391
+ xf = activePatternResult_10;
392
+ yf = activePatternResult_11;
393
+ }
394
+ else {
395
+ matchResult = 8;
396
+ }
397
+ }
398
+ else {
399
+ matchResult = 8;
400
+ }
228
401
  }
229
402
  break;
230
403
  }
@@ -235,100 +408,41 @@ function valueEquals(a_mut, b_mut) {
235
408
  ys_1 = b.fields[0];
236
409
  }
237
410
  else {
238
- matchResult = 14;
239
- }
240
- break;
241
- }
242
- case 7: {
243
- if (b.tag === 7) {
244
- matchResult = 7;
245
- xf = a.fields[0];
246
- yf = b.fields[0];
247
- }
248
- else {
249
- matchResult = 14;
250
- }
251
- break;
252
- }
253
- case 8: {
254
- if (b.tag === 8) {
255
- matchResult = 8;
256
- xf_1 = a.fields[0];
257
- yf_1 = b.fields[0];
258
- }
259
- else {
260
- matchResult = 14;
261
- }
262
- break;
263
- }
264
- case 9: {
265
- if (a.fields[0] != null) {
266
- if (b.tag === 9) {
267
- if (b.fields[0] != null) {
268
- matchResult = 10;
269
- x_8 = a.fields[0];
270
- y_8 = b.fields[0];
411
+ const activePatternResult_12 = $007CRecordFields$007C_$007C(a);
412
+ if (activePatternResult_12 != null) {
413
+ const activePatternResult_13 = $007CRecordFields$007C_$007C(b);
414
+ if (activePatternResult_13 != null) {
415
+ matchResult = 7;
416
+ xf = activePatternResult_12;
417
+ yf = activePatternResult_13;
271
418
  }
272
419
  else {
273
- matchResult = 14;
420
+ matchResult = 8;
274
421
  }
275
422
  }
276
423
  else {
277
- matchResult = 14;
424
+ matchResult = 8;
278
425
  }
279
426
  }
280
- else if (b.tag === 9) {
281
- if (b.fields[0] == null) {
282
- matchResult = 9;
427
+ break;
428
+ }
429
+ default: {
430
+ const activePatternResult_14 = $007CRecordFields$007C_$007C(a);
431
+ if (activePatternResult_14 != null) {
432
+ const activePatternResult_15 = $007CRecordFields$007C_$007C(b);
433
+ if (activePatternResult_15 != null) {
434
+ matchResult = 7;
435
+ xf = activePatternResult_14;
436
+ yf = activePatternResult_15;
283
437
  }
284
438
  else {
285
- matchResult = 14;
439
+ matchResult = 8;
286
440
  }
287
441
  }
288
442
  else {
289
- matchResult = 14;
290
- }
291
- break;
292
- }
293
- case 10: {
294
- if (b.tag === 10) {
295
- matchResult = 11;
296
- cx = a.fields[1];
297
- cy = b.fields[1];
298
- px = a.fields[2];
299
- py = b.fields[2];
300
- tx = a.fields[0];
301
- ty = b.fields[0];
302
- }
303
- else {
304
- matchResult = 14;
305
- }
306
- break;
307
- }
308
- case 12: {
309
- if (b.tag === 12) {
310
- matchResult = 12;
311
- tx_1 = a.fields[0];
312
- ty_1 = b.fields[0];
313
- }
314
- else {
315
- matchResult = 14;
316
- }
317
- break;
318
- }
319
- case 13: {
320
- if (b.tag === 13) {
321
- matchResult = 13;
322
- tx_2 = a.fields[0];
323
- ty_2 = b.fields[0];
324
- }
325
- else {
326
- matchResult = 14;
443
+ matchResult = 8;
327
444
  }
328
- break;
329
445
  }
330
- default:
331
- matchResult = 14;
332
446
  }
333
447
  switch (matchResult) {
334
448
  case 0:
@@ -366,64 +480,150 @@ function valueEquals(a_mut, b_mut) {
366
480
  else {
367
481
  return false;
368
482
  }
369
- case 8:
370
- if ((FSharpMap__get_Count(xf_1) === FSharpMap__get_Count(yf_1)) && ofSeq(FSharpMap__get_Keys(xf_1), {
371
- Compare: (x_6, y_6) => (compare(x_6, y_6) | 0),
372
- }).Equals(ofSeq(FSharpMap__get_Keys(yf_1), {
373
- Compare: (x_7, y_7) => (compare(x_7, y_7) | 0),
374
- }))) {
375
- return forAll((k_1, xv_1) => valueEquals(xv_1, FSharpMap__get_Item(yf_1, k_1)), xf_1);
376
- }
377
- else {
378
- return false;
379
- }
380
- case 9:
381
- return true;
382
- case 10: {
383
- a_mut = x_8;
384
- b_mut = y_8;
385
- continue valueEquals;
386
- }
387
- case 11:
388
- if ((tx === ty) && (cx === cy)) {
389
- let matchResult_1, xv_2, yv;
390
- if (px != null) {
391
- if (py != null) {
392
- matchResult_1 = 1;
393
- xv_2 = px;
394
- yv = py;
483
+ default: {
484
+ let matchResult_1, xf_1, yf_1, x_8, y_8, cx, cy, px, py, tx, ty, tx_1, ty_1, tx_2, ty_2;
485
+ switch (a.tag) {
486
+ case 8: {
487
+ if (b.tag === 8) {
488
+ matchResult_1 = 0;
489
+ xf_1 = a.fields[0];
490
+ yf_1 = b.fields[0];
395
491
  }
396
492
  else {
397
- matchResult_1 = 2;
493
+ matchResult_1 = 6;
398
494
  }
495
+ break;
399
496
  }
400
- else if (py == null) {
401
- matchResult_1 = 0;
497
+ case 9: {
498
+ if (a.fields[0] != null) {
499
+ if (b.tag === 9) {
500
+ if (b.fields[0] != null) {
501
+ matchResult_1 = 2;
502
+ x_8 = a.fields[0];
503
+ y_8 = b.fields[0];
504
+ }
505
+ else {
506
+ matchResult_1 = 6;
507
+ }
508
+ }
509
+ else {
510
+ matchResult_1 = 6;
511
+ }
512
+ }
513
+ else if (b.tag === 9) {
514
+ if (b.fields[0] == null) {
515
+ matchResult_1 = 1;
516
+ }
517
+ else {
518
+ matchResult_1 = 6;
519
+ }
520
+ }
521
+ else {
522
+ matchResult_1 = 6;
523
+ }
524
+ break;
402
525
  }
403
- else {
404
- matchResult_1 = 2;
526
+ case 10: {
527
+ if (b.tag === 10) {
528
+ matchResult_1 = 3;
529
+ cx = a.fields[1];
530
+ cy = b.fields[1];
531
+ px = a.fields[2];
532
+ py = b.fields[2];
533
+ tx = a.fields[0];
534
+ ty = b.fields[0];
535
+ }
536
+ else {
537
+ matchResult_1 = 6;
538
+ }
539
+ break;
405
540
  }
406
- switch (matchResult_1) {
407
- case 0:
408
- return true;
409
- case 1: {
410
- a_mut = xv_2;
411
- b_mut = yv;
412
- continue valueEquals;
541
+ case 12: {
542
+ if (b.tag === 12) {
543
+ matchResult_1 = 4;
544
+ tx_1 = a.fields[0];
545
+ ty_1 = b.fields[0];
413
546
  }
414
- default:
415
- return false;
547
+ else {
548
+ matchResult_1 = 6;
549
+ }
550
+ break;
416
551
  }
552
+ case 13: {
553
+ if (b.tag === 13) {
554
+ matchResult_1 = 5;
555
+ tx_2 = a.fields[0];
556
+ ty_2 = b.fields[0];
557
+ }
558
+ else {
559
+ matchResult_1 = 6;
560
+ }
561
+ break;
562
+ }
563
+ default:
564
+ matchResult_1 = 6;
417
565
  }
418
- else {
419
- return false;
566
+ switch (matchResult_1) {
567
+ case 0:
568
+ if ((FSharpMap__get_Count(xf_1) === FSharpMap__get_Count(yf_1)) && ofSeq(FSharpMap__get_Keys(xf_1), {
569
+ Compare: (x_6, y_6) => (compare(x_6, y_6) | 0),
570
+ }).Equals(ofSeq(FSharpMap__get_Keys(yf_1), {
571
+ Compare: (x_7, y_7) => (compare(x_7, y_7) | 0),
572
+ }))) {
573
+ return forAll((k_1, xv_1) => valueEquals(xv_1, FSharpMap__get_Item(yf_1, k_1)), xf_1);
574
+ }
575
+ else {
576
+ return false;
577
+ }
578
+ case 1:
579
+ return true;
580
+ case 2: {
581
+ a_mut = x_8;
582
+ b_mut = y_8;
583
+ continue valueEquals;
584
+ }
585
+ case 3:
586
+ if ((tx === ty) && (cx === cy)) {
587
+ let matchResult_2, xv_2, yv;
588
+ if (px != null) {
589
+ if (py != null) {
590
+ matchResult_2 = 1;
591
+ xv_2 = px;
592
+ yv = py;
593
+ }
594
+ else {
595
+ matchResult_2 = 2;
596
+ }
597
+ }
598
+ else if (py == null) {
599
+ matchResult_2 = 0;
600
+ }
601
+ else {
602
+ matchResult_2 = 2;
603
+ }
604
+ switch (matchResult_2) {
605
+ case 0:
606
+ return true;
607
+ case 1: {
608
+ a_mut = xv_2;
609
+ b_mut = yv;
610
+ continue valueEquals;
611
+ }
612
+ default:
613
+ return false;
614
+ }
615
+ }
616
+ else {
617
+ return false;
618
+ }
619
+ case 4:
620
+ return equals_1(tx_1, ty_1);
621
+ case 5:
622
+ return tx_2 === ty_2;
623
+ default:
624
+ return false;
420
625
  }
421
- case 12:
422
- return equals_1(tx_1, ty_1);
423
- case 13:
424
- return tx_2 === ty_2;
425
- default:
426
- return false;
626
+ }
427
627
  }
428
628
  break;
429
629
  }
@@ -692,14 +892,14 @@ function valueMatchesTypeRef(typeDefs, tref, value) {
692
892
  valueHasType:
693
893
  while (true) {
694
894
  const value_2 = value_2_mut, t_4 = t_4_mut;
695
- let matchResult_4, inner_4, items_1, inner_5, items_2, inner_6, inner_7, v_1, fields_3, values, name_4, v_2;
895
+ let matchResult_4, inner_4, items_1, inner_5, items_2, inner_6, inner_7, v_1, fields_3, values, fields_4, values_1, name_5, v_2;
696
896
  switch (t_4.tag) {
697
897
  case 0: {
698
898
  if (value_2.tag === 0) {
699
899
  matchResult_4 = 0;
700
900
  }
701
901
  else {
702
- matchResult_4 = 13;
902
+ matchResult_4 = 15;
703
903
  }
704
904
  break;
705
905
  }
@@ -708,7 +908,7 @@ function valueMatchesTypeRef(typeDefs, tref, value) {
708
908
  matchResult_4 = 1;
709
909
  }
710
910
  else {
711
- matchResult_4 = 13;
911
+ matchResult_4 = 15;
712
912
  }
713
913
  break;
714
914
  }
@@ -717,7 +917,7 @@ function valueMatchesTypeRef(typeDefs, tref, value) {
717
917
  matchResult_4 = 2;
718
918
  }
719
919
  else {
720
- matchResult_4 = 13;
920
+ matchResult_4 = 15;
721
921
  }
722
922
  break;
723
923
  }
@@ -726,7 +926,7 @@ function valueMatchesTypeRef(typeDefs, tref, value) {
726
926
  matchResult_4 = 3;
727
927
  }
728
928
  else {
729
- matchResult_4 = 13;
929
+ matchResult_4 = 15;
730
930
  }
731
931
  break;
732
932
  }
@@ -735,7 +935,7 @@ function valueMatchesTypeRef(typeDefs, tref, value) {
735
935
  matchResult_4 = 4;
736
936
  }
737
937
  else {
738
- matchResult_4 = 13;
938
+ matchResult_4 = 15;
739
939
  }
740
940
  break;
741
941
  }
@@ -746,7 +946,7 @@ function valueMatchesTypeRef(typeDefs, tref, value) {
746
946
  items_1 = value_2.fields[0];
747
947
  }
748
948
  else {
749
- matchResult_4 = 13;
949
+ matchResult_4 = 15;
750
950
  }
751
951
  break;
752
952
  }
@@ -755,7 +955,7 @@ function valueMatchesTypeRef(typeDefs, tref, value) {
755
955
  matchResult_4 = 6;
756
956
  }
757
957
  else {
758
- matchResult_4 = 13;
958
+ matchResult_4 = 15;
759
959
  }
760
960
  break;
761
961
  }
@@ -766,7 +966,7 @@ function valueMatchesTypeRef(typeDefs, tref, value) {
766
966
  items_2 = value_2.fields[0];
767
967
  }
768
968
  else {
769
- matchResult_4 = 13;
969
+ matchResult_4 = 15;
770
970
  }
771
971
  break;
772
972
  }
@@ -783,7 +983,7 @@ function valueMatchesTypeRef(typeDefs, tref, value) {
783
983
  }
784
984
  }
785
985
  else {
786
- matchResult_4 = 13;
986
+ matchResult_4 = 15;
787
987
  }
788
988
  break;
789
989
  }
@@ -792,29 +992,46 @@ function valueMatchesTypeRef(typeDefs, tref, value) {
792
992
  matchResult_4 = 10;
793
993
  }
794
994
  else {
795
- matchResult_4 = 13;
995
+ matchResult_4 = 15;
796
996
  }
797
997
  break;
798
998
  }
799
999
  case 8: {
800
- if (value_2.tag === 7) {
1000
+ const activePatternResult = $007CRecordFields$007C_$007C(value_2);
1001
+ if (activePatternResult != null) {
801
1002
  matchResult_4 = 11;
802
1003
  fields_3 = t_4.fields[0];
803
- values = value_2.fields[0];
1004
+ values = activePatternResult;
804
1005
  }
805
1006
  else {
1007
+ matchResult_4 = 15;
1008
+ }
1009
+ break;
1010
+ }
1011
+ case 17: {
1012
+ matchResult_4 = 12;
1013
+ break;
1014
+ }
1015
+ case 18: {
1016
+ const activePatternResult_1 = $007CRecordFields$007C_$007C(value_2);
1017
+ if (activePatternResult_1 != null) {
806
1018
  matchResult_4 = 13;
1019
+ fields_4 = t_4.fields[1];
1020
+ values_1 = activePatternResult_1;
1021
+ }
1022
+ else {
1023
+ matchResult_4 = 15;
807
1024
  }
808
1025
  break;
809
1026
  }
810
1027
  case 12: {
811
- matchResult_4 = 12;
812
- name_4 = t_4.fields[0];
1028
+ matchResult_4 = 14;
1029
+ name_5 = t_4.fields[0];
813
1030
  v_2 = value_2;
814
1031
  break;
815
1032
  }
816
1033
  default:
817
- matchResult_4 = 13;
1034
+ matchResult_4 = 15;
818
1035
  }
819
1036
  switch (matchResult_4) {
820
1037
  case 0:
@@ -857,8 +1074,12 @@ function valueMatchesTypeRef(typeDefs, tref, value) {
857
1074
  return valueHasType(matchValue_10, ft);
858
1075
  }
859
1076
  }, fields_3);
860
- case 12: {
861
- const matchValue_11 = FSharpMap__TryFind(typeDefs, name_4);
1077
+ case 12:
1078
+ return matches(typeDefs, t_4, value_2);
1079
+ case 13:
1080
+ return forAll((name_4, ft_1) => exists((fv_1) => valueHasType(fv_1, ft_1), toArray(FSharpMap__TryFind(values_1, name_4))), fields_4);
1081
+ case 14: {
1082
+ const matchValue_11 = FSharpMap__TryFind(typeDefs, name_5);
862
1083
  if (matchValue_11 == null) {
863
1084
  return false;
864
1085
  }
@@ -1158,10 +1379,11 @@ function patternMatch(typeDefs_mut, pat_mut, value_mut) {
1158
1379
  break;
1159
1380
  }
1160
1381
  case 6: {
1161
- if (value.tag === 7) {
1382
+ const activePatternResult_1 = $007CRecordFields$007C_$007C(value);
1383
+ if (activePatternResult_1 != null) {
1162
1384
  matchResult_1 = 6;
1163
1385
  fields = pat.fields[0];
1164
- values_2 = value.fields[0];
1386
+ values_2 = activePatternResult_1;
1165
1387
  }
1166
1388
  else {
1167
1389
  matchResult_1 = 12;
@@ -1436,7 +1658,7 @@ function applyFunctionValue(runtime, eval$, typeDefs, span, fnValue, argValue) {
1436
1658
  const ext = fnValue.fields[0];
1437
1659
  const args$0027 = cons(argValue, fnValue.fields[1]);
1438
1660
  if (length(args$0027) === ext.Arity) {
1439
- return ext.Impl(createExternContext(runtime, typeDefs, span), reverse(args$0027));
1661
+ return invoke(typeDefs, ext, createExternContext(runtime, typeDefs, span), reverse(args$0027));
1440
1662
  }
1441
1663
  else if (length(args$0027) < ext.Arity) {
1442
1664
  return new Value(/* VExternal */ 15, [ext, args$0027]);
@@ -1802,17 +2024,33 @@ function evalExpr(runtime_mut, typeDefs_mut, env_mut, expr_mut) {
1802
2024
  const matchValue_11 = FSharpMap__TryFind(env, concat(moduleName_1, ".", fieldName));
1803
2025
  if (matchValue_11 == null) {
1804
2026
  const matchValue_12 = evalExpr(runtime, typeDefs, env, target_2);
1805
- if (matchValue_12.tag === 7) {
1806
- const matchValue_13 = FSharpMap__TryFind(matchValue_12.fields[0], fieldName);
1807
- if (matchValue_13 == null) {
1808
- throw new EvalException(new EvalError$(toText(printf("Record field \'%s\' not found"))(fieldName), span_12));
2027
+ let matchResult_3, fields_4;
2028
+ switch (matchValue_12.tag) {
2029
+ case 7: {
2030
+ matchResult_3 = 0;
2031
+ fields_4 = matchValue_12.fields[0];
2032
+ break;
1809
2033
  }
1810
- else {
1811
- return matchValue_13;
2034
+ case 16: {
2035
+ matchResult_3 = 0;
2036
+ fields_4 = matchValue_12.fields[0].Fields;
2037
+ break;
1812
2038
  }
2039
+ default:
2040
+ matchResult_3 = 1;
1813
2041
  }
1814
- else {
1815
- throw new EvalException(new EvalError$("Field access requires a record value", span_12));
2042
+ switch (matchResult_3) {
2043
+ case 0: {
2044
+ const matchValue_13 = FSharpMap__TryFind(fields_4, fieldName);
2045
+ if (matchValue_13 == null) {
2046
+ throw new EvalException(new EvalError$(toText(printf("Record field \'%s\' not found"))(fieldName), span_12));
2047
+ }
2048
+ else {
2049
+ return matchValue_13;
2050
+ }
2051
+ }
2052
+ default:
2053
+ throw new EvalException(new EvalError$("Field access requires a record value", span_12));
1816
2054
  }
1817
2055
  }
1818
2056
  else {
@@ -1821,17 +2059,33 @@ function evalExpr(runtime_mut, typeDefs_mut, env_mut, expr_mut) {
1821
2059
  }
1822
2060
  default: {
1823
2061
  const matchValue_14 = evalExpr(runtime, typeDefs, env, target_2);
1824
- if (matchValue_14.tag === 7) {
1825
- const matchValue_15 = FSharpMap__TryFind(matchValue_14.fields[0], fieldName);
1826
- if (matchValue_15 == null) {
1827
- throw new EvalException(new EvalError$(toText(printf("Record field \'%s\' not found"))(fieldName), span_12));
2062
+ let matchResult_4, fields_5;
2063
+ switch (matchValue_14.tag) {
2064
+ case 7: {
2065
+ matchResult_4 = 0;
2066
+ fields_5 = matchValue_14.fields[0];
2067
+ break;
1828
2068
  }
1829
- else {
1830
- return matchValue_15;
2069
+ case 16: {
2070
+ matchResult_4 = 0;
2071
+ fields_5 = matchValue_14.fields[0].Fields;
2072
+ break;
1831
2073
  }
2074
+ default:
2075
+ matchResult_4 = 1;
1832
2076
  }
1833
- else {
1834
- throw new EvalException(new EvalError$("Field access requires a record value", span_12));
2077
+ switch (matchResult_4) {
2078
+ case 0: {
2079
+ const matchValue_15 = FSharpMap__TryFind(fields_5, fieldName);
2080
+ if (matchValue_15 == null) {
2081
+ throw new EvalException(new EvalError$(toText(printf("Record field \'%s\' not found"))(fieldName), span_12));
2082
+ }
2083
+ else {
2084
+ return matchValue_15;
2085
+ }
2086
+ }
2087
+ default:
2088
+ throw new EvalException(new EvalError$("Field access requires a record value", span_12));
1835
2089
  }
1836
2090
  }
1837
2091
  }
@@ -1840,55 +2094,55 @@ function evalExpr(runtime_mut, typeDefs_mut, env_mut, expr_mut) {
1840
2094
  const span_13 = expr.fields[2];
1841
2095
  const targetValue = evalExpr(runtime, typeDefs, env, expr.fields[0]);
1842
2096
  const keyValue_1 = evalExpr(runtime, typeDefs, env, expr.fields[1]);
1843
- let matchResult_3, index, values, mapValue;
2097
+ let matchResult_5, index, values, mapValue;
1844
2098
  switch (targetValue.tag) {
1845
2099
  case 5: {
1846
2100
  if (keyValue_1.tag === 1) {
1847
- matchResult_3 = 0;
2101
+ matchResult_5 = 0;
1848
2102
  index = keyValue_1.fields[0];
1849
2103
  values = targetValue.fields[0];
1850
2104
  }
1851
2105
  else {
1852
- matchResult_3 = 3;
2106
+ matchResult_5 = 3;
1853
2107
  }
1854
2108
  break;
1855
2109
  }
1856
2110
  case 8: {
1857
2111
  switch (keyValue_1.tag) {
1858
2112
  case 4: {
1859
- matchResult_3 = 1;
2113
+ matchResult_5 = 1;
1860
2114
  mapValue = targetValue.fields[0];
1861
2115
  break;
1862
2116
  }
1863
2117
  case 1: {
1864
- matchResult_3 = 1;
2118
+ matchResult_5 = 1;
1865
2119
  mapValue = targetValue.fields[0];
1866
2120
  break;
1867
2121
  }
1868
2122
  case 3: {
1869
- matchResult_3 = 1;
2123
+ matchResult_5 = 1;
1870
2124
  mapValue = targetValue.fields[0];
1871
2125
  break;
1872
2126
  }
1873
2127
  case 10: {
1874
2128
  if (keyValue_1.fields[2] == null) {
1875
- matchResult_3 = 1;
2129
+ matchResult_5 = 1;
1876
2130
  mapValue = targetValue.fields[0];
1877
2131
  }
1878
2132
  else {
1879
- matchResult_3 = 2;
2133
+ matchResult_5 = 2;
1880
2134
  }
1881
2135
  break;
1882
2136
  }
1883
2137
  default:
1884
- matchResult_3 = 2;
2138
+ matchResult_5 = 2;
1885
2139
  }
1886
2140
  break;
1887
2141
  }
1888
2142
  default:
1889
- matchResult_3 = 4;
2143
+ matchResult_5 = 4;
1890
2144
  }
1891
- switch (matchResult_3) {
2145
+ switch (matchResult_5) {
1892
2146
  case 0: {
1893
2147
  const loop = (remaining_mut, current_1_mut) => {
1894
2148
  loop:
@@ -1940,21 +2194,21 @@ function evalExpr(runtime_mut, typeDefs_mut, env_mut, expr_mut) {
1940
2194
  case 24: {
1941
2195
  const av = evalExpr(runtime, typeDefs, env, expr.fields[0]);
1942
2196
  const bv = evalExpr(runtime, typeDefs, env, expr.fields[1]);
1943
- let matchResult_4, xs_1, ys;
2197
+ let matchResult_6, xs_1, ys;
1944
2198
  if (av.tag === 5) {
1945
2199
  if (bv.tag === 5) {
1946
- matchResult_4 = 0;
2200
+ matchResult_6 = 0;
1947
2201
  xs_1 = av.fields[0];
1948
2202
  ys = bv.fields[0];
1949
2203
  }
1950
2204
  else {
1951
- matchResult_4 = 1;
2205
+ matchResult_6 = 1;
1952
2206
  }
1953
2207
  }
1954
2208
  else {
1955
- matchResult_4 = 1;
2209
+ matchResult_6 = 1;
1956
2210
  }
1957
- switch (matchResult_4) {
2211
+ switch (matchResult_6) {
1958
2212
  case 0:
1959
2213
  return new Value(/* VList */ 5, [append(xs_1, ys)]);
1960
2214
  default:
@@ -1967,34 +2221,34 @@ function evalExpr(runtime_mut, typeDefs_mut, env_mut, expr_mut) {
1967
2221
  const av_1 = evalExpr(runtime, typeDefs, env, expr.fields[1]);
1968
2222
  const bv_1 = evalExpr(runtime, typeDefs, env, expr.fields[2]);
1969
2223
  const arith = (fInt, fFloat) => {
1970
- let matchResult_5, x_3, y_3, x_4, y_4;
2224
+ let matchResult_7, x_3, y_3, x_4, y_4;
1971
2225
  switch (av_1.tag) {
1972
2226
  case 1: {
1973
2227
  if (bv_1.tag === 1) {
1974
- matchResult_5 = 0;
2228
+ matchResult_7 = 0;
1975
2229
  x_3 = av_1.fields[0];
1976
2230
  y_3 = bv_1.fields[0];
1977
2231
  }
1978
2232
  else {
1979
- matchResult_5 = 2;
2233
+ matchResult_7 = 2;
1980
2234
  }
1981
2235
  break;
1982
2236
  }
1983
2237
  case 2: {
1984
2238
  if (bv_1.tag === 2) {
1985
- matchResult_5 = 1;
2239
+ matchResult_7 = 1;
1986
2240
  x_4 = av_1.fields[0];
1987
2241
  y_4 = bv_1.fields[0];
1988
2242
  }
1989
2243
  else {
1990
- matchResult_5 = 2;
2244
+ matchResult_7 = 2;
1991
2245
  }
1992
2246
  break;
1993
2247
  }
1994
2248
  default:
1995
- matchResult_5 = 2;
2249
+ matchResult_7 = 2;
1996
2250
  }
1997
- switch (matchResult_5) {
2251
+ switch (matchResult_7) {
1998
2252
  case 0:
1999
2253
  return new Value(/* VInt */ 1, [fInt(x_3)(y_3)]);
2000
2254
  case 1:
@@ -2013,34 +2267,34 @@ function evalExpr(runtime_mut, typeDefs_mut, env_mut, expr_mut) {
2013
2267
  case "*":
2014
2268
  return arith((x_9) => ((y_9) => toInt64_unchecked(op_Multiply(x_9, y_9))), (x_10) => ((y_10) => (x_10 * y_10)));
2015
2269
  case "/": {
2016
- let matchResult_6, x_11, y_11, x_12, y_12;
2270
+ let matchResult_8, x_11, y_11, x_12, y_12;
2017
2271
  switch (av_1.tag) {
2018
2272
  case 1: {
2019
2273
  if (bv_1.tag === 1) {
2020
- matchResult_6 = 0;
2274
+ matchResult_8 = 0;
2021
2275
  x_11 = av_1.fields[0];
2022
2276
  y_11 = bv_1.fields[0];
2023
2277
  }
2024
2278
  else {
2025
- matchResult_6 = 2;
2279
+ matchResult_8 = 2;
2026
2280
  }
2027
2281
  break;
2028
2282
  }
2029
2283
  case 2: {
2030
2284
  if (bv_1.tag === 2) {
2031
- matchResult_6 = 1;
2285
+ matchResult_8 = 1;
2032
2286
  x_12 = av_1.fields[0];
2033
2287
  y_12 = bv_1.fields[0];
2034
2288
  }
2035
2289
  else {
2036
- matchResult_6 = 2;
2290
+ matchResult_8 = 2;
2037
2291
  }
2038
2292
  break;
2039
2293
  }
2040
2294
  default:
2041
- matchResult_6 = 2;
2295
+ matchResult_8 = 2;
2042
2296
  }
2043
- switch (matchResult_6) {
2297
+ switch (matchResult_8) {
2044
2298
  case 0:
2045
2299
  return new Value(/* VInt */ 1, [toInt64_unchecked(op_Division(x_11, y_11))]);
2046
2300
  case 1:
@@ -2050,21 +2304,21 @@ function evalExpr(runtime_mut, typeDefs_mut, env_mut, expr_mut) {
2050
2304
  }
2051
2305
  }
2052
2306
  case "%": {
2053
- let matchResult_7, x_13, y_13;
2307
+ let matchResult_9, x_13, y_13;
2054
2308
  if (av_1.tag === 1) {
2055
2309
  if (bv_1.tag === 1) {
2056
- matchResult_7 = 0;
2310
+ matchResult_9 = 0;
2057
2311
  x_13 = av_1.fields[0];
2058
2312
  y_13 = bv_1.fields[0];
2059
2313
  }
2060
2314
  else {
2061
- matchResult_7 = 1;
2315
+ matchResult_9 = 1;
2062
2316
  }
2063
2317
  }
2064
2318
  else {
2065
- matchResult_7 = 1;
2319
+ matchResult_9 = 1;
2066
2320
  }
2067
- switch (matchResult_7) {
2321
+ switch (matchResult_9) {
2068
2322
  case 0:
2069
2323
  return new Value(/* VInt */ 1, [toInt64_unchecked(op_Modulus(x_13, y_13))]);
2070
2324
  default:
@@ -2077,34 +2331,34 @@ function evalExpr(runtime_mut, typeDefs_mut, env_mut, expr_mut) {
2077
2331
  case ">":
2078
2332
  case "<=":
2079
2333
  case ">=": {
2080
- let matchResult_8, x_14, y_14, x_15, y_15;
2334
+ let matchResult_10, x_14, y_14, x_15, y_15;
2081
2335
  switch (av_1.tag) {
2082
2336
  case 1: {
2083
2337
  if (bv_1.tag === 1) {
2084
- matchResult_8 = 0;
2338
+ matchResult_10 = 0;
2085
2339
  x_14 = av_1.fields[0];
2086
2340
  y_14 = bv_1.fields[0];
2087
2341
  }
2088
2342
  else {
2089
- matchResult_8 = 2;
2343
+ matchResult_10 = 2;
2090
2344
  }
2091
2345
  break;
2092
2346
  }
2093
2347
  case 2: {
2094
2348
  if (bv_1.tag === 2) {
2095
- matchResult_8 = 1;
2349
+ matchResult_10 = 1;
2096
2350
  x_15 = av_1.fields[0];
2097
2351
  y_15 = bv_1.fields[0];
2098
2352
  }
2099
2353
  else {
2100
- matchResult_8 = 2;
2354
+ matchResult_10 = 2;
2101
2355
  }
2102
2356
  break;
2103
2357
  }
2104
2358
  default:
2105
- matchResult_8 = 2;
2359
+ matchResult_10 = 2;
2106
2360
  }
2107
- switch (matchResult_8) {
2361
+ switch (matchResult_10) {
2108
2362
  case 0:
2109
2363
  return new Value(/* VBool */ 3, [(op === "<") ? (compare_1(x_14, y_14) < 0) : ((op === ">") ? (compare_1(x_14, y_14) > 0) : ((op === "<=") ? (compare_1(x_14, y_14) <= 0) : ((op === ">=") && (compare_1(x_14, y_14) >= 0))))]);
2110
2364
  case 1:
@@ -2115,21 +2369,21 @@ function evalExpr(runtime_mut, typeDefs_mut, env_mut, expr_mut) {
2115
2369
  }
2116
2370
  case "&&":
2117
2371
  case "||": {
2118
- let matchResult_9, x_16, y_16;
2372
+ let matchResult_11, x_16, y_16;
2119
2373
  if (av_1.tag === 3) {
2120
2374
  if (bv_1.tag === 3) {
2121
- matchResult_9 = 0;
2375
+ matchResult_11 = 0;
2122
2376
  x_16 = av_1.fields[0];
2123
2377
  y_16 = bv_1.fields[0];
2124
2378
  }
2125
2379
  else {
2126
- matchResult_9 = 1;
2380
+ matchResult_11 = 1;
2127
2381
  }
2128
2382
  }
2129
2383
  else {
2130
- matchResult_9 = 1;
2384
+ matchResult_11 = 1;
2131
2385
  }
2132
- switch (matchResult_9) {
2386
+ switch (matchResult_11) {
2133
2387
  case 0:
2134
2388
  return new Value(/* VBool */ 3, [(op === "&&") ? (x_16 && y_16) : (x_16 ? true : y_16)]);
2135
2389
  default:
@@ -2144,21 +2398,21 @@ function evalExpr(runtime_mut, typeDefs_mut, env_mut, expr_mut) {
2144
2398
  throw new EvalException(new EvalError$("Right side of \'::\' must be list", span_16));
2145
2399
  }
2146
2400
  case "@": {
2147
- let matchResult_10, xs_3, ys_1;
2401
+ let matchResult_12, xs_3, ys_1;
2148
2402
  if (av_1.tag === 5) {
2149
2403
  if (bv_1.tag === 5) {
2150
- matchResult_10 = 0;
2404
+ matchResult_12 = 0;
2151
2405
  xs_3 = av_1.fields[0];
2152
2406
  ys_1 = bv_1.fields[0];
2153
2407
  }
2154
2408
  else {
2155
- matchResult_10 = 1;
2409
+ matchResult_12 = 1;
2156
2410
  }
2157
2411
  }
2158
2412
  else {
2159
- matchResult_10 = 1;
2413
+ matchResult_12 = 1;
2160
2414
  }
2161
- switch (matchResult_10) {
2415
+ switch (matchResult_12) {
2162
2416
  case 0:
2163
2417
  return new Value(/* VList */ 5, [append(xs_3, ys_1)]);
2164
2418
  default:
@@ -2230,7 +2484,7 @@ export function invokeValue(typeDefs, fnValue, args) {
2230
2484
  const ext = currentValue.fields[0];
2231
2485
  const allArgs = append(reverse(currentValue.fields[1]), remainingArgs);
2232
2486
  if (length(allArgs) === ext.Arity) {
2233
- return ext.Impl(createExternContext(runtime, typeDefs, unknownSpan), allArgs);
2487
+ return invoke(typeDefs, ext, createExternContext(runtime, typeDefs, unknownSpan), allArgs);
2234
2488
  }
2235
2489
  else if (length(allArgs) < ext.Arity) {
2236
2490
  return new Value(/* VExternal */ 15, [ext, reverse(allArgs)]);
@@ -2436,7 +2690,8 @@ export function evalProgramFromState(state, program) {
2436
2690
  return evaluateStatements(new RuntimeState({}, [], undefined), state.TypeDefs, state.Env, program);
2437
2691
  }
2438
2692
 
2439
- export function evalProgramWithExternsState(externs, program) {
2693
+ export function evalProgramWithRegistrationState(registration, program) {
2694
+ const externs = registration.Functions;
2440
2695
  const runtime = new RuntimeState({}, [], undefined);
2441
2696
  const option_1 = tryFind_1((ext) => contains(ext.Name, builtinReservedNames), externs);
2442
2697
  if (option_1 != null) {
@@ -2533,7 +2788,7 @@ export function evalProgramWithExternsState(externs, program) {
2533
2788
  }
2534
2789
  }
2535
2790
  };
2536
- const typeDefs = map_1((name_2, def_2) => {
2791
+ const typeDefs_1 = fold((acc, name_3, t_2) => add(name_3, t_2, acc), map_1((name_2, def_2) => {
2537
2792
  if (!isEmpty(def_2.Cases)) {
2538
2793
  return new Type(/* TUnion */ 13, [name_2, ofList(map((tupledArg_4) => {
2539
2794
  let mapping_8, option_5;
@@ -2547,7 +2802,7 @@ export function evalProgramWithExternsState(externs, program) {
2547
2802
  Compare: (x_6, y_7) => (comparePrimitives(x_6, y_7) | 0),
2548
2803
  })]);
2549
2804
  }
2550
- }, decls);
2805
+ }, decls), typeDefinitions(registration, toList_1(keys(decls))));
2551
2806
  const constructorValues = collect((tupledArg_6) => {
2552
2807
  const typeName = tupledArg_6[0];
2553
2808
  return collect((tupledArg_7) => {
@@ -2556,28 +2811,36 @@ export function evalProgramWithExternsState(externs, program) {
2556
2811
  return ofArray([[caseName_2, value], [concat(typeName, ".", caseName_2), value]]);
2557
2812
  }, tupledArg_6[1].Cases);
2558
2813
  }, toList(decls));
2559
- const externContext = createExternContext(runtime, typeDefs, unknownSpan);
2814
+ const externContext = createExternContext(runtime, typeDefs_1, unknownSpan);
2560
2815
  let env;
2561
2816
  const list_13 = append(builtinExterns, externs);
2562
- env = fold_1((acc, ext_2) => {
2817
+ env = fold_1((acc_1, ext_2) => {
2563
2818
  if (ext_2.Arity === 0) {
2564
- return FSharpMap__Add(acc, ext_2.Name, ext_2.Impl(externContext, empty()));
2819
+ return FSharpMap__Add(acc_1, ext_2.Name, invoke(typeDefs_1, ext_2, externContext, empty()));
2565
2820
  }
2566
2821
  else {
2567
- return FSharpMap__Add(acc, ext_2.Name, new Value(/* VExternal */ 15, [ext_2, empty()]));
2822
+ return FSharpMap__Add(acc_1, ext_2.Name, new Value(/* VExternal */ 15, [ext_2, empty()]));
2568
2823
  }
2569
2824
  }, empty_1({
2570
2825
  Compare: (x_7, y_8) => (comparePrimitives(x_7, y_8) | 0),
2571
2826
  }), list_13);
2572
- env = fold_1((acc_1, tupledArg_8) => FSharpMap__Add(acc_1, tupledArg_8[0], tupledArg_8[1]), env, constructorValues);
2573
- return evaluateStatements(runtime, typeDefs, env, program);
2827
+ env = fold_1((acc_2, tupledArg_8) => FSharpMap__Add(acc_2, tupledArg_8[0], tupledArg_8[1]), env, constructorValues);
2828
+ return evaluateStatements(runtime, typeDefs_1, env, program);
2574
2829
  }
2575
2830
 
2576
2831
  export function evalProgramWithExterns(externs, program) {
2577
- return evalProgramWithExternsState(externs, program).LastValue;
2832
+ return evalProgramWithRegistrationState(ofExterns(externs), program).LastValue;
2578
2833
  }
2579
2834
 
2580
2835
  export function evalProgram(program) {
2581
2836
  return evalProgramWithExterns(empty(), program);
2582
2837
  }
2583
2838
 
2839
+ export function evalProgramWithExternsState(externs, program) {
2840
+ return evalProgramWithRegistrationState(ofExterns(externs), program);
2841
+ }
2842
+
2843
+ export function evalProgramWithRegistration(registration, program) {
2844
+ return evalProgramWithRegistrationState(registration, program).LastValue;
2845
+ }
2846
+