@mojir/dvala 0.0.30 → 0.0.31
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/dist/cli/cli.js +167 -127
- package/package.json +1 -1
package/dist/cli/cli.js
CHANGED
|
@@ -119,7 +119,8 @@ const NodeTypes = {
|
|
|
119
119
|
ReservedSymbol: 8,
|
|
120
120
|
Binding: 9,
|
|
121
121
|
Spread: 10,
|
|
122
|
-
TemplateString: 11
|
|
122
|
+
TemplateString: 11,
|
|
123
|
+
EffectName: 12
|
|
123
124
|
};
|
|
124
125
|
const NodeTypesSet = new Set(Object.values(NodeTypes));
|
|
125
126
|
function getNodeTypeName(type) {
|
|
@@ -478,7 +479,7 @@ function findAllOccurrences(input, pattern) {
|
|
|
478
479
|
}
|
|
479
480
|
//#endregion
|
|
480
481
|
//#region package.json
|
|
481
|
-
var version = "0.0.
|
|
482
|
+
var version = "0.0.31";
|
|
482
483
|
//#endregion
|
|
483
484
|
//#region src/typeGuards/string.ts
|
|
484
485
|
function isString(value, options = {}) {
|
|
@@ -527,7 +528,7 @@ const assertionNormalExpression = { assert: {
|
|
|
527
528
|
message: { type: "string" }
|
|
528
529
|
},
|
|
529
530
|
variants: [{ argumentNames: ["value"] }, { argumentNames: ["value", "message"] }],
|
|
530
|
-
examples: ["do assert(0, \"Expected a positive value\") with case
|
|
531
|
+
examples: ["do assert(0, \"Expected a positive value\") with case @dvala.error then ([msg]) -> msg end"],
|
|
531
532
|
seeAlso: ["assertion.assert-truthy", "assertion.assert-true"],
|
|
532
533
|
hideOperatorForm: true
|
|
533
534
|
}
|
|
@@ -3580,7 +3581,7 @@ const miscNormalExpression = {
|
|
|
3580
3581
|
variants: [{ argumentNames: ["e"] }],
|
|
3581
3582
|
description: "Returns the name of an effect reference as a string.",
|
|
3582
3583
|
seeAlso: ["effect-matcher", "effect?"],
|
|
3583
|
-
examples: ["effect-name(
|
|
3584
|
+
examples: ["effect-name(@dvala.error)", "effect-name(@llm.complete)"]
|
|
3584
3585
|
}
|
|
3585
3586
|
},
|
|
3586
3587
|
"effect-matcher": {
|
|
@@ -3617,9 +3618,9 @@ const miscNormalExpression = {
|
|
|
3617
3618
|
description: "Returns a predicate function that matches effects by name. If $pattern is a string, uses wildcard matching: no wildcard means exact match, `.*` suffix matches the prefix and all descendants (dot boundary enforced), and `*` alone matches everything. If $pattern is a regexp, tests the effect name against the regexp.",
|
|
3618
3619
|
seeAlso: ["effect-name", "effect?"],
|
|
3619
3620
|
examples: [
|
|
3620
|
-
"let pred = effect-matcher(\"dvala.*\"); pred(
|
|
3621
|
-
"let pred = effect-matcher(\"dvala.*\"); pred(
|
|
3622
|
-
"let pred = effect-matcher(\"*\"); pred(
|
|
3621
|
+
"let pred = effect-matcher(\"dvala.*\"); pred(@dvala.error)",
|
|
3622
|
+
"let pred = effect-matcher(\"dvala.*\"); pred(@custom.foo)",
|
|
3623
|
+
"let pred = effect-matcher(\"*\"); pred(@anything)"
|
|
3623
3624
|
]
|
|
3624
3625
|
}
|
|
3625
3626
|
},
|
|
@@ -3665,7 +3666,7 @@ const miscNormalExpression = {
|
|
|
3665
3666
|
"type-of({ a: 1 })",
|
|
3666
3667
|
"type-of((x) -> x + 1)",
|
|
3667
3668
|
"type-of(regexp(\"^start\"))",
|
|
3668
|
-
"type-of(
|
|
3669
|
+
"type-of(@dvala.io.println)"
|
|
3669
3670
|
]
|
|
3670
3671
|
}
|
|
3671
3672
|
}
|
|
@@ -4410,7 +4411,7 @@ const predicatesNormalExpression = {
|
|
|
4410
4411
|
"type-of"
|
|
4411
4412
|
],
|
|
4412
4413
|
examples: [
|
|
4413
|
-
"effect?(
|
|
4414
|
+
"effect?(@dvala.io.println)",
|
|
4414
4415
|
"effect?(42)",
|
|
4415
4416
|
"effect?(\"hello\")",
|
|
4416
4417
|
"effect?(null)",
|
|
@@ -5241,7 +5242,7 @@ function signature(reference) {
|
|
|
5241
5242
|
const { title, variants, args, returns } = reference;
|
|
5242
5243
|
const isOperator = !isEffectRef(reference) && reference._isOperator;
|
|
5243
5244
|
const functionForms = variants.map((variant) => {
|
|
5244
|
-
if (isEffectRef(reference)) return ` perform(
|
|
5245
|
+
if (isEffectRef(reference)) return ` perform(@${title}${variant.argumentNames.length > 0 ? `, ${variant.argumentNames.map((argName) => {
|
|
5245
5246
|
let result = "";
|
|
5246
5247
|
if (args[argName].rest) result += "...";
|
|
5247
5248
|
result += argName;
|
|
@@ -5299,7 +5300,7 @@ function getMetaNormalExpression(normalExpressionReference, effectReference) {
|
|
|
5299
5300
|
seeAlso: ["arity", "with-doc"],
|
|
5300
5301
|
examples: [
|
|
5301
5302
|
"doc(+)",
|
|
5302
|
-
"doc(
|
|
5303
|
+
"doc(@dvala.io.println)",
|
|
5303
5304
|
"let add = (x, y) -> x + y with-doc \"Adds two numbers.\";\ndoc(add)"
|
|
5304
5305
|
]
|
|
5305
5306
|
}
|
|
@@ -5354,7 +5355,7 @@ function getMetaNormalExpression(normalExpressionReference, effectReference) {
|
|
|
5354
5355
|
examples: [
|
|
5355
5356
|
"arity(+)",
|
|
5356
5357
|
"arity(defined?)",
|
|
5357
|
-
"arity(
|
|
5358
|
+
"arity(@dvala.random.int)",
|
|
5358
5359
|
`
|
|
5359
5360
|
let add = (x, y = 0) -> do
|
|
5360
5361
|
x + y;
|
|
@@ -5764,7 +5765,7 @@ const doSpecialExpression = {
|
|
|
5764
5765
|
arity: {},
|
|
5765
5766
|
docs: {
|
|
5766
5767
|
category: "special-expression",
|
|
5767
|
-
customVariants: ["do body end", "do body with case
|
|
5768
|
+
customVariants: ["do body end", "do body with case @name then handler end"],
|
|
5768
5769
|
details: [
|
|
5769
5770
|
[
|
|
5770
5771
|
"body",
|
|
@@ -5772,7 +5773,7 @@ const doSpecialExpression = {
|
|
|
5772
5773
|
"The expressions to evaluate."
|
|
5773
5774
|
],
|
|
5774
5775
|
[
|
|
5775
|
-
"
|
|
5776
|
+
"@name",
|
|
5776
5777
|
"expression",
|
|
5777
5778
|
"An expression evaluating to an effect value."
|
|
5778
5779
|
],
|
|
@@ -5790,9 +5791,9 @@ do
|
|
|
5790
5791
|
b(a)
|
|
5791
5792
|
end`, `
|
|
5792
5793
|
do
|
|
5793
|
-
perform(
|
|
5794
|
+
perform(@dvala.io.println, "hello")
|
|
5794
5795
|
with
|
|
5795
|
-
case
|
|
5796
|
+
case @dvala.io.println then ([msg]) -> null
|
|
5796
5797
|
end`]
|
|
5797
5798
|
},
|
|
5798
5799
|
getUndefinedSymbols: (node, contextStack, { getUndefinedSymbols, builtin }) => {
|
|
@@ -6109,7 +6110,7 @@ const doseqSpecialExpression = {
|
|
|
6109
6110
|
returns: { type: "null" },
|
|
6110
6111
|
description: "Iterates over `bindings`, evaluates `body` for each `binding` and returns `null`. This is useful for side effects.",
|
|
6111
6112
|
examples: [`
|
|
6112
|
-
doseq (i in [1, 2, 3]) -> perform(
|
|
6113
|
+
doseq (i in [1, 2, 3]) -> perform(@dvala.io.println, i * 2)
|
|
6113
6114
|
`]
|
|
6114
6115
|
},
|
|
6115
6116
|
getUndefinedSymbols: (node, contextStack, { getUndefinedSymbols, builtin }) => analyze(node, contextStack, getUndefinedSymbols, builtin)
|
|
@@ -6280,14 +6281,14 @@ const effectSpecialExpression = {
|
|
|
6280
6281
|
arity: {},
|
|
6281
6282
|
docs: {
|
|
6282
6283
|
category: "special-expression",
|
|
6283
|
-
customVariants: ["
|
|
6284
|
+
customVariants: ["@name"],
|
|
6284
6285
|
details: [[
|
|
6285
6286
|
"name",
|
|
6286
6287
|
"dotted identifier",
|
|
6287
6288
|
"The effect name, e.g. `llm.complete` or `dvala.io.println`."
|
|
6288
6289
|
]],
|
|
6289
6290
|
description: "Returns the unique effect reference for the given name. Calling `effect` with the same name always returns the same reference. Effect references are first-class values that can be stored, passed, and compared with `==`.",
|
|
6290
|
-
examples: ["
|
|
6291
|
+
examples: ["@dvala.io.println", "==(@llm.complete, @llm.complete)"],
|
|
6291
6292
|
seeAlso: ["effect?"]
|
|
6292
6293
|
},
|
|
6293
6294
|
getUndefinedSymbols: () => /* @__PURE__ */ new Set()
|
|
@@ -6379,7 +6380,7 @@ const performSpecialExpression = {
|
|
|
6379
6380
|
details: [[
|
|
6380
6381
|
"eff",
|
|
6381
6382
|
"expression",
|
|
6382
|
-
"An expression evaluating to an effect value (from
|
|
6383
|
+
"An expression evaluating to an effect value (from `@name`)."
|
|
6383
6384
|
], [
|
|
6384
6385
|
"arg1, arg2, ...",
|
|
6385
6386
|
"expressions",
|
|
@@ -6388,9 +6389,9 @@ const performSpecialExpression = {
|
|
|
6388
6389
|
description: "Invokes an effect. The nearest enclosing `do/with` handler matching the effect intercepts the call. The handler receives the arguments as an array and its return value becomes the result of `perform`. If no local handler matches, the effect is dispatched to the host.",
|
|
6389
6390
|
examples: [`
|
|
6390
6391
|
do
|
|
6391
|
-
perform(
|
|
6392
|
+
perform(@dvala.io.println, "hello")
|
|
6392
6393
|
with
|
|
6393
|
-
case
|
|
6394
|
+
case @dvala.io.println then ([msg]) -> msg
|
|
6394
6395
|
end
|
|
6395
6396
|
`],
|
|
6396
6397
|
seeAlso: ["effect?"]
|
|
@@ -6481,7 +6482,7 @@ function isFunctionDocs(docs) {
|
|
|
6481
6482
|
}
|
|
6482
6483
|
//#endregion
|
|
6483
6484
|
//#region src/builtin/modules/assertion/assertion.dvala
|
|
6484
|
-
var assertion_default = "{\n assert-fails: (fn, ...args) -> do\n let message = first(args);\n assert(function?(fn), \"First argument must be a function\");\n if not(null?(message)) then assert(string?(message), \"Second argument must be a string\") end;\n let failed-sentinel =
|
|
6485
|
+
var assertion_default = "{\n assert-fails: (fn, ...args) -> do\n let message = first(args);\n assert(function?(fn), \"First argument must be a function\");\n if not(null?(message)) then assert(string?(message), \"Second argument must be a string\") end;\n let failed-sentinel = @dvala.assertion.failed;\n let result = do fn() with case @dvala.error then ([msg]) -> failed-sentinel end;\n if effect?(result) && result == failed-sentinel then\n null\n else\n assert(false, message ?? \"Expected function to fail\")\n end\n end,\n\n assert-fails-with: (fn, expected-error, ...args) -> do\n let message = first(args);\n assert(function?(fn), \"First argument must be a function\");\n assert(string?(expected-error), \"Second argument must be a string\");\n if not(null?(message)) then assert(string?(message), \"Third argument must be a string\") end;\n let failed-sentinel = @dvala.assertion.failed;\n let result = do fn() with case @dvala.error then ([msg]) -> [failed-sentinel, msg] end;\n if array?(result) && first(result) == failed-sentinel then do\n let actual-error = second(result);\n if actual-error == expected-error then\n null\n else\n assert(false, message ?? (\"Expected function to fail with \\\"\" ++ expected-error ++ \"\\\" but got \\\"\" ++ actual-error ++ \"\\\"\"))\n end\n end\n else\n assert(false, message ?? (\"Expected function to fail with \\\"\" ++ expected-error ++ \"\\\"\"))\n end\n end,\n\n assert-succeeds: (fn, ...args) -> do\n let message = first(args);\n assert(function?(fn), \"First argument must be a function\");\n if not(null?(message)) then assert(string?(message), \"Second argument must be a string\") end;\n let failed-sentinel = @dvala.assertion.failed;\n let result = do fn() with case @dvala.error then ([msg]) -> failed-sentinel end;\n if effect?(result) && result == failed-sentinel then\n assert(false, message ?? \"Expected function to succeed\")\n else\n null\n end\n end\n}\n";
|
|
6485
6486
|
//#endregion
|
|
6486
6487
|
//#region src/builtin/modules/assertion/docs.ts
|
|
6487
6488
|
const moduleDocs$5 = {
|
|
@@ -6500,10 +6501,10 @@ const moduleDocs$5 = {
|
|
|
6500
6501
|
"message"
|
|
6501
6502
|
] }],
|
|
6502
6503
|
examples: [
|
|
6503
|
-
"let { assert!= } = import(assertion);\ndo assert!=(0, 0, \"Expected different values\") with case
|
|
6504
|
-
"let { assert!= } = import(assertion);\ndo assert!=(0, 0) with case
|
|
6505
|
-
"let { assert!= } = import(assertion);\ndo 0 assert!= 0 with case
|
|
6506
|
-
"let { assert!= } = import(assertion);\ndo assert!=(0, 1) with case
|
|
6504
|
+
"let { assert!= } = import(assertion);\ndo assert!=(0, 0, \"Expected different values\") with case @dvala.error then ([msg]) -> msg end",
|
|
6505
|
+
"let { assert!= } = import(assertion);\ndo assert!=(0, 0) with case @dvala.error then ([msg]) -> msg end",
|
|
6506
|
+
"let { assert!= } = import(assertion);\ndo 0 assert!= 0 with case @dvala.error then ([msg]) -> msg end",
|
|
6507
|
+
"let { assert!= } = import(assertion);\ndo assert!=(0, 1) with case @dvala.error then ([msg]) -> msg end"
|
|
6507
6508
|
],
|
|
6508
6509
|
seeAlso: ["assertion.assert="],
|
|
6509
6510
|
hideOperatorForm: true
|
|
@@ -6523,9 +6524,9 @@ const moduleDocs$5 = {
|
|
|
6523
6524
|
"message"
|
|
6524
6525
|
] }],
|
|
6525
6526
|
examples: [
|
|
6526
|
-
"let { assert= } = import(assertion);\ndo assert=({ \"a\": 1 }, { \"a\": 2 }, \"Expected equal values\") with case
|
|
6527
|
-
"let { assert= } = import(assertion);\ndo assert=({ \"a\": 1 }, { \"a\": 2 }) with case
|
|
6528
|
-
"let { assert= } = import(assertion);\ndo assert=({ \"a\": 1 }, { \"a\": 1 }) with case
|
|
6527
|
+
"let { assert= } = import(assertion);\ndo assert=({ \"a\": 1 }, { \"a\": 2 }, \"Expected equal values\") with case @dvala.error then ([msg]) -> msg end",
|
|
6528
|
+
"let { assert= } = import(assertion);\ndo assert=({ \"a\": 1 }, { \"a\": 2 }) with case @dvala.error then ([msg]) -> msg end",
|
|
6529
|
+
"let { assert= } = import(assertion);\ndo assert=({ \"a\": 1 }, { \"a\": 1 }) with case @dvala.error then ([msg]) -> msg end"
|
|
6529
6530
|
],
|
|
6530
6531
|
seeAlso: ["assertion.assert!="],
|
|
6531
6532
|
hideOperatorForm: true
|
|
@@ -6545,9 +6546,9 @@ const moduleDocs$5 = {
|
|
|
6545
6546
|
"message"
|
|
6546
6547
|
] }],
|
|
6547
6548
|
examples: [
|
|
6548
|
-
"let { assert-gt } = import(assertion);\ndo assert-gt(0, 1, \"Expected greater value\") with case
|
|
6549
|
-
"let { assert-gt } = import(assertion);\ndo assert-gt(0, 0) with case
|
|
6550
|
-
"let { assert-gt } = import(assertion);\ndo assert-gt(1, 0) with case
|
|
6549
|
+
"let { assert-gt } = import(assertion);\ndo assert-gt(0, 1, \"Expected greater value\") with case @dvala.error then ([msg]) -> msg end",
|
|
6550
|
+
"let { assert-gt } = import(assertion);\ndo assert-gt(0, 0) with case @dvala.error then ([msg]) -> msg end",
|
|
6551
|
+
"let { assert-gt } = import(assertion);\ndo assert-gt(1, 0) with case @dvala.error then ([msg]) -> msg end"
|
|
6551
6552
|
],
|
|
6552
6553
|
seeAlso: [
|
|
6553
6554
|
"assertion.assert-lt",
|
|
@@ -6571,9 +6572,9 @@ const moduleDocs$5 = {
|
|
|
6571
6572
|
"message"
|
|
6572
6573
|
] }],
|
|
6573
6574
|
examples: [
|
|
6574
|
-
"let { assert-lt } = import(assertion);\ndo assert-lt(1, 0, \"Expected smaller value value\") with case
|
|
6575
|
-
"let { assert-lt } = import(assertion);\ndo assert-lt(1, 1) with case
|
|
6576
|
-
"let { assert-lt } = import(assertion);\ndo assert-lt(0, 1) with case
|
|
6575
|
+
"let { assert-lt } = import(assertion);\ndo assert-lt(1, 0, \"Expected smaller value value\") with case @dvala.error then ([msg]) -> msg end",
|
|
6576
|
+
"let { assert-lt } = import(assertion);\ndo assert-lt(1, 1) with case @dvala.error then ([msg]) -> msg end",
|
|
6577
|
+
"let { assert-lt } = import(assertion);\ndo assert-lt(0, 1) with case @dvala.error then ([msg]) -> msg end"
|
|
6577
6578
|
],
|
|
6578
6579
|
seeAlso: [
|
|
6579
6580
|
"assertion.assert-gt",
|
|
@@ -6597,9 +6598,9 @@ const moduleDocs$5 = {
|
|
|
6597
6598
|
"message"
|
|
6598
6599
|
] }],
|
|
6599
6600
|
examples: [
|
|
6600
|
-
"let { assert-gte } = import(assertion);\ndo assert-gte(0, 1, \"Expected greater value\") with case
|
|
6601
|
-
"let { assert-gte } = import(assertion);\ndo assert-gte(0, 1) with case
|
|
6602
|
-
"let { assert-gte } = import(assertion);\ndo assert-gte(1, 1) with case
|
|
6601
|
+
"let { assert-gte } = import(assertion);\ndo assert-gte(0, 1, \"Expected greater value\") with case @dvala.error then ([msg]) -> msg end",
|
|
6602
|
+
"let { assert-gte } = import(assertion);\ndo assert-gte(0, 1) with case @dvala.error then ([msg]) -> msg end",
|
|
6603
|
+
"let { assert-gte } = import(assertion);\ndo assert-gte(1, 1) with case @dvala.error then ([msg]) -> msg end"
|
|
6603
6604
|
],
|
|
6604
6605
|
seeAlso: [
|
|
6605
6606
|
"assertion.assert-lte",
|
|
@@ -6623,9 +6624,9 @@ const moduleDocs$5 = {
|
|
|
6623
6624
|
"message"
|
|
6624
6625
|
] }],
|
|
6625
6626
|
examples: [
|
|
6626
|
-
"let { assert-lte } = import(assertion);\ndo assert-lte(1, 0, \"Expected smaller value value\") with case
|
|
6627
|
-
"let { assert-lte } = import(assertion);\ndo assert-lte(1, 0) with case
|
|
6628
|
-
"let { assert-lte } = import(assertion);\ndo assert-lte(1, 1) with case
|
|
6627
|
+
"let { assert-lte } = import(assertion);\ndo assert-lte(1, 0, \"Expected smaller value value\") with case @dvala.error then ([msg]) -> msg end",
|
|
6628
|
+
"let { assert-lte } = import(assertion);\ndo assert-lte(1, 0) with case @dvala.error then ([msg]) -> msg end",
|
|
6629
|
+
"let { assert-lte } = import(assertion);\ndo assert-lte(1, 1) with case @dvala.error then ([msg]) -> msg end"
|
|
6629
6630
|
],
|
|
6630
6631
|
seeAlso: [
|
|
6631
6632
|
"assertion.assert-gte",
|
|
@@ -6644,9 +6645,9 @@ const moduleDocs$5 = {
|
|
|
6644
6645
|
},
|
|
6645
6646
|
variants: [{ argumentNames: ["value"] }, { argumentNames: ["value", "message"] }],
|
|
6646
6647
|
examples: [
|
|
6647
|
-
"let { assert-true } = import(assertion);\ndo assert-true(false, \"Expected true\") with case
|
|
6648
|
-
"let { assert-true } = import(assertion);\ndo assert-true(false) with case
|
|
6649
|
-
"let { assert-true } = import(assertion);\ndo assert-true(true) with case
|
|
6648
|
+
"let { assert-true } = import(assertion);\ndo assert-true(false, \"Expected true\") with case @dvala.error then ([msg]) -> msg end",
|
|
6649
|
+
"let { assert-true } = import(assertion);\ndo assert-true(false) with case @dvala.error then ([msg]) -> msg end",
|
|
6650
|
+
"let { assert-true } = import(assertion);\ndo assert-true(true) with case @dvala.error then ([msg]) -> msg end"
|
|
6650
6651
|
],
|
|
6651
6652
|
seeAlso: [
|
|
6652
6653
|
"assertion.assert-false",
|
|
@@ -6667,9 +6668,9 @@ const moduleDocs$5 = {
|
|
|
6667
6668
|
},
|
|
6668
6669
|
variants: [{ argumentNames: ["value"] }, { argumentNames: ["value", "message"] }],
|
|
6669
6670
|
examples: [
|
|
6670
|
-
"let { assert-false } = import(assertion);\ndo assert-false(true, \"Expected false\") with case
|
|
6671
|
-
"let { assert-false } = import(assertion);\ndo assert-false(true) with case
|
|
6672
|
-
"let { assert-false } = import(assertion);\ndo assert-false(false) with case
|
|
6671
|
+
"let { assert-false } = import(assertion);\ndo assert-false(true, \"Expected false\") with case @dvala.error then ([msg]) -> msg end",
|
|
6672
|
+
"let { assert-false } = import(assertion);\ndo assert-false(true) with case @dvala.error then ([msg]) -> msg end",
|
|
6673
|
+
"let { assert-false } = import(assertion);\ndo assert-false(false) with case @dvala.error then ([msg]) -> msg end"
|
|
6673
6674
|
],
|
|
6674
6675
|
seeAlso: [
|
|
6675
6676
|
"assertion.assert-true",
|
|
@@ -6689,16 +6690,16 @@ const moduleDocs$5 = {
|
|
|
6689
6690
|
},
|
|
6690
6691
|
variants: [{ argumentNames: ["value"] }, { argumentNames: ["value", "message"] }],
|
|
6691
6692
|
examples: [
|
|
6692
|
-
"let { assert-truthy } = import(assertion);\ndo assert-truthy(false, \"Expected truthy\") with case
|
|
6693
|
-
"let { assert-truthy } = import(assertion);\ndo assert-truthy(false) with case
|
|
6694
|
-
"let { assert-truthy } = import(assertion);\ndo assert-truthy(0) with case
|
|
6695
|
-
"let { assert-truthy } = import(assertion);\ndo assert-truthy(null) with case
|
|
6696
|
-
"let { assert-truthy } = import(assertion);\ndo assert-truthy(\"\") with case
|
|
6697
|
-
"let { assert-truthy } = import(assertion);\ndo assert-truthy(true) with case
|
|
6698
|
-
"let { assert-truthy } = import(assertion);\ndo assert-truthy(1) with case
|
|
6699
|
-
"let { assert-truthy } = import(assertion);\ndo assert-truthy(\"x\") with case
|
|
6700
|
-
"let { assert-truthy } = import(assertion);\ndo assert-truthy([]) with case
|
|
6701
|
-
"let { assert-truthy } = import(assertion);\ndo assert-truthy(nd) with case
|
|
6693
|
+
"let { assert-truthy } = import(assertion);\ndo assert-truthy(false, \"Expected truthy\") with case @dvala.error then ([msg]) -> msg end",
|
|
6694
|
+
"let { assert-truthy } = import(assertion);\ndo assert-truthy(false) with case @dvala.error then ([msg]) -> msg end",
|
|
6695
|
+
"let { assert-truthy } = import(assertion);\ndo assert-truthy(0) with case @dvala.error then ([msg]) -> msg end",
|
|
6696
|
+
"let { assert-truthy } = import(assertion);\ndo assert-truthy(null) with case @dvala.error then ([msg]) -> msg end",
|
|
6697
|
+
"let { assert-truthy } = import(assertion);\ndo assert-truthy(\"\") with case @dvala.error then ([msg]) -> msg end",
|
|
6698
|
+
"let { assert-truthy } = import(assertion);\ndo assert-truthy(true) with case @dvala.error then ([msg]) -> msg end",
|
|
6699
|
+
"let { assert-truthy } = import(assertion);\ndo assert-truthy(1) with case @dvala.error then ([msg]) -> msg end",
|
|
6700
|
+
"let { assert-truthy } = import(assertion);\ndo assert-truthy(\"x\") with case @dvala.error then ([msg]) -> msg end",
|
|
6701
|
+
"let { assert-truthy } = import(assertion);\ndo assert-truthy([]) with case @dvala.error then ([msg]) -> msg end",
|
|
6702
|
+
"let { assert-truthy } = import(assertion);\ndo assert-truthy(nd) with case @dvala.error then ([msg]) -> msg end"
|
|
6702
6703
|
],
|
|
6703
6704
|
seeAlso: [
|
|
6704
6705
|
"assertion.assert-falsy",
|
|
@@ -6719,15 +6720,15 @@ const moduleDocs$5 = {
|
|
|
6719
6720
|
},
|
|
6720
6721
|
variants: [{ argumentNames: ["value"] }, { argumentNames: ["value", "message"] }],
|
|
6721
6722
|
examples: [
|
|
6722
|
-
"let { assert-falsy } = import(assertion);\ndo assert-falsy(true, \"Expected falsy\") with case
|
|
6723
|
-
"let { assert-falsy } = import(assertion);\ndo assert-falsy(\"x\") with case
|
|
6724
|
-
"let { assert-falsy } = import(assertion);\ndo assert-falsy([]) with case
|
|
6725
|
-
"let { assert-falsy } = import(assertion);\ndo assert-falsy(nd) with case
|
|
6726
|
-
"let { assert-falsy } = import(assertion);\ndo assert-falsy(1) with case
|
|
6727
|
-
"let { assert-falsy } = import(assertion);\ndo assert-falsy(false) with case
|
|
6728
|
-
"let { assert-falsy } = import(assertion);\ndo assert-falsy(0) with case
|
|
6729
|
-
"let { assert-falsy } = import(assertion);\ndo assert-falsy(null) with case
|
|
6730
|
-
"let { assert-falsy } = import(assertion);\ndo assert-falsy(\"\") with case
|
|
6723
|
+
"let { assert-falsy } = import(assertion);\ndo assert-falsy(true, \"Expected falsy\") with case @dvala.error then ([msg]) -> msg end",
|
|
6724
|
+
"let { assert-falsy } = import(assertion);\ndo assert-falsy(\"x\") with case @dvala.error then ([msg]) -> msg end",
|
|
6725
|
+
"let { assert-falsy } = import(assertion);\ndo assert-falsy([]) with case @dvala.error then ([msg]) -> msg end",
|
|
6726
|
+
"let { assert-falsy } = import(assertion);\ndo assert-falsy(nd) with case @dvala.error then ([msg]) -> msg end",
|
|
6727
|
+
"let { assert-falsy } = import(assertion);\ndo assert-falsy(1) with case @dvala.error then ([msg]) -> msg end",
|
|
6728
|
+
"let { assert-falsy } = import(assertion);\ndo assert-falsy(false) with case @dvala.error then ([msg]) -> msg end",
|
|
6729
|
+
"let { assert-falsy } = import(assertion);\ndo assert-falsy(0) with case @dvala.error then ([msg]) -> msg end",
|
|
6730
|
+
"let { assert-falsy } = import(assertion);\ndo assert-falsy(null) with case @dvala.error then ([msg]) -> msg end",
|
|
6731
|
+
"let { assert-falsy } = import(assertion);\ndo assert-falsy(\"\") with case @dvala.error then ([msg]) -> msg end"
|
|
6731
6732
|
],
|
|
6732
6733
|
seeAlso: [
|
|
6733
6734
|
"assertion.assert-truthy",
|
|
@@ -6747,15 +6748,15 @@ const moduleDocs$5 = {
|
|
|
6747
6748
|
},
|
|
6748
6749
|
variants: [{ argumentNames: ["value"] }, { argumentNames: ["value", "message"] }],
|
|
6749
6750
|
examples: [
|
|
6750
|
-
"let { assert-null } = import(assertion);\ndo assert-null(null) with case
|
|
6751
|
-
"let { assert-null } = import(assertion);\ndo assert-null(true, \"Expected null\") with case
|
|
6752
|
-
"let { assert-null } = import(assertion);\ndo assert-null(\"x\") with case
|
|
6753
|
-
"let { assert-null } = import(assertion);\ndo assert-null([]) with case
|
|
6754
|
-
"let { assert-null } = import(assertion);\ndo assert-null(nd) with case
|
|
6755
|
-
"let { assert-null } = import(assertion);\ndo assert-null(1) with case
|
|
6756
|
-
"let { assert-null } = import(assertion);\ndo assert-null(false) with case
|
|
6757
|
-
"let { assert-null } = import(assertion);\ndo assert-null(0) with case
|
|
6758
|
-
"let { assert-null } = import(assertion);\ndo assert-null(\"\") with case
|
|
6751
|
+
"let { assert-null } = import(assertion);\ndo assert-null(null) with case @dvala.error then ([msg]) -> msg end",
|
|
6752
|
+
"let { assert-null } = import(assertion);\ndo assert-null(true, \"Expected null\") with case @dvala.error then ([msg]) -> msg end",
|
|
6753
|
+
"let { assert-null } = import(assertion);\ndo assert-null(\"x\") with case @dvala.error then ([msg]) -> msg end",
|
|
6754
|
+
"let { assert-null } = import(assertion);\ndo assert-null([]) with case @dvala.error then ([msg]) -> msg end",
|
|
6755
|
+
"let { assert-null } = import(assertion);\ndo assert-null(nd) with case @dvala.error then ([msg]) -> msg end",
|
|
6756
|
+
"let { assert-null } = import(assertion);\ndo assert-null(1) with case @dvala.error then ([msg]) -> msg end",
|
|
6757
|
+
"let { assert-null } = import(assertion);\ndo assert-null(false) with case @dvala.error then ([msg]) -> msg end",
|
|
6758
|
+
"let { assert-null } = import(assertion);\ndo assert-null(0) with case @dvala.error then ([msg]) -> msg end",
|
|
6759
|
+
"let { assert-null } = import(assertion);\ndo assert-null(\"\") with case @dvala.error then ([msg]) -> msg end"
|
|
6759
6760
|
],
|
|
6760
6761
|
seeAlso: ["assertion.assert-truthy", "assertion.assert-falsy"],
|
|
6761
6762
|
hideOperatorForm: true
|
|
@@ -6769,7 +6770,7 @@ const moduleDocs$5 = {
|
|
|
6769
6770
|
message: { type: "string" }
|
|
6770
6771
|
},
|
|
6771
6772
|
variants: [{ argumentNames: ["fun"] }, { argumentNames: ["fun", "message"] }],
|
|
6772
|
-
examples: ["let { assert-fails } = import(assertion);\nassert-fails(-> perform(
|
|
6773
|
+
examples: ["let { assert-fails } = import(assertion);\nassert-fails(-> perform(@dvala.error, \"Error\"))", "let { assert-fails } = import(assertion);\ndo assert-fails(-> identity(\"Error\")) with case @dvala.error then ([msg]) -> msg end"],
|
|
6773
6774
|
seeAlso: ["assertion.assert-fails-with", "assertion.assert-succeeds"],
|
|
6774
6775
|
hideOperatorForm: true
|
|
6775
6776
|
},
|
|
@@ -6787,7 +6788,7 @@ const moduleDocs$5 = {
|
|
|
6787
6788
|
"error-message",
|
|
6788
6789
|
"message"
|
|
6789
6790
|
] }],
|
|
6790
|
-
examples: ["let { assert-fails-with } = import(assertion);\ndo assert-fails-with(-> perform(
|
|
6791
|
+
examples: ["let { assert-fails-with } = import(assertion);\ndo assert-fails-with(-> perform(@dvala.error, \"Error\"), \"Error\") with case @dvala.error then ([msg]) -> msg end", "let { assert-fails-with } = import(assertion);\ndo assert-fails-with(-> identity(\"Error\"), \"Error\") with case @dvala.error then ([msg]) -> msg end"],
|
|
6791
6792
|
seeAlso: ["assertion.assert-fails", "assertion.assert-succeeds"],
|
|
6792
6793
|
hideOperatorForm: true
|
|
6793
6794
|
},
|
|
@@ -6800,7 +6801,7 @@ const moduleDocs$5 = {
|
|
|
6800
6801
|
message: { type: "string" }
|
|
6801
6802
|
},
|
|
6802
6803
|
variants: [{ argumentNames: ["fun"] }, { argumentNames: ["fun", "message"] }],
|
|
6803
|
-
examples: ["let { assert-succeeds } = import(assertion);\ndo assert-succeeds(-> identity(\"OK\")) with case
|
|
6804
|
+
examples: ["let { assert-succeeds } = import(assertion);\ndo assert-succeeds(-> identity(\"OK\")) with case @dvala.error then ([msg]) -> msg end", "let { assert-succeeds } = import(assertion);\ndo assert-succeeds(-> perform(@dvala.error, \"Error\")) with case @dvala.error then ([msg]) -> msg end"],
|
|
6804
6805
|
seeAlso: ["assertion.assert-fails", "assertion.assert-fails-with"],
|
|
6805
6806
|
hideOperatorForm: true
|
|
6806
6807
|
},
|
|
@@ -6814,9 +6815,9 @@ const moduleDocs$5 = {
|
|
|
6814
6815
|
},
|
|
6815
6816
|
variants: [{ argumentNames: ["value"] }, { argumentNames: ["value", "message"] }],
|
|
6816
6817
|
examples: [
|
|
6817
|
-
"let { assert-array } = import(assertion);\ndo assert-array([1, 2, 3]) with case
|
|
6818
|
-
"let { assert-array } = import(assertion);\ndo assert-array(\"string\") with case
|
|
6819
|
-
"let { assert-array } = import(assertion);\ndo assert-array(42, \"Expected an array\") with case
|
|
6818
|
+
"let { assert-array } = import(assertion);\ndo assert-array([1, 2, 3]) with case @dvala.error then ([msg]) -> msg end",
|
|
6819
|
+
"let { assert-array } = import(assertion);\ndo assert-array(\"string\") with case @dvala.error then ([msg]) -> msg end",
|
|
6820
|
+
"let { assert-array } = import(assertion);\ndo assert-array(42, \"Expected an array\") with case @dvala.error then ([msg]) -> msg end"
|
|
6820
6821
|
],
|
|
6821
6822
|
seeAlso: [
|
|
6822
6823
|
"assertion.assert-object",
|
|
@@ -6835,9 +6836,9 @@ const moduleDocs$5 = {
|
|
|
6835
6836
|
},
|
|
6836
6837
|
variants: [{ argumentNames: ["value"] }, { argumentNames: ["value", "message"] }],
|
|
6837
6838
|
examples: [
|
|
6838
|
-
"let { assert-boolean } = import(assertion);\ndo assert-boolean(true) with case
|
|
6839
|
-
"let { assert-boolean } = import(assertion);\ndo assert-boolean(false) with case
|
|
6840
|
-
"let { assert-boolean } = import(assertion);\ndo assert-boolean(1, \"Expected a boolean\") with case
|
|
6839
|
+
"let { assert-boolean } = import(assertion);\ndo assert-boolean(true) with case @dvala.error then ([msg]) -> msg end",
|
|
6840
|
+
"let { assert-boolean } = import(assertion);\ndo assert-boolean(false) with case @dvala.error then ([msg]) -> msg end",
|
|
6841
|
+
"let { assert-boolean } = import(assertion);\ndo assert-boolean(1, \"Expected a boolean\") with case @dvala.error then ([msg]) -> msg end"
|
|
6841
6842
|
],
|
|
6842
6843
|
seeAlso: [
|
|
6843
6844
|
"assertion.assert-true",
|
|
@@ -6857,10 +6858,10 @@ const moduleDocs$5 = {
|
|
|
6857
6858
|
},
|
|
6858
6859
|
variants: [{ argumentNames: ["value"] }, { argumentNames: ["value", "message"] }],
|
|
6859
6860
|
examples: [
|
|
6860
|
-
"let { assert-collection } = import(assertion);\ndo assert-collection([1, 2]) with case
|
|
6861
|
-
"let { assert-collection } = import(assertion);\ndo assert-collection({ a: 1 }) with case
|
|
6862
|
-
"let { assert-collection } = import(assertion);\ndo assert-collection(\"hello\") with case
|
|
6863
|
-
"let { assert-collection } = import(assertion);\ndo assert-collection(42, \"Expected a collection\") with case
|
|
6861
|
+
"let { assert-collection } = import(assertion);\ndo assert-collection([1, 2]) with case @dvala.error then ([msg]) -> msg end",
|
|
6862
|
+
"let { assert-collection } = import(assertion);\ndo assert-collection({ a: 1 }) with case @dvala.error then ([msg]) -> msg end",
|
|
6863
|
+
"let { assert-collection } = import(assertion);\ndo assert-collection(\"hello\") with case @dvala.error then ([msg]) -> msg end",
|
|
6864
|
+
"let { assert-collection } = import(assertion);\ndo assert-collection(42, \"Expected a collection\") with case @dvala.error then ([msg]) -> msg end"
|
|
6864
6865
|
],
|
|
6865
6866
|
seeAlso: [
|
|
6866
6867
|
"assertion.assert-sequence",
|
|
@@ -6878,7 +6879,7 @@ const moduleDocs$5 = {
|
|
|
6878
6879
|
message: { type: "string" }
|
|
6879
6880
|
},
|
|
6880
6881
|
variants: [{ argumentNames: ["value"] }, { argumentNames: ["value", "message"] }],
|
|
6881
|
-
examples: ["let { assert-function } = import(assertion);\ndo assert-function(-> $ + 1) with case
|
|
6882
|
+
examples: ["let { assert-function } = import(assertion);\ndo assert-function(-> $ + 1) with case @dvala.error then ([msg]) -> msg end", "let { assert-function } = import(assertion);\ndo assert-function(42, \"Expected a function\") with case @dvala.error then ([msg]) -> msg end"],
|
|
6882
6883
|
seeAlso: ["assertion.assert-number", "assertion.assert-string"],
|
|
6883
6884
|
hideOperatorForm: true
|
|
6884
6885
|
},
|
|
@@ -6891,7 +6892,7 @@ const moduleDocs$5 = {
|
|
|
6891
6892
|
message: { type: "string" }
|
|
6892
6893
|
},
|
|
6893
6894
|
variants: [{ argumentNames: ["value"] }, { argumentNames: ["value", "message"] }],
|
|
6894
|
-
examples: ["let { assert-grid } = import(assertion);\ndo assert-grid([[1, 2], [3, 4]]) with case
|
|
6895
|
+
examples: ["let { assert-grid } = import(assertion);\ndo assert-grid([[1, 2], [3, 4]]) with case @dvala.error then ([msg]) -> msg end", "let { assert-grid } = import(assertion);\ndo assert-grid([1, 2], \"Expected a grid\") with case @dvala.error then ([msg]) -> msg end"],
|
|
6895
6896
|
seeAlso: ["assertion.assert-matrix", "assertion.assert-vector"],
|
|
6896
6897
|
hideOperatorForm: true
|
|
6897
6898
|
},
|
|
@@ -6904,7 +6905,7 @@ const moduleDocs$5 = {
|
|
|
6904
6905
|
message: { type: "string" }
|
|
6905
6906
|
},
|
|
6906
6907
|
variants: [{ argumentNames: ["value"] }, { argumentNames: ["value", "message"] }],
|
|
6907
|
-
examples: ["let { assert-integer } = import(assertion);\ndo assert-integer(42) with case
|
|
6908
|
+
examples: ["let { assert-integer } = import(assertion);\ndo assert-integer(42) with case @dvala.error then ([msg]) -> msg end", "let { assert-integer } = import(assertion);\ndo assert-integer(3.14, \"Expected an integer\") with case @dvala.error then ([msg]) -> msg end"],
|
|
6908
6909
|
seeAlso: ["assertion.assert-number"],
|
|
6909
6910
|
hideOperatorForm: true
|
|
6910
6911
|
},
|
|
@@ -6917,7 +6918,7 @@ const moduleDocs$5 = {
|
|
|
6917
6918
|
message: { type: "string" }
|
|
6918
6919
|
},
|
|
6919
6920
|
variants: [{ argumentNames: ["value"] }, { argumentNames: ["value", "message"] }],
|
|
6920
|
-
examples: ["let { assert-matrix } = import(assertion);\ndo assert-matrix([[1, 2], [3, 4]]) with case
|
|
6921
|
+
examples: ["let { assert-matrix } = import(assertion);\ndo assert-matrix([[1, 2], [3, 4]]) with case @dvala.error then ([msg]) -> msg end", "let { assert-matrix } = import(assertion);\ndo assert-matrix([1, 2], \"Expected a matrix\") with case @dvala.error then ([msg]) -> msg end"],
|
|
6921
6922
|
seeAlso: ["assertion.assert-vector", "assertion.assert-grid"],
|
|
6922
6923
|
hideOperatorForm: true
|
|
6923
6924
|
},
|
|
@@ -6930,7 +6931,7 @@ const moduleDocs$5 = {
|
|
|
6930
6931
|
message: { type: "string" }
|
|
6931
6932
|
},
|
|
6932
6933
|
variants: [{ argumentNames: ["value"] }, { argumentNames: ["value", "message"] }],
|
|
6933
|
-
examples: ["let { assert-number } = import(assertion);\ndo assert-number(42) with case
|
|
6934
|
+
examples: ["let { assert-number } = import(assertion);\ndo assert-number(42) with case @dvala.error then ([msg]) -> msg end", "let { assert-number } = import(assertion);\ndo assert-number(\"hello\", \"Expected a number\") with case @dvala.error then ([msg]) -> msg end"],
|
|
6934
6935
|
seeAlso: [
|
|
6935
6936
|
"assertion.assert-integer",
|
|
6936
6937
|
"assertion.assert-boolean",
|
|
@@ -6948,7 +6949,7 @@ const moduleDocs$5 = {
|
|
|
6948
6949
|
message: { type: "string" }
|
|
6949
6950
|
},
|
|
6950
6951
|
variants: [{ argumentNames: ["value"] }, { argumentNames: ["value", "message"] }],
|
|
6951
|
-
examples: ["let { assert-object } = import(assertion);\ndo assert-object({ a: 1 }) with case
|
|
6952
|
+
examples: ["let { assert-object } = import(assertion);\ndo assert-object({ a: 1 }) with case @dvala.error then ([msg]) -> msg end", "let { assert-object } = import(assertion);\ndo assert-object([1, 2], \"Expected an object\") with case @dvala.error then ([msg]) -> msg end"],
|
|
6952
6953
|
seeAlso: ["assertion.assert-array", "assertion.assert-collection"],
|
|
6953
6954
|
hideOperatorForm: true
|
|
6954
6955
|
},
|
|
@@ -6961,7 +6962,7 @@ const moduleDocs$5 = {
|
|
|
6961
6962
|
message: { type: "string" }
|
|
6962
6963
|
},
|
|
6963
6964
|
variants: [{ argumentNames: ["value"] }, { argumentNames: ["value", "message"] }],
|
|
6964
|
-
examples: ["let { assert-regexp } = import(assertion);\ndo assert-regexp(#\"^start\") with case
|
|
6965
|
+
examples: ["let { assert-regexp } = import(assertion);\ndo assert-regexp(#\"^start\") with case @dvala.error then ([msg]) -> msg end", "let { assert-regexp } = import(assertion);\ndo assert-regexp(\"hello\", \"Expected a regexp\") with case @dvala.error then ([msg]) -> msg end"],
|
|
6965
6966
|
seeAlso: ["assertion.assert-string"],
|
|
6966
6967
|
hideOperatorForm: true
|
|
6967
6968
|
},
|
|
@@ -6975,9 +6976,9 @@ const moduleDocs$5 = {
|
|
|
6975
6976
|
},
|
|
6976
6977
|
variants: [{ argumentNames: ["value"] }, { argumentNames: ["value", "message"] }],
|
|
6977
6978
|
examples: [
|
|
6978
|
-
"let { assert-sequence } = import(assertion);\ndo assert-sequence([1, 2]) with case
|
|
6979
|
-
"let { assert-sequence } = import(assertion);\ndo assert-sequence(\"hello\") with case
|
|
6980
|
-
"let { assert-sequence } = import(assertion);\ndo assert-sequence({ a: 1 }, \"Expected a sequence\") with case
|
|
6979
|
+
"let { assert-sequence } = import(assertion);\ndo assert-sequence([1, 2]) with case @dvala.error then ([msg]) -> msg end",
|
|
6980
|
+
"let { assert-sequence } = import(assertion);\ndo assert-sequence(\"hello\") with case @dvala.error then ([msg]) -> msg end",
|
|
6981
|
+
"let { assert-sequence } = import(assertion);\ndo assert-sequence({ a: 1 }, \"Expected a sequence\") with case @dvala.error then ([msg]) -> msg end"
|
|
6981
6982
|
],
|
|
6982
6983
|
seeAlso: ["assertion.assert-collection", "assertion.assert-array"],
|
|
6983
6984
|
hideOperatorForm: true
|
|
@@ -6991,7 +6992,7 @@ const moduleDocs$5 = {
|
|
|
6991
6992
|
message: { type: "string" }
|
|
6992
6993
|
},
|
|
6993
6994
|
variants: [{ argumentNames: ["value"] }, { argumentNames: ["value", "message"] }],
|
|
6994
|
-
examples: ["let { assert-string } = import(assertion);\ndo assert-string(\"hello\") with case
|
|
6995
|
+
examples: ["let { assert-string } = import(assertion);\ndo assert-string(\"hello\") with case @dvala.error then ([msg]) -> msg end", "let { assert-string } = import(assertion);\ndo assert-string(42, \"Expected a string\") with case @dvala.error then ([msg]) -> msg end"],
|
|
6995
6996
|
seeAlso: [
|
|
6996
6997
|
"assertion.assert-number",
|
|
6997
6998
|
"assertion.assert-boolean",
|
|
@@ -7009,7 +7010,7 @@ const moduleDocs$5 = {
|
|
|
7009
7010
|
message: { type: "string" }
|
|
7010
7011
|
},
|
|
7011
7012
|
variants: [{ argumentNames: ["value"] }, { argumentNames: ["value", "message"] }],
|
|
7012
|
-
examples: ["let { assert-vector } = import(assertion);\ndo assert-vector([1, 2, 3]) with case
|
|
7013
|
+
examples: ["let { assert-vector } = import(assertion);\ndo assert-vector([1, 2, 3]) with case @dvala.error then ([msg]) -> msg end", "let { assert-vector } = import(assertion);\ndo assert-vector([\"a\", \"b\"], \"Expected a vector\") with case @dvala.error then ([msg]) -> msg end"],
|
|
7013
7014
|
seeAlso: ["assertion.assert-matrix", "assertion.assert-grid"],
|
|
7014
7015
|
hideOperatorForm: true
|
|
7015
7016
|
}
|
|
@@ -7617,7 +7618,7 @@ const bitwiseUtilsModule = {
|
|
|
7617
7618
|
};
|
|
7618
7619
|
//#endregion
|
|
7619
7620
|
//#region src/builtin/modules/collection/collection.dvala
|
|
7620
|
-
var collection_default$1 = "{\n update: (coll, key, fn, ...extra-params) ->\n assoc(coll, key, apply(fn, [get(coll, key), ...extra-params])),\n\n update-in: (coll, ks, fn, ...extra-params) -> do\n let k = first(ks);\n if count(ks) == 1 then\n assoc(coll, k, apply(fn, [get(coll, k), ...extra-params]))\n else\n let inner = get(coll, k);\n let inner-coll = null?(inner) ? {} : inner;\n assoc(coll, k, apply(self, [inner-coll, slice(ks, 1), fn, ...extra-params]))\n end\n end,\n\n filteri: (coll, fn) -> do\n cond\n case array?(coll) then\n reduce(\n for (i in range(count(coll))) -> [nth(coll, i), i],\n (acc, pair) -> if fn(first(pair), second(pair)) then [...acc, first(pair)] else acc end,\n []\n )\n\n case string?(coll) then\n reduce(\n for (i in range(count(coll))) -> [nth(coll, i), i],\n (acc, pair) -> if fn(first(pair), second(pair)) then ++(acc, first(pair)) else acc end,\n \"\"\n )\n\n case object?(coll) then\n reduce(keys(coll), (acc, k) ->\n if fn(coll(k), k) then assoc(acc, k, coll(k)) else acc end,\n {}\n )\n\n case true then\n perform(
|
|
7621
|
+
var collection_default$1 = "{\n update: (coll, key, fn, ...extra-params) ->\n assoc(coll, key, apply(fn, [get(coll, key), ...extra-params])),\n\n update-in: (coll, ks, fn, ...extra-params) -> do\n let k = first(ks);\n if count(ks) == 1 then\n assoc(coll, k, apply(fn, [get(coll, k), ...extra-params]))\n else\n let inner = get(coll, k);\n let inner-coll = null?(inner) ? {} : inner;\n assoc(coll, k, apply(self, [inner-coll, slice(ks, 1), fn, ...extra-params]))\n end\n end,\n\n filteri: (coll, fn) -> do\n cond\n case array?(coll) then\n reduce(\n for (i in range(count(coll))) -> [nth(coll, i), i],\n (acc, pair) -> if fn(first(pair), second(pair)) then [...acc, first(pair)] else acc end,\n []\n )\n\n case string?(coll) then\n reduce(\n for (i in range(count(coll))) -> [nth(coll, i), i],\n (acc, pair) -> if fn(first(pair), second(pair)) then ++(acc, first(pair)) else acc end,\n \"\"\n )\n\n case object?(coll) then\n reduce(keys(coll), (acc, k) ->\n if fn(coll(k), k) then assoc(acc, k, coll(k)) else acc end,\n {}\n )\n\n case true then\n perform(@dvala.error, \"Expected collection\")\n end\n end,\n\n mapi: (coll, fn) -> do\n cond\n case array?(coll) then\n for (i in range(count(coll))) -> fn(nth(coll, i), i)\n\n case string?(coll) then\n reduce(\n for (i in range(count(coll))) -> fn(nth(coll, i), i),\n (acc, ch) -> ++(acc, ch),\n \"\"\n )\n\n case object?(coll) then\n reduce(keys(coll), (acc, k) ->\n assoc(acc, k, fn(coll(k), k)),\n {}\n )\n\n case true then\n perform(@dvala.error, \"Expected collection\")\n end\n end,\n\n reducei: (coll, fn, initial) -> do\n cond\n case string?(coll) then\n loop (acc = initial, i = 0) -> do\n if i >= count(coll) then\n acc\n else\n recur(fn(acc, nth(coll, i), i), i + 1)\n end\n end\n\n case array?(coll) then\n loop (acc = initial, i = 0) -> do\n if i >= count(coll) then\n acc\n else\n recur(fn(acc, nth(coll, i), i), i + 1)\n end\n end\n\n case object?(coll) then\n reduce(keys(coll), (acc, k) -> fn(acc, coll(k), k), initial)\n\n case true then\n perform(@dvala.error, \"Expected collection\")\n end\n end,\n\n reduce-right: (coll, fn, initial) -> do\n cond\n case string?(coll) then\n reduce(reverse(coll), fn, initial)\n\n case array?(coll) then\n reduce(reverse(coll), fn, initial)\n\n case object?(coll) then\n reduce(reverse(keys(coll)), (acc, k) -> fn(acc, coll(k)), initial)\n\n case true then\n perform(@dvala.error, \"Expected collection\")\n end\n end,\n\n reducei-right: (coll, fn, initial) -> do\n cond\n case string?(coll) then\n let len = count(coll);\n loop (acc = initial, i = len - 1) -> do\n if i < 0 then\n acc\n else\n recur(fn(acc, nth(coll, i), i), i - 1)\n end\n end\n\n case array?(coll) then\n let len = count(coll);\n loop (acc = initial, i = len - 1) -> do\n if i < 0 then\n acc\n else\n recur(fn(acc, nth(coll, i), i), i - 1)\n end\n end\n\n case object?(coll) then\n reduce(reverse(keys(coll)), (acc, k) -> fn(acc, coll(k), k), initial)\n\n case true then\n perform(@dvala.error, \"Expected collection\")\n end\n end,\n\n reductions: (coll, fn, initial) -> do\n let items = cond\n case string?(coll) then\n if count(coll) == 0 then [] else for (i in range(count(coll))) -> nth(coll, i) end\n\n case array?(coll) then coll\n\n case object?(coll) then\n for (k in keys(coll)) -> coll(k)\n\n case true then\n perform(@dvala.error, \"Expected collection\")\n end;\n if count(items) == 0 then\n [initial]\n else\n reduce(items, (acc, elem) -> do\n let prev = last(acc);\n [...acc, fn(prev, elem)]\n end, [initial])\n end\n end,\n\n reductionsi: (coll, fn, initial) -> do\n cond\n case string?(coll) then do\n if count(coll) == 0 then\n [initial]\n else\n reduce(\n for (i in range(count(coll))) -> [nth(coll, i), i],\n (acc, pair) -> do\n let prev = last(acc);\n [...acc, fn(prev, first(pair), second(pair))]\n end,\n [initial]\n )\n end\n end\n\n case array?(coll) then do\n if count(coll) == 0 then\n [initial]\n else\n reduce(\n for (i in range(count(coll))) -> [nth(coll, i), i],\n (acc, pair) -> do\n let prev = last(acc);\n [...acc, fn(prev, first(pair), second(pair))]\n end,\n [initial]\n )\n end\n end\n\n case object?(coll) then do\n let ks = keys(coll);\n if count(ks) == 0 then\n [initial]\n else\n reduce(ks, (acc, k) -> do\n let prev = last(acc);\n [...acc, fn(prev, coll(k), k)]\n end, [initial])\n end\n end\n\n case true then\n perform(@dvala.error, \"Expected collection\")\n end\n end,\n\n \"every?\": (coll, fn) -> do\n let items = cond\n case array?(coll) then coll\n case string?(coll) then for (i in range(count(coll))) -> nth(coll, i)\n case object?(coll) then for (k in keys(coll)) -> [k, coll(k)]\n case true then perform(@dvala.error, \"Expected collection\")\n end;\n loop (i = 0) ->\n cond\n case i >= count(items) then true\n case not(fn(nth(items, i))) then false\n case true then recur(i + 1)\n end\n end,\n\n \"any?\": (coll, fn) -> do\n let items = cond\n case array?(coll) then coll\n case string?(coll) then for (i in range(count(coll))) -> nth(coll, i)\n case object?(coll) then for (k in keys(coll)) -> [k, coll(k)]\n case true then perform(@dvala.error, \"Expected collection\")\n end;\n loop (i = 0) ->\n cond\n case i >= count(items) then false\n case fn(nth(items, i)) then true\n case true then recur(i + 1)\n end\n end,\n\n \"not-any?\": (coll, fn) -> do\n let items = cond\n case array?(coll) then coll\n case string?(coll) then for (i in range(count(coll))) -> nth(coll, i)\n case object?(coll) then for (k in keys(coll)) -> [k, coll(k)]\n case true then perform(@dvala.error, \"Expected collection\")\n end;\n loop (i = 0) ->\n cond\n case i >= count(items) then true\n case fn(nth(items, i)) then false\n case true then recur(i + 1)\n end\n end,\n\n \"not-every?\": (coll, fn) -> do\n let items = cond\n case array?(coll) then coll\n case string?(coll) then for (i in range(count(coll))) -> nth(coll, i)\n case object?(coll) then for (k in keys(coll)) -> [k, coll(k)]\n case true then perform(@dvala.error, \"Expected collection\")\n end;\n loop (i = 0) ->\n cond\n case i >= count(items) then false\n case not(fn(nth(items, i))) then true\n case true then recur(i + 1)\n end\n end\n}";
|
|
7621
7622
|
//#endregion
|
|
7622
7623
|
//#region src/builtin/modules/collection/index.ts
|
|
7623
7624
|
function get(coll, key) {
|
|
@@ -24392,10 +24393,10 @@ const standardEffects = {
|
|
|
24392
24393
|
} },
|
|
24393
24394
|
variants: [{ argumentNames: ["value"] }],
|
|
24394
24395
|
examples: [{
|
|
24395
|
-
code: "perform(
|
|
24396
|
+
code: "perform(@dvala.io.print, \"hello\")",
|
|
24396
24397
|
noRun: true
|
|
24397
24398
|
}, {
|
|
24398
|
-
code: "perform(
|
|
24399
|
+
code: "perform(@dvala.io.print, 42)",
|
|
24399
24400
|
noRun: true
|
|
24400
24401
|
}],
|
|
24401
24402
|
seeAlso: [
|
|
@@ -24420,10 +24421,10 @@ const standardEffects = {
|
|
|
24420
24421
|
} },
|
|
24421
24422
|
variants: [{ argumentNames: ["value"] }],
|
|
24422
24423
|
examples: [{
|
|
24423
|
-
code: "perform(
|
|
24424
|
+
code: "perform(@dvala.io.println, \"hello\")",
|
|
24424
24425
|
noRun: true
|
|
24425
24426
|
}, {
|
|
24426
|
-
code: "perform(
|
|
24427
|
+
code: "perform(@dvala.io.println, [1, 2, 3])",
|
|
24427
24428
|
noRun: true
|
|
24428
24429
|
}],
|
|
24429
24430
|
seeAlso: [
|
|
@@ -24458,7 +24459,7 @@ const standardEffects = {
|
|
|
24458
24459
|
} },
|
|
24459
24460
|
variants: [{ argumentNames: ["value"] }],
|
|
24460
24461
|
examples: [{
|
|
24461
|
-
code: "perform(
|
|
24462
|
+
code: "perform(@dvala.io.error, \"something went wrong\")",
|
|
24462
24463
|
noRun: true
|
|
24463
24464
|
}],
|
|
24464
24465
|
seeAlso: [
|
|
@@ -24492,7 +24493,7 @@ const standardEffects = {
|
|
|
24492
24493
|
description: "Optional prompt message to display."
|
|
24493
24494
|
} },
|
|
24494
24495
|
variants: [{ argumentNames: [] }, { argumentNames: ["message"] }],
|
|
24495
|
-
examples: ["
|
|
24496
|
+
examples: ["@dvala.io.read-line"],
|
|
24496
24497
|
seeAlso: [
|
|
24497
24498
|
"-effect-dvala.io.read-stdin",
|
|
24498
24499
|
"-effect-dvala.io.print",
|
|
@@ -24570,7 +24571,7 @@ const standardEffects = {
|
|
|
24570
24571
|
}
|
|
24571
24572
|
},
|
|
24572
24573
|
variants: [{ argumentNames: ["items"] }, { argumentNames: ["items", "options"] }],
|
|
24573
|
-
examples: ["
|
|
24574
|
+
examples: ["@dvala.io.pick"],
|
|
24574
24575
|
seeAlso: [
|
|
24575
24576
|
"-effect-dvala.io.read-line",
|
|
24576
24577
|
"-effect-dvala.io.confirm",
|
|
@@ -24615,7 +24616,7 @@ const standardEffects = {
|
|
|
24615
24616
|
}
|
|
24616
24617
|
},
|
|
24617
24618
|
variants: [{ argumentNames: ["question"] }, { argumentNames: ["question", "options"] }],
|
|
24618
|
-
examples: ["
|
|
24619
|
+
examples: ["@dvala.io.confirm"],
|
|
24619
24620
|
seeAlso: [
|
|
24620
24621
|
"-effect-dvala.io.read-line",
|
|
24621
24622
|
"-effect-dvala.io.pick",
|
|
@@ -24647,7 +24648,7 @@ const standardEffects = {
|
|
|
24647
24648
|
returns: { type: "string" },
|
|
24648
24649
|
args: {},
|
|
24649
24650
|
variants: [{ argumentNames: [] }],
|
|
24650
|
-
examples: ["
|
|
24651
|
+
examples: ["@dvala.io.read-stdin"],
|
|
24651
24652
|
seeAlso: [
|
|
24652
24653
|
"-effect-dvala.io.read-line",
|
|
24653
24654
|
"perform",
|
|
@@ -24670,7 +24671,7 @@ const standardEffects = {
|
|
|
24670
24671
|
returns: { type: "number" },
|
|
24671
24672
|
args: {},
|
|
24672
24673
|
variants: [{ argumentNames: [] }],
|
|
24673
|
-
examples: ["perform(
|
|
24674
|
+
examples: ["perform(@dvala.random)"],
|
|
24674
24675
|
seeAlso: [
|
|
24675
24676
|
"-effect-dvala.random.int",
|
|
24676
24677
|
"-effect-dvala.random.uuid",
|
|
@@ -24696,7 +24697,7 @@ const standardEffects = {
|
|
|
24696
24697
|
returns: { type: "string" },
|
|
24697
24698
|
args: {},
|
|
24698
24699
|
variants: [{ argumentNames: [] }],
|
|
24699
|
-
examples: ["perform(
|
|
24700
|
+
examples: ["perform(@dvala.random.uuid)"],
|
|
24700
24701
|
seeAlso: [
|
|
24701
24702
|
"-effect-dvala.random",
|
|
24702
24703
|
"perform",
|
|
@@ -24733,7 +24734,7 @@ const standardEffects = {
|
|
|
24733
24734
|
}
|
|
24734
24735
|
},
|
|
24735
24736
|
variants: [{ argumentNames: ["min", "max"] }],
|
|
24736
|
-
examples: ["perform(
|
|
24737
|
+
examples: ["perform(@dvala.random.int, 1, 100)"],
|
|
24737
24738
|
seeAlso: [
|
|
24738
24739
|
"-effect-dvala.random",
|
|
24739
24740
|
"-effect-dvala.random.item",
|
|
@@ -24763,7 +24764,7 @@ const standardEffects = {
|
|
|
24763
24764
|
description: "Non-empty array to pick from."
|
|
24764
24765
|
} },
|
|
24765
24766
|
variants: [{ argumentNames: ["array"] }],
|
|
24766
|
-
examples: ["perform(
|
|
24767
|
+
examples: ["perform(@dvala.random.item, [\"a\", \"b\", \"c\"])"],
|
|
24767
24768
|
seeAlso: [
|
|
24768
24769
|
"-effect-dvala.random",
|
|
24769
24770
|
"-effect-dvala.random.shuffle",
|
|
@@ -24800,7 +24801,7 @@ const standardEffects = {
|
|
|
24800
24801
|
description: "Array to shuffle."
|
|
24801
24802
|
} },
|
|
24802
24803
|
variants: [{ argumentNames: ["array"] }],
|
|
24803
|
-
examples: ["perform(
|
|
24804
|
+
examples: ["perform(@dvala.random.shuffle, [1, 2, 3, 4, 5])"],
|
|
24804
24805
|
seeAlso: [
|
|
24805
24806
|
"-effect-dvala.random",
|
|
24806
24807
|
"-effect-dvala.random.item",
|
|
@@ -24824,7 +24825,7 @@ const standardEffects = {
|
|
|
24824
24825
|
returns: { type: "number" },
|
|
24825
24826
|
args: {},
|
|
24826
24827
|
variants: [{ argumentNames: [] }],
|
|
24827
|
-
examples: ["perform(
|
|
24828
|
+
examples: ["perform(@dvala.time.now)"],
|
|
24828
24829
|
seeAlso: [
|
|
24829
24830
|
"-effect-dvala.time.zone",
|
|
24830
24831
|
"-effect-dvala.sleep",
|
|
@@ -24848,7 +24849,7 @@ const standardEffects = {
|
|
|
24848
24849
|
returns: { type: "string" },
|
|
24849
24850
|
args: {},
|
|
24850
24851
|
variants: [{ argumentNames: [] }],
|
|
24851
|
-
examples: ["perform(
|
|
24852
|
+
examples: ["perform(@dvala.time.zone)"],
|
|
24852
24853
|
seeAlso: [
|
|
24853
24854
|
"-effect-dvala.time.now",
|
|
24854
24855
|
"perform",
|
|
@@ -24876,7 +24877,7 @@ const standardEffects = {
|
|
|
24876
24877
|
}
|
|
24877
24878
|
},
|
|
24878
24879
|
variants: [{ argumentNames: ["message"] }, { argumentNames: ["message", "meta"] }],
|
|
24879
|
-
examples: ["perform(
|
|
24880
|
+
examples: ["perform(@dvala.checkpoint, \"init\")", "perform(@dvala.checkpoint, \"analysis-done\", { step: 1 })"],
|
|
24880
24881
|
seeAlso: ["perform", "effect"]
|
|
24881
24882
|
}
|
|
24882
24883
|
},
|
|
@@ -24902,7 +24903,7 @@ const standardEffects = {
|
|
|
24902
24903
|
description: "The number of milliseconds to sleep. Must be a non-negative number."
|
|
24903
24904
|
} },
|
|
24904
24905
|
variants: [{ argumentNames: ["ms"] }],
|
|
24905
|
-
examples: ["
|
|
24906
|
+
examples: ["@dvala.sleep"],
|
|
24906
24907
|
seeAlso: [
|
|
24907
24908
|
"-effect-dvala.time.now",
|
|
24908
24909
|
"perform",
|
|
@@ -25148,7 +25149,7 @@ const datatype = {
|
|
|
25148
25149
|
title: "effect",
|
|
25149
25150
|
category: "datatype",
|
|
25150
25151
|
description: "An effect, created with the `effect` special expression. Effects are used with `perform` to trigger algebraic effects.",
|
|
25151
|
-
examples: ["
|
|
25152
|
+
examples: ["@dvala.io.println", "@dvala.time.now"]
|
|
25152
25153
|
},
|
|
25153
25154
|
"-type-never": {
|
|
25154
25155
|
datatype: true,
|
|
@@ -25156,8 +25157,8 @@ const datatype = {
|
|
|
25156
25157
|
category: "datatype",
|
|
25157
25158
|
description: "A value that can never be created",
|
|
25158
25159
|
examples: [`
|
|
25159
|
-
// perform(
|
|
25160
|
-
do perform(
|
|
25160
|
+
// perform(@dvala.error, "error") will never return a value
|
|
25161
|
+
do perform(@dvala.error, "error") with case @dvala.error then (args) -> "never" end`]
|
|
25161
25162
|
}
|
|
25162
25163
|
};
|
|
25163
25164
|
//#endregion
|
|
@@ -25575,6 +25576,7 @@ const illegalFirstSymbolCharacters = [
|
|
|
25575
25576
|
"7",
|
|
25576
25577
|
"8",
|
|
25577
25578
|
"9",
|
|
25579
|
+
"@",
|
|
25578
25580
|
...illegalSymbolCharacters
|
|
25579
25581
|
];
|
|
25580
25582
|
const illegalSymbolCharacterSet = new Set(illegalSymbolCharacters);
|
|
@@ -25740,6 +25742,34 @@ const tokenizeBasePrefixedNumber = (input, position) => {
|
|
|
25740
25742
|
if (nextChar && !postNumberRegExp.test(nextChar)) return NO_MATCH;
|
|
25741
25743
|
return [length, ["BasePrefixedNumber", input.substring(position, i)]];
|
|
25742
25744
|
};
|
|
25745
|
+
/**
|
|
25746
|
+
* Tokenize effect name literal: @segment.segment.segment
|
|
25747
|
+
* Each segment follows symbol naming rules. Dots separate segments.
|
|
25748
|
+
* The token value is the name without the @ prefix.
|
|
25749
|
+
*/
|
|
25750
|
+
const tokenizeEffectName = (input, position) => {
|
|
25751
|
+
if (input[position] !== "@") return NO_MATCH;
|
|
25752
|
+
let i = position + 1;
|
|
25753
|
+
const firstChar = input[i];
|
|
25754
|
+
if (!firstChar || illegalFirstSymbolCharacterSet.has(firstChar)) return NO_MATCH;
|
|
25755
|
+
let name = "";
|
|
25756
|
+
while (i < input.length && !illegalSymbolCharacterSet.has(input[i])) {
|
|
25757
|
+
name += input[i];
|
|
25758
|
+
i++;
|
|
25759
|
+
}
|
|
25760
|
+
while (i < input.length && input[i] === ".") {
|
|
25761
|
+
const dotPos = i;
|
|
25762
|
+
i++;
|
|
25763
|
+
const segStart = i;
|
|
25764
|
+
if (i >= input.length || illegalFirstSymbolCharacterSet.has(input[i])) {
|
|
25765
|
+
i = dotPos;
|
|
25766
|
+
break;
|
|
25767
|
+
}
|
|
25768
|
+
while (i < input.length && !illegalSymbolCharacterSet.has(input[i])) i++;
|
|
25769
|
+
name += `.${input.slice(segStart, i)}`;
|
|
25770
|
+
}
|
|
25771
|
+
return [i - position, ["EffectName", name]];
|
|
25772
|
+
};
|
|
25743
25773
|
const tokenizeSymbol = (input, position) => {
|
|
25744
25774
|
let value = input[position];
|
|
25745
25775
|
if (value === "'") {
|
|
@@ -25945,6 +25975,7 @@ const tokenizers = [
|
|
|
25945
25975
|
tokenizeBasePrefixedNumber,
|
|
25946
25976
|
tokenizeNumber,
|
|
25947
25977
|
tokenizeOperator,
|
|
25978
|
+
tokenizeEffectName,
|
|
25948
25979
|
tokenizeSymbol
|
|
25949
25980
|
];
|
|
25950
25981
|
//#endregion
|
|
@@ -26771,6 +26802,7 @@ function findUnresolvedSymbolsInNode(node, contextStack, builtin) {
|
|
|
26771
26802
|
for (const segment of node[1]) findUnresolvedSymbolsInNode(segment, contextStack, builtin)?.forEach((symbol) => unresolvedSymbols.add(symbol));
|
|
26772
26803
|
return unresolvedSymbols;
|
|
26773
26804
|
}
|
|
26805
|
+
case NodeTypes.EffectName: return null;
|
|
26774
26806
|
default: throw new DvalaError(`Unhandled node type: ${nodeType}`, node[2]);
|
|
26775
26807
|
}
|
|
26776
26808
|
}
|
|
@@ -27947,6 +27979,9 @@ function parseOperandPart(ctx) {
|
|
|
27947
27979
|
}
|
|
27948
27980
|
case "ReservedSymbol": return parseReservedSymbol(ctx);
|
|
27949
27981
|
case "RegexpShorthand": return parseRegexpShorthand(ctx);
|
|
27982
|
+
case "EffectName":
|
|
27983
|
+
ctx.advance();
|
|
27984
|
+
return withSourceCodeInfo([NodeTypes.EffectName, token[1]], token[2]);
|
|
27950
27985
|
default: throw new DvalaError(`Unknown token type: ${tokenType}`, token[2]);
|
|
27951
27986
|
}
|
|
27952
27987
|
}
|
|
@@ -28766,6 +28801,11 @@ function stepNode(node, env, k) {
|
|
|
28766
28801
|
case NodeTypes.NormalExpression: return stepNormalExpression(node, env, k);
|
|
28767
28802
|
case NodeTypes.SpecialExpression: return stepSpecialExpression(node, env, k);
|
|
28768
28803
|
case NodeTypes.TemplateString: return stepTemplateString(node, env, k);
|
|
28804
|
+
case NodeTypes.EffectName: return {
|
|
28805
|
+
type: "Value",
|
|
28806
|
+
value: getEffectRef(node[1]),
|
|
28807
|
+
k
|
|
28808
|
+
};
|
|
28769
28809
|
default: throw new DvalaError(`${getNodeTypeName(node[0])}-node cannot be evaluated`, node[2]);
|
|
28770
28810
|
}
|
|
28771
28811
|
}
|
|
@@ -30593,7 +30633,7 @@ function applyPerformArgs(frame, value, k) {
|
|
|
30593
30633
|
/**
|
|
30594
30634
|
* Check if a handler's case clause matches the given effect.
|
|
30595
30635
|
* Supports two forms:
|
|
30596
|
-
* - EffectRef: exact name match (`case
|
|
30636
|
+
* - EffectRef: exact name match (`case @dvala.error`)
|
|
30597
30637
|
* - Predicate function: called with the effect, truthy = match (`case my-predicate`)
|
|
30598
30638
|
*
|
|
30599
30639
|
* Predicate functions must be synchronous — async predicates throw an error.
|
|
@@ -32007,11 +32047,11 @@ async function runEffectLoop(initial, handlers, signal, initialSnapshotState, ma
|
|
|
32007
32047
|
//#endregion
|
|
32008
32048
|
//#region src/builtin/normalExpressions/initCoreDvala.ts
|
|
32009
32049
|
const coreDvalaSources = {
|
|
32010
|
-
collection: "{\n map: (first-coll, ...args) -> do\n let fn = last(args);\n let other-colls = slice(args, 0, count(args) - 1);\n let all-colls = [first-coll, ...other-colls];\n\n cond\n case object?(first-coll) then do\n let expected-keys = keys(first-coll) |> sort;\n doseq (obj in other-colls) -> do\n if not(object?(obj)) then\n perform(
|
|
32050
|
+
collection: "{\n map: (first-coll, ...args) -> do\n let fn = last(args);\n let other-colls = slice(args, 0, count(args) - 1);\n let all-colls = [first-coll, ...other-colls];\n\n cond\n case object?(first-coll) then do\n let expected-keys = keys(first-coll) |> sort;\n doseq (obj in other-colls) -> do\n if not(object?(obj)) then\n perform(@dvala.error, \"Expected object\")\n end;\n let obj-keys = keys(obj) |> sort;\n if not(obj-keys == expected-keys) then\n perform(@dvala.error, ++(\n \"All objects must have the same keys. Expected: \",\n join(expected-keys, \", \"),\n \". Found: \",\n join(obj-keys, \", \")\n ))\n end\n end;\n reduce(keys(first-coll), (acc, k) -> do\n let a = for (coll in all-colls) -> coll(k);\n assoc(acc, k, apply(fn, a))\n end, {})\n end\n\n case string?(first-coll) then do\n doseq (s in other-colls) -> do\n if not(string?(s)) then\n perform(@dvala.error, \"Expected string\")\n end\n end;\n let len = reduce(other-colls, (m, s) -> min(m, count(s)), count(first-coll));\n let mapped = for (i in range(len)) -> do\n let a = for (coll in all-colls) -> nth(coll, i);\n apply(fn, a)\n end;\n reduce(mapped, (acc, ch) -> do\n if not(string?(ch)) then\n perform(@dvala.error, \"Expected string\")\n end;\n ++(acc, ch)\n end, \"\")\n end\n\n case true then do\n doseq (x in other-colls) -> do\n if not(array?(x)) then\n perform(@dvala.error, \"Expected array\")\n end\n end;\n let len = reduce(other-colls, (m, x) -> min(m, count(x)), count(first-coll));\n for (i in range(len)) -> do\n let a = for (coll in all-colls) -> nth(coll, i);\n apply(fn, a)\n end\n end\n end\n end,\n\n filter: (coll, fn) -> do\n cond\n case array?(coll) then\n reduce(coll, (acc, elem) -> if fn(elem) then [...acc, elem] else acc end, [])\n\n case string?(coll) then\n reduce(coll, (acc, ch) -> if fn(ch) then ++(acc, ch) else acc end, \"\")\n\n case object?(coll) then\n reduce(keys(coll), (acc, k) -> do\n if fn(coll(k)) then\n assoc(acc, k, coll(k))\n else\n acc\n end\n end, {})\n\n case true then\n perform(@dvala.error, \"Expected collection\")\n end\n end,\n\n reduce: (coll, fn, initial) -> do\n cond\n case string?(coll) then\n loop (acc = initial, i = 0) -> do\n if i >= count(coll) then\n acc\n else\n recur(fn(acc, nth(coll, i)), i + 1)\n end\n end\n\n case array?(coll) then\n loop (acc = initial, i = 0) -> do\n if i >= count(coll) then\n acc\n else\n recur(fn(acc, nth(coll, i)), i + 1)\n end\n end\n\n case object?(coll) then do\n let values = vals(coll);\n loop (acc = initial, i = 0) -> do\n if i >= count(values) then\n acc\n else\n recur(fn(acc, nth(values, i)), i + 1)\n end\n end\n end\n\n case true then\n perform(@dvala.error, \"Expected collection\")\n end\n end\n}",
|
|
32011
32051
|
sequence: "{\n some: (seq, fn) -> do\n if null?(seq) then null\n else do\n loop (i = 0) -> do\n if i >= count(seq) then\n null\n else do\n let elem = nth(seq, i);\n if fn(elem) then elem\n else recur(i + 1)\n end\n end\n end\n end\n end\n end\n end,\n\n take-while: (seq, fn) -> do\n let is-str = string?(seq);\n let len = count(seq);\n let idx = loop (i = 0) -> do\n if i >= len then\n len\n else if fn(nth(seq, i)) then\n recur(i + 1)\n else\n i\n end\n end\n end;\n slice(seq, 0, idx)\n end,\n\n drop-while: (seq, fn) -> do\n let is-str = string?(seq);\n let len = count(seq);\n let idx = loop (i = 0) -> do\n if i >= len then\n len\n else if fn(nth(seq, i)) then\n recur(i + 1)\n else\n i\n end\n end\n end;\n slice(seq, idx)\n end,\n\n sort: (seq, ...args) -> do\n let cmp = if count(args) == 0 then compare else first(args) end;\n let is-str = string?(seq);\n let arr = if is-str then split(seq, \"\") else seq end;\n let len = count(arr);\n\n // merge two sorted arrays\n let merge-arrays = (left, right) -> do\n let left-len = count(left);\n let right-len = count(right);\n loop (result = [], li = 0, ri = 0) -> do\n if li >= left-len then\n ++(result, slice(right, ri))\n else if ri >= right-len then\n ++(result, slice(left, li))\n else do\n let l = nth(left, li);\n let r = nth(right, ri);\n if cmp(l, r) <= 0 then\n recur(push(result, l), li + 1, ri)\n else\n recur(push(result, r), li, ri + 1)\n end\n end\n end\n end\n end\n end;\n\n // recursive merge-sort\n let merge-sort = (a) -> do\n let n = count(a);\n if n <= 1 then a\n else do\n let mid = floor(n / 2);\n let left = merge-sort(slice(a, 0, mid));\n let right = merge-sort(slice(a, mid));\n merge-arrays(left, right)\n end\n end\n end;\n\n let sorted = merge-sort(arr);\n if is-str then join(sorted, \"\") else sorted end\n end\n}\n",
|
|
32012
|
-
array: "{\n mapcat: (arr, fn) -> do\n flatten(map(arr, fn), 1)\n end,\n\n moving-fn: (arr, window-size, fn) -> do\n if window-size > count(arr) then\n perform(
|
|
32052
|
+
array: "{\n mapcat: (arr, fn) -> do\n flatten(map(arr, fn), 1)\n end,\n\n moving-fn: (arr, window-size, fn) -> do\n if window-size > count(arr) then\n perform(@dvala.error, \"Expected window-size <= array length\")\n end;\n for (i in range(count(arr) - window-size + 1)) -> do\n fn(slice(arr, i, i + window-size))\n end\n end,\n\n running-fn: (arr, fn) -> do\n for (i in range(count(arr))) -> do\n fn(slice(arr, 0, i + 1))\n end\n end\n}\n",
|
|
32013
32053
|
functional: "{\n \"|>\": (a, b) -> b(a),\n\n apply: (fn, ...args) -> do\n let arr = last(args);\n let leading = slice(args, 0, count(args) - 1);\n fn(...leading, ...arr)\n end\n}\n",
|
|
32014
|
-
object: "{\n merge-with: (...args) -> do\n let fn = last(args);\n let objs = slice(args, 0, count(args) - 1);\n if not(function?(fn)) then\n perform(
|
|
32054
|
+
object: "{\n merge-with: (...args) -> do\n let fn = last(args);\n let objs = slice(args, 0, count(args) - 1);\n if not(function?(fn)) then\n perform(@dvala.error, str(\"Expected function, got: \", type(fn)))\n end;\n if count(objs) == 0 then\n perform(@dvala.error, \"Expected at least one object argument\")\n end;\n reduce(rest(objs), (result, obj) -> do\n if not(object?(obj)) then\n perform(@dvala.error, str(\"Expected object, got: \", type(obj)))\n end;\n reduce(keys(obj), (res, key) -> do\n if contains?(res, key) then\n assoc(res, key, fn(get(res, key), get(obj, key)))\n else\n assoc(res, key, get(obj, key))\n end\n end, result)\n end, do\n let f = first(objs);\n if not(object?(f)) then\n perform(@dvala.error, str(\"Expected object, got: \", type(f)))\n end;\n f\n end)\n end\n}\n"
|
|
32015
32055
|
};
|
|
32016
32056
|
let initialized = false;
|
|
32017
32057
|
function initCoreDvalaSources() {
|
package/package.json
CHANGED