@mojir/dvala 0.0.1 → 0.0.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +1 -1
- package/README.md +1613 -4
- package/dist/bundler.esm.js +2 -0
- package/dist/bundler.esm.js.map +1 -0
- package/dist/bundler.js +2 -0
- package/dist/bundler.js.map +1 -0
- package/dist/cli/cli/src/cli.d.ts +2 -0
- package/dist/cli/cli/src/cliDocumentation/formatCliDescription.d.ts +3 -0
- package/dist/cli/cli/src/cliDocumentation/getCliArgumentInfo.d.ts +3 -0
- package/dist/cli/cli/src/cliDocumentation/getCliDocumentation.d.ts +2 -0
- package/dist/cli/cli/src/cliDocumentation/getCliFunctionExamples.d.ts +3 -0
- package/dist/cli/cli/src/cliDocumentation/getCliFunctionSignature.d.ts +3 -0
- package/dist/cli/cli/src/cliDocumentation/getCliTitle.d.ts +3 -0
- package/dist/cli/cli/src/cliDocumentation/getCliType.d.ts +3 -0
- package/dist/cli/cli/src/cliFormatterRules.d.ts +13 -0
- package/dist/cli/cli/src/colorizer.d.ts +939 -0
- package/dist/cli/cli/src/createReadlineInterface.d.ts +5 -0
- package/dist/cli/cli/src/js-interop/Cli/Fs/index.d.ts +2 -0
- package/dist/cli/cli/src/js-interop/Cli/Proc/index.d.ts +3 -0
- package/dist/cli/cli/src/js-interop/Cli/index.d.ts +2 -0
- package/dist/cli/cli.js +38614 -0
- package/dist/cli/common/createFormatter.d.ts +6 -0
- package/dist/cli/common/utils.d.ts +2 -0
- package/dist/cli/reference/api.d.ts +75 -0
- package/dist/cli/reference/datatype.d.ts +3 -0
- package/dist/cli/reference/effect.d.ts +3 -0
- package/dist/cli/reference/examples.d.ts +11 -0
- package/dist/cli/reference/index.d.ts +191 -0
- package/dist/cli/reference/shorthand.d.ts +3 -0
- package/dist/cli/src/AutoCompleter/AutoCompleter.d.ts +25 -0
- package/dist/cli/src/Dvala/Cache.d.ts +16 -0
- package/dist/cli/src/Dvala/Dvala.d.ts +68 -0
- package/dist/cli/src/allModules.d.ts +2 -0
- package/dist/cli/src/builtin/bindingNode.d.ts +11 -0
- package/dist/cli/src/builtin/core/array.d.ts +2 -0
- package/dist/cli/src/builtin/core/assertion.d.ts +2 -0
- package/dist/cli/src/builtin/core/bitwise.d.ts +2 -0
- package/dist/cli/src/builtin/core/collection.d.ts +2 -0
- package/dist/cli/src/builtin/core/functional.d.ts +2 -0
- package/dist/cli/src/builtin/core/math.d.ts +2 -0
- package/dist/cli/src/builtin/core/meta.d.ts +3 -0
- package/dist/cli/src/builtin/core/misc.d.ts +2 -0
- package/dist/cli/src/builtin/core/object.d.ts +2 -0
- package/dist/cli/src/builtin/core/predicates.d.ts +2 -0
- package/dist/cli/src/builtin/core/regexp.d.ts +2 -0
- package/dist/cli/src/builtin/core/sequence.d.ts +2 -0
- package/dist/cli/src/builtin/core/string.d.ts +2 -0
- package/dist/cli/src/builtin/core/vector.d.ts +2 -0
- package/dist/cli/src/builtin/index.d.ts +13 -0
- package/dist/cli/src/builtin/interface.d.ts +113 -0
- package/dist/cli/src/builtin/modules/assertion/docs.d.ts +2 -0
- package/dist/cli/src/builtin/modules/assertion/index.d.ts +2 -0
- package/dist/cli/src/builtin/modules/bitwise/index.d.ts +2 -0
- package/dist/cli/src/builtin/modules/collection/index.d.ts +2 -0
- package/dist/cli/src/builtin/modules/convert/index.d.ts +2 -0
- package/dist/cli/src/builtin/modules/functional/index.d.ts +2 -0
- package/dist/cli/src/builtin/modules/grid/docs.d.ts +2 -0
- package/dist/cli/src/builtin/modules/grid/fromArray.d.ts +8 -0
- package/dist/cli/src/builtin/modules/grid/index.d.ts +2 -0
- package/dist/cli/src/builtin/modules/grid/transpose.d.ts +2 -0
- package/dist/cli/src/builtin/modules/interface.d.ts +11 -0
- package/dist/cli/src/builtin/modules/linear-algebra/docs.d.ts +2 -0
- package/dist/cli/src/builtin/modules/linear-algebra/helpers/calcFractionalRanks.d.ts +1 -0
- package/dist/cli/src/builtin/modules/linear-algebra/helpers/collinear.d.ts +2 -0
- package/dist/cli/src/builtin/modules/linear-algebra/helpers/corrleation.d.ts +8 -0
- package/dist/cli/src/builtin/modules/linear-algebra/helpers/covariance.d.ts +4 -0
- package/dist/cli/src/builtin/modules/linear-algebra/helpers/dot.d.ts +1 -0
- package/dist/cli/src/builtin/modules/linear-algebra/helpers/gaussJordanElimination.d.ts +7 -0
- package/dist/cli/src/builtin/modules/linear-algebra/helpers/getUnit.d.ts +2 -0
- package/dist/cli/src/builtin/modules/linear-algebra/helpers/isZeroVector.d.ts +1 -0
- package/dist/cli/src/builtin/modules/linear-algebra/helpers/kendallTau.d.ts +10 -0
- package/dist/cli/src/builtin/modules/linear-algebra/helpers/length.d.ts +1 -0
- package/dist/cli/src/builtin/modules/linear-algebra/helpers/pearsonCorr.d.ts +1 -0
- package/dist/cli/src/builtin/modules/linear-algebra/helpers/scale.d.ts +1 -0
- package/dist/cli/src/builtin/modules/linear-algebra/helpers/solve.d.ts +8 -0
- package/dist/cli/src/builtin/modules/linear-algebra/helpers/subtract.d.ts +1 -0
- package/dist/cli/src/builtin/modules/linear-algebra/index.d.ts +4 -0
- package/dist/cli/src/builtin/modules/math/index.d.ts +2 -0
- package/dist/cli/src/builtin/modules/matrix/docs.d.ts +2 -0
- package/dist/cli/src/builtin/modules/matrix/helpers/adjugate.d.ts +1 -0
- package/dist/cli/src/builtin/modules/matrix/helpers/band.d.ts +9 -0
- package/dist/cli/src/builtin/modules/matrix/helpers/cofactor.d.ts +1 -0
- package/dist/cli/src/builtin/modules/matrix/helpers/determinant.d.ts +6 -0
- package/dist/cli/src/builtin/modules/matrix/helpers/inverse.d.ts +6 -0
- package/dist/cli/src/builtin/modules/matrix/helpers/isBanded.d.ts +11 -0
- package/dist/cli/src/builtin/modules/matrix/helpers/isDiagonal.d.ts +10 -0
- package/dist/cli/src/builtin/modules/matrix/helpers/isIdentity.d.ts +1 -0
- package/dist/cli/src/builtin/modules/matrix/helpers/isOrthogonal.d.ts +1 -0
- package/dist/cli/src/builtin/modules/matrix/helpers/isSquare.d.ts +1 -0
- package/dist/cli/src/builtin/modules/matrix/helpers/isSymetric.d.ts +8 -0
- package/dist/cli/src/builtin/modules/matrix/helpers/isTriangular.d.ts +13 -0
- package/dist/cli/src/builtin/modules/matrix/helpers/matrixMultiply.d.ts +7 -0
- package/dist/cli/src/builtin/modules/matrix/helpers/minor.d.ts +1 -0
- package/dist/cli/src/builtin/modules/matrix/helpers/norm1.d.ts +1 -0
- package/dist/cli/src/builtin/modules/matrix/helpers/trace.d.ts +8 -0
- package/dist/cli/src/builtin/modules/matrix/index.d.ts +4 -0
- package/dist/cli/src/builtin/modules/number-theory/binomialCefficient.d.ts +1 -0
- package/dist/cli/src/builtin/modules/number-theory/combinations.d.ts +2 -0
- package/dist/cli/src/builtin/modules/number-theory/derangements.d.ts +2 -0
- package/dist/cli/src/builtin/modules/number-theory/divisors.d.ts +4 -0
- package/dist/cli/src/builtin/modules/number-theory/docs.d.ts +2 -0
- package/dist/cli/src/builtin/modules/number-theory/factorial.d.ts +3 -0
- package/dist/cli/src/builtin/modules/number-theory/index.d.ts +4 -0
- package/dist/cli/src/builtin/modules/number-theory/partitions.d.ts +2 -0
- package/dist/cli/src/builtin/modules/number-theory/permutations.d.ts +2 -0
- package/dist/cli/src/builtin/modules/number-theory/powerSet.d.ts +2 -0
- package/dist/cli/src/builtin/modules/number-theory/primeFactors.d.ts +11 -0
- package/dist/cli/src/builtin/modules/number-theory/sequences/abundant.d.ts +2 -0
- package/dist/cli/src/builtin/modules/number-theory/sequences/arithmetic.d.ts +2 -0
- package/dist/cli/src/builtin/modules/number-theory/sequences/bell.d.ts +1 -0
- package/dist/cli/src/builtin/modules/number-theory/sequences/bernoulli.d.ts +2 -0
- package/dist/cli/src/builtin/modules/number-theory/sequences/catalan.d.ts +1 -0
- package/dist/cli/src/builtin/modules/number-theory/sequences/collatz.d.ts +2 -0
- package/dist/cli/src/builtin/modules/number-theory/sequences/composite.d.ts +3 -0
- package/dist/cli/src/builtin/modules/number-theory/sequences/deficient.d.ts +2 -0
- package/dist/cli/src/builtin/modules/number-theory/sequences/factorial.d.ts +1 -0
- package/dist/cli/src/builtin/modules/number-theory/sequences/fibonacci.d.ts +1 -0
- package/dist/cli/src/builtin/modules/number-theory/sequences/geometric.d.ts +2 -0
- package/dist/cli/src/builtin/modules/number-theory/sequences/golomb.d.ts +2 -0
- package/dist/cli/src/builtin/modules/number-theory/sequences/happy.d.ts +2 -0
- package/dist/cli/src/builtin/modules/number-theory/sequences/index.d.ts +27 -0
- package/dist/cli/src/builtin/modules/number-theory/sequences/juggler.d.ts +2 -0
- package/dist/cli/src/builtin/modules/number-theory/sequences/lookAndSay.d.ts +2 -0
- package/dist/cli/src/builtin/modules/number-theory/sequences/lucas.d.ts +1 -0
- package/dist/cli/src/builtin/modules/number-theory/sequences/lucky.d.ts +2 -0
- package/dist/cli/src/builtin/modules/number-theory/sequences/mersenne.d.ts +1 -0
- package/dist/cli/src/builtin/modules/number-theory/sequences/padovan.d.ts +2 -0
- package/dist/cli/src/builtin/modules/number-theory/sequences/partition.d.ts +1 -0
- package/dist/cli/src/builtin/modules/number-theory/sequences/pell.d.ts +1 -0
- package/dist/cli/src/builtin/modules/number-theory/sequences/perfect.d.ts +1 -0
- package/dist/cli/src/builtin/modules/number-theory/sequences/perfectCube.d.ts +2 -0
- package/dist/cli/src/builtin/modules/number-theory/sequences/perfectPower.d.ts +10 -0
- package/dist/cli/src/builtin/modules/number-theory/sequences/perfectSquare.d.ts +2 -0
- package/dist/cli/src/builtin/modules/number-theory/sequences/poligonal.d.ts +2 -0
- package/dist/cli/src/builtin/modules/number-theory/sequences/prime.d.ts +3 -0
- package/dist/cli/src/builtin/modules/number-theory/sequences/recaman.d.ts +9 -0
- package/dist/cli/src/builtin/modules/number-theory/sequences/sylvester.d.ts +1 -0
- package/dist/cli/src/builtin/modules/number-theory/sequences/thueMorse.d.ts +2 -0
- package/dist/cli/src/builtin/modules/number-theory/sequences/tribonacci.d.ts +1 -0
- package/dist/cli/src/builtin/modules/random/docs.d.ts +2 -0
- package/dist/cli/src/builtin/modules/random/index.d.ts +2 -0
- package/dist/cli/src/builtin/modules/sequence/index.d.ts +2 -0
- package/dist/cli/src/builtin/modules/string/index.d.ts +2 -0
- package/dist/cli/src/builtin/modules/vector/bincount.d.ts +9 -0
- package/dist/cli/src/builtin/modules/vector/calcMad.d.ts +1 -0
- package/dist/cli/src/builtin/modules/vector/calcMean.d.ts +1 -0
- package/dist/cli/src/builtin/modules/vector/calcMedad.d.ts +1 -0
- package/dist/cli/src/builtin/modules/vector/calcMedian.d.ts +1 -0
- package/dist/cli/src/builtin/modules/vector/calcStdDev.d.ts +2 -0
- package/dist/cli/src/builtin/modules/vector/calcVariance.d.ts +2 -0
- package/dist/cli/src/builtin/modules/vector/docs.d.ts +2 -0
- package/dist/cli/src/builtin/modules/vector/entropy.d.ts +8 -0
- package/dist/cli/src/builtin/modules/vector/histogram.d.ts +9 -0
- package/dist/cli/src/builtin/modules/vector/index.d.ts +2 -0
- package/dist/cli/src/builtin/modules/vector/mode.d.ts +6 -0
- package/dist/cli/src/builtin/modules/vector/outliers.d.ts +7 -0
- package/dist/cli/src/builtin/modules/vector/percentile.d.ts +7 -0
- package/dist/cli/src/builtin/modules/vector/quartiles.d.ts +1 -0
- package/dist/cli/src/builtin/modules/vector/reductionFunctions/entropy.d.ts +2 -0
- package/dist/cli/src/builtin/modules/vector/reductionFunctions/giniCoefficient.d.ts +2 -0
- package/dist/cli/src/builtin/modules/vector/reductionFunctions/index.d.ts +13 -0
- package/dist/cli/src/builtin/modules/vector/reductionFunctions/iqr.d.ts +2 -0
- package/dist/cli/src/builtin/modules/vector/reductionFunctions/kurtosis.d.ts +5 -0
- package/dist/cli/src/builtin/modules/vector/reductionFunctions/mad.d.ts +2 -0
- package/dist/cli/src/builtin/modules/vector/reductionFunctions/mean.d.ts +4 -0
- package/dist/cli/src/builtin/modules/vector/reductionFunctions/medad.d.ts +2 -0
- package/dist/cli/src/builtin/modules/vector/reductionFunctions/median.d.ts +2 -0
- package/dist/cli/src/builtin/modules/vector/reductionFunctions/prod.d.ts +2 -0
- package/dist/cli/src/builtin/modules/vector/reductionFunctions/rms.d.ts +2 -0
- package/dist/cli/src/builtin/modules/vector/reductionFunctions/skewness.d.ts +3 -0
- package/dist/cli/src/builtin/modules/vector/reductionFunctions/span.d.ts +2 -0
- package/dist/cli/src/builtin/modules/vector/reductionFunctions/standardDeviation.d.ts +3 -0
- package/dist/cli/src/builtin/modules/vector/reductionFunctions/sum.d.ts +2 -0
- package/dist/cli/src/builtin/modules/vector/reductionFunctions/variance.d.ts +3 -0
- package/dist/cli/src/builtin/normalExpressions/index.d.ts +8 -0
- package/dist/cli/src/builtin/specialExpressionTypes.d.ts +26 -0
- package/dist/cli/src/builtin/specialExpressions/and.d.ts +6 -0
- package/dist/cli/src/builtin/specialExpressions/array.d.ts +6 -0
- package/dist/cli/src/builtin/specialExpressions/block.d.ts +6 -0
- package/dist/cli/src/builtin/specialExpressions/cond.d.ts +6 -0
- package/dist/cli/src/builtin/specialExpressions/defined.d.ts +5 -0
- package/dist/cli/src/builtin/specialExpressions/effect.d.ts +5 -0
- package/dist/cli/src/builtin/specialExpressions/functions.d.ts +6 -0
- package/dist/cli/src/builtin/specialExpressions/if.d.ts +6 -0
- package/dist/cli/src/builtin/specialExpressions/import.d.ts +6 -0
- package/dist/cli/src/builtin/specialExpressions/let.d.ts +6 -0
- package/dist/cli/src/builtin/specialExpressions/loop.d.ts +6 -0
- package/dist/cli/src/builtin/specialExpressions/loops.d.ts +9 -0
- package/dist/cli/src/builtin/specialExpressions/match.d.ts +7 -0
- package/dist/cli/src/builtin/specialExpressions/object.d.ts +6 -0
- package/dist/cli/src/builtin/specialExpressions/or.d.ts +6 -0
- package/dist/cli/src/builtin/specialExpressions/parallel.d.ts +6 -0
- package/dist/cli/src/builtin/specialExpressions/perform.d.ts +6 -0
- package/dist/cli/src/builtin/specialExpressions/qq.d.ts +6 -0
- package/dist/cli/src/builtin/specialExpressions/race.d.ts +6 -0
- package/dist/cli/src/builtin/specialExpressions/recur.d.ts +5 -0
- package/dist/cli/src/builtin/specialExpressions/throw.d.ts +5 -0
- package/dist/cli/src/builtin/specialExpressions/try.d.ts +7 -0
- package/dist/cli/src/builtin/specialExpressions/unless.d.ts +6 -0
- package/dist/cli/src/builtin/utils.d.ts +6 -0
- package/dist/cli/src/bundler/index.d.ts +9 -0
- package/dist/cli/src/bundler/interface.d.ts +15 -0
- package/dist/cli/src/bundler.d.ts +3 -0
- package/dist/cli/src/cli.d.ts +2 -0
- package/dist/cli/src/cliDocumentation/formatCliDescription.d.ts +3 -0
- package/dist/cli/src/cliDocumentation/getCliArgumentInfo.d.ts +3 -0
- package/dist/cli/src/cliDocumentation/getCliDocumentation.d.ts +2 -0
- package/dist/cli/src/cliDocumentation/getCliFunctionExamples.d.ts +3 -0
- package/dist/cli/src/cliDocumentation/getCliFunctionSignature.d.ts +3 -0
- package/dist/cli/src/cliDocumentation/getCliTitle.d.ts +3 -0
- package/dist/cli/src/cliDocumentation/getCliType.d.ts +3 -0
- package/dist/cli/src/cliFormatterRules.d.ts +13 -0
- package/dist/cli/src/colorizer.d.ts +939 -0
- package/dist/cli/src/constants/constants.d.ts +19 -0
- package/dist/cli/src/createReadlineInterface.d.ts +5 -0
- package/dist/cli/src/effects.d.ts +106 -0
- package/dist/cli/src/errors.d.ts +24 -0
- package/dist/cli/src/evaluator/ContextStack.d.ts +65 -0
- package/dist/cli/src/evaluator/effectRef.d.ts +27 -0
- package/dist/cli/src/evaluator/effectTypes.d.ts +79 -0
- package/dist/cli/src/evaluator/frames.d.ts +525 -0
- package/dist/cli/src/evaluator/interface.d.ts +14 -0
- package/dist/cli/src/evaluator/serialization.d.ts +45 -0
- package/dist/cli/src/evaluator/standardEffects.d.ts +35 -0
- package/dist/cli/src/evaluator/step.d.ts +159 -0
- package/dist/cli/src/evaluator/suspension.d.ts +53 -0
- package/dist/cli/src/evaluator/trampoline.d.ts +119 -0
- package/dist/cli/src/getUndefinedSymbols/index.d.ts +7 -0
- package/dist/cli/src/index.d.ts +18 -0
- package/dist/cli/src/initReferenceData.d.ts +1 -0
- package/dist/cli/src/interface.d.ts +7 -0
- package/dist/cli/src/js-interop/Cli/Fs/index.d.ts +2 -0
- package/dist/cli/src/js-interop/Cli/Proc/index.d.ts +3 -0
- package/dist/cli/src/js-interop/Cli/index.d.ts +2 -0
- package/dist/cli/src/parser/ParserContext.d.ts +20 -0
- package/dist/cli/src/parser/getPrecedence.d.ts +3 -0
- package/dist/cli/src/parser/helpers.d.ts +19 -0
- package/dist/cli/src/parser/index.d.ts +5 -0
- package/dist/cli/src/parser/subParsers/parseArray.d.ts +3 -0
- package/dist/cli/src/parser/subParsers/parseBindingTarget.d.ts +8 -0
- package/dist/cli/src/parser/subParsers/parseCond.d.ts +4 -0
- package/dist/cli/src/parser/subParsers/parseDo.d.ts +3 -0
- package/dist/cli/src/parser/subParsers/parseExpression.d.ts +5 -0
- package/dist/cli/src/parser/subParsers/parseForOrDoseq.d.ts +4 -0
- package/dist/cli/src/parser/subParsers/parseFunction.d.ts +4 -0
- package/dist/cli/src/parser/subParsers/parseFunctionCall.d.ts +3 -0
- package/dist/cli/src/parser/subParsers/parseIfOrUnless.d.ts +5 -0
- package/dist/cli/src/parser/subParsers/parseImplicitBlock.d.ts +5 -0
- package/dist/cli/src/parser/subParsers/parseLet.d.ts +4 -0
- package/dist/cli/src/parser/subParsers/parseLoop.d.ts +4 -0
- package/dist/cli/src/parser/subParsers/parseMatch.d.ts +4 -0
- package/dist/cli/src/parser/subParsers/parseNumber.d.ts +3 -0
- package/dist/cli/src/parser/subParsers/parseObject.d.ts +3 -0
- package/dist/cli/src/parser/subParsers/parseOperand.d.ts +3 -0
- package/dist/cli/src/parser/subParsers/parseRegexpShorthand.d.ts +3 -0
- package/dist/cli/src/parser/subParsers/parseReservedSymbol.d.ts +3 -0
- package/dist/cli/src/parser/subParsers/parseString.d.ts +4 -0
- package/dist/cli/src/parser/subParsers/parseSymbol.d.ts +3 -0
- package/dist/cli/src/parser/subParsers/parseTry.d.ts +4 -0
- package/dist/cli/src/parser/types.d.ts +129 -0
- package/dist/cli/src/symbolPatterns.d.ts +2 -0
- package/dist/cli/src/testFramework/index.d.ts +15 -0
- package/dist/cli/src/tokenizer/minifyTokenStream.d.ts +4 -0
- package/dist/cli/src/tokenizer/operators.d.ts +12 -0
- package/dist/cli/src/tokenizer/reservedNames.d.ts +66 -0
- package/dist/cli/src/tokenizer/token.d.ts +84 -0
- package/dist/cli/src/tokenizer/tokenize.d.ts +8 -0
- package/dist/cli/src/tokenizer/tokenizers.d.ts +14 -0
- package/dist/cli/src/transformer/index.d.ts +2 -0
- package/dist/cli/src/typeGuards/annotatedArrays.d.ts +16 -0
- package/dist/cli/src/typeGuards/array.d.ts +9 -0
- package/dist/cli/src/typeGuards/astNode.d.ts +19 -0
- package/dist/cli/src/typeGuards/dvala.d.ts +26 -0
- package/dist/cli/src/typeGuards/dvalaFunction.d.ts +12 -0
- package/dist/cli/src/typeGuards/index.d.ts +7 -0
- package/dist/cli/src/typeGuards/number.d.ts +66 -0
- package/dist/cli/src/typeGuards/string.d.ts +15 -0
- package/dist/cli/src/untokenizer/index.d.ts +2 -0
- package/dist/cli/src/utils/arity.d.ts +10 -0
- package/dist/cli/src/utils/debug/debugTools.d.ts +1 -0
- package/dist/cli/src/utils/debug/getCodeMarker.d.ts +2 -0
- package/dist/cli/src/utils/debug/getSourceCodeInfo.d.ts +2 -0
- package/dist/cli/src/utils/docString/generateDocString.d.ts +2 -0
- package/dist/cli/src/utils/getAssertionError.d.ts +3 -0
- package/dist/cli/src/utils/index.d.ts +14 -0
- package/dist/cli/src/utils/maybePromise.d.ts +54 -0
- package/dist/cli/src/utils/symbols.d.ts +3 -0
- package/dist/common/createFormatter.d.ts +6 -0
- package/dist/common/utils.d.ts +2 -0
- package/dist/debug.esm.js +2 -0
- package/dist/debug.esm.js.map +1 -0
- package/dist/debug.js +2 -0
- package/dist/debug.js.map +1 -0
- package/dist/dvala.iife.js +2 -0
- package/dist/dvala.iife.js.map +1 -0
- package/dist/full.esm.js +2 -0
- package/dist/full.esm.js.map +1 -0
- package/dist/full.js +2 -0
- package/dist/full.js.map +1 -0
- package/dist/index.esm.js +2 -0
- package/dist/index.esm.js.map +1 -0
- package/dist/index.js +2 -2
- package/dist/index.js.map +1 -1
- package/dist/modules/assertion.esm.js +2 -0
- package/dist/modules/assertion.esm.js.map +1 -0
- package/dist/modules/assertion.js +2 -0
- package/dist/modules/assertion.js.map +1 -0
- package/dist/modules/bitwise.esm.js +2 -0
- package/dist/modules/bitwise.esm.js.map +1 -0
- package/dist/modules/bitwise.js +2 -0
- package/dist/modules/bitwise.js.map +1 -0
- package/dist/modules/cli/src/cli.d.ts +2 -0
- package/dist/modules/cli/src/cliDocumentation/formatCliDescription.d.ts +3 -0
- package/dist/modules/cli/src/cliDocumentation/getCliArgumentInfo.d.ts +3 -0
- package/dist/modules/cli/src/cliDocumentation/getCliDocumentation.d.ts +2 -0
- package/dist/modules/cli/src/cliDocumentation/getCliFunctionExamples.d.ts +3 -0
- package/dist/modules/cli/src/cliDocumentation/getCliFunctionSignature.d.ts +3 -0
- package/dist/modules/cli/src/cliDocumentation/getCliTitle.d.ts +3 -0
- package/dist/modules/cli/src/cliDocumentation/getCliType.d.ts +3 -0
- package/dist/modules/cli/src/cliFormatterRules.d.ts +13 -0
- package/dist/modules/cli/src/colorizer.d.ts +939 -0
- package/dist/modules/cli/src/createReadlineInterface.d.ts +5 -0
- package/dist/modules/cli/src/js-interop/Cli/Fs/index.d.ts +2 -0
- package/dist/modules/cli/src/js-interop/Cli/Proc/index.d.ts +3 -0
- package/dist/modules/cli/src/js-interop/Cli/index.d.ts +2 -0
- package/dist/modules/collection.esm.js +2 -0
- package/dist/modules/collection.esm.js.map +1 -0
- package/dist/modules/collection.js +2 -0
- package/dist/modules/collection.js.map +1 -0
- package/dist/modules/common/createFormatter.d.ts +6 -0
- package/dist/modules/common/utils.d.ts +2 -0
- package/dist/modules/convert.esm.js +2 -0
- package/dist/modules/convert.esm.js.map +1 -0
- package/dist/modules/convert.js +2 -0
- package/dist/modules/convert.js.map +1 -0
- package/dist/modules/functional.esm.js +2 -0
- package/dist/modules/functional.esm.js.map +1 -0
- package/dist/modules/functional.js +2 -0
- package/dist/modules/functional.js.map +1 -0
- package/dist/modules/grid.esm.js +2 -0
- package/dist/modules/grid.esm.js.map +1 -0
- package/dist/modules/grid.js +2 -0
- package/dist/modules/grid.js.map +1 -0
- package/dist/modules/linear-algebra.esm.js +2 -0
- package/dist/modules/linear-algebra.esm.js.map +1 -0
- package/dist/modules/linear-algebra.js +2 -0
- package/dist/modules/linear-algebra.js.map +1 -0
- package/dist/modules/math.esm.js +2 -0
- package/dist/modules/math.esm.js.map +1 -0
- package/dist/modules/math.js +2 -0
- package/dist/modules/math.js.map +1 -0
- package/dist/modules/matrix.esm.js +2 -0
- package/dist/modules/matrix.esm.js.map +1 -0
- package/dist/modules/matrix.js +2 -0
- package/dist/modules/matrix.js.map +1 -0
- package/dist/modules/number-theory.esm.js +2 -0
- package/dist/modules/number-theory.esm.js.map +1 -0
- package/dist/modules/number-theory.js +2 -0
- package/dist/modules/number-theory.js.map +1 -0
- package/dist/modules/random.esm.js +2 -0
- package/dist/modules/random.esm.js.map +1 -0
- package/dist/modules/random.js +2 -0
- package/dist/modules/random.js.map +1 -0
- package/dist/modules/reference/api.d.ts +75 -0
- package/dist/modules/reference/datatype.d.ts +3 -0
- package/dist/modules/reference/effect.d.ts +3 -0
- package/dist/modules/reference/index.d.ts +191 -0
- package/dist/modules/reference/shorthand.d.ts +3 -0
- package/dist/modules/sequence.esm.js +2 -0
- package/dist/modules/sequence.esm.js.map +1 -0
- package/dist/modules/sequence.js +2 -0
- package/dist/modules/sequence.js.map +1 -0
- package/dist/modules/src/AutoCompleter/AutoCompleter.d.ts +25 -0
- package/dist/modules/src/Dvala/Cache.d.ts +16 -0
- package/dist/modules/src/Dvala/Dvala.d.ts +68 -0
- package/dist/modules/src/allModules.d.ts +2 -0
- package/dist/modules/src/builtin/bindingNode.d.ts +11 -0
- package/dist/modules/src/builtin/core/array.d.ts +2 -0
- package/dist/modules/src/builtin/core/assertion.d.ts +2 -0
- package/dist/modules/src/builtin/core/bitwise.d.ts +2 -0
- package/dist/modules/src/builtin/core/collection.d.ts +2 -0
- package/dist/modules/src/builtin/core/functional.d.ts +2 -0
- package/dist/modules/src/builtin/core/math.d.ts +2 -0
- package/dist/modules/src/builtin/core/meta.d.ts +3 -0
- package/dist/modules/src/builtin/core/misc.d.ts +2 -0
- package/dist/modules/src/builtin/core/object.d.ts +2 -0
- package/dist/modules/src/builtin/core/predicates.d.ts +2 -0
- package/dist/modules/src/builtin/core/regexp.d.ts +2 -0
- package/dist/modules/src/builtin/core/sequence.d.ts +2 -0
- package/dist/modules/src/builtin/core/string.d.ts +2 -0
- package/dist/modules/src/builtin/core/vector.d.ts +2 -0
- package/dist/modules/src/builtin/index.d.ts +13 -0
- package/dist/modules/src/builtin/interface.d.ts +113 -0
- package/dist/modules/src/builtin/modules/assertion/docs.d.ts +2 -0
- package/dist/modules/src/builtin/modules/assertion/index.d.ts +2 -0
- package/dist/modules/src/builtin/modules/bitwise/index.d.ts +2 -0
- package/dist/modules/src/builtin/modules/collection/index.d.ts +2 -0
- package/dist/modules/src/builtin/modules/convert/index.d.ts +2 -0
- package/dist/modules/src/builtin/modules/functional/index.d.ts +2 -0
- package/dist/modules/src/builtin/modules/grid/docs.d.ts +2 -0
- package/dist/modules/src/builtin/modules/grid/fromArray.d.ts +8 -0
- package/dist/modules/src/builtin/modules/grid/index.d.ts +2 -0
- package/dist/modules/src/builtin/modules/grid/transpose.d.ts +2 -0
- package/dist/modules/src/builtin/modules/interface.d.ts +11 -0
- package/dist/modules/src/builtin/modules/linear-algebra/docs.d.ts +2 -0
- package/dist/modules/src/builtin/modules/linear-algebra/helpers/calcFractionalRanks.d.ts +1 -0
- package/dist/modules/src/builtin/modules/linear-algebra/helpers/collinear.d.ts +2 -0
- package/dist/modules/src/builtin/modules/linear-algebra/helpers/corrleation.d.ts +8 -0
- package/dist/modules/src/builtin/modules/linear-algebra/helpers/covariance.d.ts +4 -0
- package/dist/modules/src/builtin/modules/linear-algebra/helpers/dot.d.ts +1 -0
- package/dist/modules/src/builtin/modules/linear-algebra/helpers/gaussJordanElimination.d.ts +7 -0
- package/dist/modules/src/builtin/modules/linear-algebra/helpers/getUnit.d.ts +2 -0
- package/dist/modules/src/builtin/modules/linear-algebra/helpers/isZeroVector.d.ts +1 -0
- package/dist/modules/src/builtin/modules/linear-algebra/helpers/kendallTau.d.ts +10 -0
- package/dist/modules/src/builtin/modules/linear-algebra/helpers/length.d.ts +1 -0
- package/dist/modules/src/builtin/modules/linear-algebra/helpers/pearsonCorr.d.ts +1 -0
- package/dist/modules/src/builtin/modules/linear-algebra/helpers/scale.d.ts +1 -0
- package/dist/modules/src/builtin/modules/linear-algebra/helpers/solve.d.ts +8 -0
- package/dist/modules/src/builtin/modules/linear-algebra/helpers/subtract.d.ts +1 -0
- package/dist/modules/src/builtin/modules/linear-algebra/index.d.ts +4 -0
- package/dist/modules/src/builtin/modules/math/index.d.ts +2 -0
- package/dist/modules/src/builtin/modules/matrix/docs.d.ts +2 -0
- package/dist/modules/src/builtin/modules/matrix/helpers/adjugate.d.ts +1 -0
- package/dist/modules/src/builtin/modules/matrix/helpers/band.d.ts +9 -0
- package/dist/modules/src/builtin/modules/matrix/helpers/cofactor.d.ts +1 -0
- package/dist/modules/src/builtin/modules/matrix/helpers/determinant.d.ts +6 -0
- package/dist/modules/src/builtin/modules/matrix/helpers/diagonal.d.ts +1 -0
- package/dist/modules/src/builtin/modules/matrix/helpers/inverse.d.ts +6 -0
- package/dist/modules/src/builtin/modules/matrix/helpers/isBanded.d.ts +11 -0
- package/dist/modules/src/builtin/modules/matrix/helpers/isDiagonal.d.ts +10 -0
- package/dist/modules/src/builtin/modules/matrix/helpers/isIdentity.d.ts +1 -0
- package/dist/modules/src/builtin/modules/matrix/helpers/isOrthogonal.d.ts +1 -0
- package/dist/modules/src/builtin/modules/matrix/helpers/isSquare.d.ts +1 -0
- package/dist/modules/src/builtin/modules/matrix/helpers/isSymetric.d.ts +8 -0
- package/dist/modules/src/builtin/modules/matrix/helpers/isTriangular.d.ts +13 -0
- package/dist/modules/src/builtin/modules/matrix/helpers/matrixMultiply.d.ts +7 -0
- package/dist/modules/src/builtin/modules/matrix/helpers/minor.d.ts +1 -0
- package/dist/modules/src/builtin/modules/matrix/helpers/norm1.d.ts +1 -0
- package/dist/modules/src/builtin/modules/matrix/helpers/trace.d.ts +8 -0
- package/dist/modules/src/builtin/modules/matrix/index.d.ts +4 -0
- package/dist/modules/src/builtin/modules/number-theory/binomialCefficient.d.ts +1 -0
- package/dist/modules/src/builtin/modules/number-theory/combinations.d.ts +2 -0
- package/dist/modules/src/builtin/modules/number-theory/derangements.d.ts +2 -0
- package/dist/modules/src/builtin/modules/number-theory/divisors.d.ts +4 -0
- package/dist/modules/src/builtin/modules/number-theory/docs.d.ts +2 -0
- package/dist/modules/src/builtin/modules/number-theory/factorial.d.ts +3 -0
- package/dist/modules/src/builtin/modules/number-theory/index.d.ts +4 -0
- package/dist/modules/src/builtin/modules/number-theory/partitions.d.ts +2 -0
- package/dist/modules/src/builtin/modules/number-theory/permutations.d.ts +2 -0
- package/dist/modules/src/builtin/modules/number-theory/powerSet.d.ts +2 -0
- package/dist/modules/src/builtin/modules/number-theory/primeFactors.d.ts +11 -0
- package/dist/modules/src/builtin/modules/number-theory/sequences/abundant.d.ts +2 -0
- package/dist/modules/src/builtin/modules/number-theory/sequences/arithmetic.d.ts +2 -0
- package/dist/modules/src/builtin/modules/number-theory/sequences/bell.d.ts +1 -0
- package/dist/modules/src/builtin/modules/number-theory/sequences/bernoulli.d.ts +2 -0
- package/dist/modules/src/builtin/modules/number-theory/sequences/catalan.d.ts +1 -0
- package/dist/modules/src/builtin/modules/number-theory/sequences/collatz.d.ts +2 -0
- package/dist/modules/src/builtin/modules/number-theory/sequences/composite.d.ts +3 -0
- package/dist/modules/src/builtin/modules/number-theory/sequences/deficient.d.ts +2 -0
- package/dist/modules/src/builtin/modules/number-theory/sequences/factorial.d.ts +1 -0
- package/dist/modules/src/builtin/modules/number-theory/sequences/fibonacci.d.ts +1 -0
- package/dist/modules/src/builtin/modules/number-theory/sequences/geometric.d.ts +2 -0
- package/dist/modules/src/builtin/modules/number-theory/sequences/golomb.d.ts +2 -0
- package/dist/modules/src/builtin/modules/number-theory/sequences/happy.d.ts +2 -0
- package/dist/modules/src/builtin/modules/number-theory/sequences/index.d.ts +27 -0
- package/dist/modules/src/builtin/modules/number-theory/sequences/juggler.d.ts +2 -0
- package/dist/modules/src/builtin/modules/number-theory/sequences/lookAndSay.d.ts +2 -0
- package/dist/modules/src/builtin/modules/number-theory/sequences/lucas.d.ts +1 -0
- package/dist/modules/src/builtin/modules/number-theory/sequences/lucky.d.ts +2 -0
- package/dist/modules/src/builtin/modules/number-theory/sequences/mersenne.d.ts +1 -0
- package/dist/modules/src/builtin/modules/number-theory/sequences/padovan.d.ts +2 -0
- package/dist/modules/src/builtin/modules/number-theory/sequences/partition.d.ts +1 -0
- package/dist/modules/src/builtin/modules/number-theory/sequences/pell.d.ts +1 -0
- package/dist/modules/src/builtin/modules/number-theory/sequences/perfect.d.ts +1 -0
- package/dist/modules/src/builtin/modules/number-theory/sequences/perfectCube.d.ts +2 -0
- package/dist/modules/src/builtin/modules/number-theory/sequences/perfectPower.d.ts +10 -0
- package/dist/modules/src/builtin/modules/number-theory/sequences/perfectSquare.d.ts +2 -0
- package/dist/modules/src/builtin/modules/number-theory/sequences/poligonal.d.ts +2 -0
- package/dist/modules/src/builtin/modules/number-theory/sequences/prime.d.ts +3 -0
- package/dist/modules/src/builtin/modules/number-theory/sequences/recaman.d.ts +9 -0
- package/dist/modules/src/builtin/modules/number-theory/sequences/sylvester.d.ts +1 -0
- package/dist/modules/src/builtin/modules/number-theory/sequences/thueMorse.d.ts +2 -0
- package/dist/modules/src/builtin/modules/number-theory/sequences/tribonacci.d.ts +1 -0
- package/dist/modules/src/builtin/modules/random/docs.d.ts +2 -0
- package/dist/modules/src/builtin/modules/random/index.d.ts +2 -0
- package/dist/modules/src/builtin/modules/sequence/index.d.ts +2 -0
- package/dist/modules/src/builtin/modules/string/index.d.ts +2 -0
- package/dist/modules/src/builtin/modules/vector/bincount.d.ts +9 -0
- package/dist/modules/src/builtin/modules/vector/calcMad.d.ts +1 -0
- package/dist/modules/src/builtin/modules/vector/calcMean.d.ts +1 -0
- package/dist/modules/src/builtin/modules/vector/calcMedad.d.ts +1 -0
- package/dist/modules/src/builtin/modules/vector/calcMedian.d.ts +1 -0
- package/dist/modules/src/builtin/modules/vector/calcStdDev.d.ts +2 -0
- package/dist/modules/src/builtin/modules/vector/calcVariance.d.ts +2 -0
- package/dist/modules/src/builtin/modules/vector/docs.d.ts +2 -0
- package/dist/modules/src/builtin/modules/vector/entropy.d.ts +8 -0
- package/dist/modules/src/builtin/modules/vector/histogram.d.ts +9 -0
- package/dist/modules/src/builtin/modules/vector/index.d.ts +2 -0
- package/dist/modules/src/builtin/modules/vector/mode.d.ts +6 -0
- package/dist/modules/src/builtin/modules/vector/outliers.d.ts +7 -0
- package/dist/modules/src/builtin/modules/vector/percentile.d.ts +7 -0
- package/dist/modules/src/builtin/modules/vector/quartiles.d.ts +1 -0
- package/dist/modules/src/builtin/modules/vector/reductionFunctions/entropy.d.ts +2 -0
- package/dist/modules/src/builtin/modules/vector/reductionFunctions/giniCoefficient.d.ts +2 -0
- package/dist/modules/src/builtin/modules/vector/reductionFunctions/index.d.ts +13 -0
- package/dist/modules/src/builtin/modules/vector/reductionFunctions/iqr.d.ts +2 -0
- package/dist/modules/src/builtin/modules/vector/reductionFunctions/kurtosis.d.ts +5 -0
- package/dist/modules/src/builtin/modules/vector/reductionFunctions/mad.d.ts +2 -0
- package/dist/modules/src/builtin/modules/vector/reductionFunctions/mean.d.ts +4 -0
- package/dist/modules/src/builtin/modules/vector/reductionFunctions/medad.d.ts +2 -0
- package/dist/modules/src/builtin/modules/vector/reductionFunctions/median.d.ts +2 -0
- package/dist/modules/src/builtin/modules/vector/reductionFunctions/prod.d.ts +2 -0
- package/dist/modules/src/builtin/modules/vector/reductionFunctions/rms.d.ts +2 -0
- package/dist/modules/src/builtin/modules/vector/reductionFunctions/skewness.d.ts +3 -0
- package/dist/modules/src/builtin/modules/vector/reductionFunctions/span.d.ts +2 -0
- package/dist/modules/src/builtin/modules/vector/reductionFunctions/standardDeviation.d.ts +3 -0
- package/dist/modules/src/builtin/modules/vector/reductionFunctions/sum.d.ts +2 -0
- package/dist/modules/src/builtin/modules/vector/reductionFunctions/variance.d.ts +3 -0
- package/dist/modules/src/builtin/normalExpressions/index.d.ts +8 -0
- package/dist/modules/src/builtin/specialExpressionTypes.d.ts +26 -0
- package/dist/modules/src/builtin/specialExpressions/and.d.ts +6 -0
- package/dist/modules/src/builtin/specialExpressions/array.d.ts +6 -0
- package/dist/modules/src/builtin/specialExpressions/block.d.ts +6 -0
- package/dist/modules/src/builtin/specialExpressions/cond.d.ts +6 -0
- package/dist/modules/src/builtin/specialExpressions/defined.d.ts +5 -0
- package/dist/modules/src/builtin/specialExpressions/effect.d.ts +5 -0
- package/dist/modules/src/builtin/specialExpressions/functions.d.ts +6 -0
- package/dist/modules/src/builtin/specialExpressions/if.d.ts +6 -0
- package/dist/modules/src/builtin/specialExpressions/import.d.ts +6 -0
- package/dist/modules/src/builtin/specialExpressions/let.d.ts +6 -0
- package/dist/modules/src/builtin/specialExpressions/loop.d.ts +6 -0
- package/dist/modules/src/builtin/specialExpressions/loops.d.ts +9 -0
- package/dist/modules/src/builtin/specialExpressions/match.d.ts +7 -0
- package/dist/modules/src/builtin/specialExpressions/object.d.ts +6 -0
- package/dist/modules/src/builtin/specialExpressions/or.d.ts +6 -0
- package/dist/modules/src/builtin/specialExpressions/parallel.d.ts +6 -0
- package/dist/modules/src/builtin/specialExpressions/perform.d.ts +6 -0
- package/dist/modules/src/builtin/specialExpressions/qq.d.ts +6 -0
- package/dist/modules/src/builtin/specialExpressions/race.d.ts +6 -0
- package/dist/modules/src/builtin/specialExpressions/recur.d.ts +5 -0
- package/dist/modules/src/builtin/specialExpressions/throw.d.ts +5 -0
- package/dist/modules/src/builtin/specialExpressions/try.d.ts +7 -0
- package/dist/modules/src/builtin/specialExpressions/unless.d.ts +6 -0
- package/dist/modules/src/builtin/utils.d.ts +6 -0
- package/dist/modules/src/bundler/index.d.ts +9 -0
- package/dist/modules/src/bundler/interface.d.ts +15 -0
- package/dist/modules/src/bundler.d.ts +3 -0
- package/dist/modules/src/constants/constants.d.ts +19 -0
- package/dist/modules/src/debug.d.ts +115 -0
- package/dist/modules/src/effects.d.ts +106 -0
- package/dist/modules/src/errors.d.ts +24 -0
- package/dist/modules/src/evaluator/ContextStack.d.ts +65 -0
- package/dist/modules/src/evaluator/effectRef.d.ts +27 -0
- package/dist/modules/src/evaluator/effectTypes.d.ts +79 -0
- package/dist/modules/src/evaluator/frames.d.ts +525 -0
- package/dist/modules/src/evaluator/interface.d.ts +14 -0
- package/dist/modules/src/evaluator/serialization.d.ts +45 -0
- package/dist/modules/src/evaluator/standardEffects.d.ts +35 -0
- package/dist/modules/src/evaluator/step.d.ts +159 -0
- package/dist/modules/src/evaluator/suspension.d.ts +53 -0
- package/dist/modules/src/evaluator/trampoline.d.ts +119 -0
- package/dist/modules/src/full.d.ts +17 -0
- package/dist/modules/src/getUndefinedSymbols/index.d.ts +7 -0
- package/dist/modules/src/index.d.ts +18 -0
- package/dist/modules/src/initReferenceData.d.ts +1 -0
- package/dist/modules/src/interface.d.ts +7 -0
- package/dist/modules/src/modules/assertion.d.ts +2 -0
- package/dist/modules/src/modules/bitwise.d.ts +2 -0
- package/dist/modules/src/modules/collection.d.ts +2 -0
- package/dist/modules/src/modules/convert.d.ts +2 -0
- package/dist/modules/src/modules/functional.d.ts +2 -0
- package/dist/modules/src/modules/grid.d.ts +2 -0
- package/dist/modules/src/modules/linear-algebra.d.ts +2 -0
- package/dist/modules/src/modules/math.d.ts +2 -0
- package/dist/modules/src/modules/matrix.d.ts +2 -0
- package/dist/modules/src/modules/number-theory.d.ts +2 -0
- package/dist/modules/src/modules/random.d.ts +2 -0
- package/dist/modules/src/modules/sequence.d.ts +2 -0
- package/dist/modules/src/modules/string.d.ts +2 -0
- package/dist/modules/src/modules/vector.d.ts +2 -0
- package/dist/modules/src/parser/ParserContext.d.ts +20 -0
- package/dist/modules/src/parser/getPrecedence.d.ts +3 -0
- package/dist/modules/src/parser/helpers.d.ts +19 -0
- package/dist/modules/src/parser/index.d.ts +5 -0
- package/dist/modules/src/parser/subParsers/parseArray.d.ts +3 -0
- package/dist/modules/src/parser/subParsers/parseBindingTarget.d.ts +8 -0
- package/dist/modules/src/parser/subParsers/parseCond.d.ts +4 -0
- package/dist/modules/src/parser/subParsers/parseDo.d.ts +3 -0
- package/dist/modules/src/parser/subParsers/parseExpression.d.ts +5 -0
- package/dist/modules/src/parser/subParsers/parseForOrDoseq.d.ts +4 -0
- package/dist/modules/src/parser/subParsers/parseFunction.d.ts +4 -0
- package/dist/modules/src/parser/subParsers/parseFunctionCall.d.ts +3 -0
- package/dist/modules/src/parser/subParsers/parseIfOrUnless.d.ts +5 -0
- package/dist/modules/src/parser/subParsers/parseImplicitBlock.d.ts +5 -0
- package/dist/modules/src/parser/subParsers/parseLet.d.ts +4 -0
- package/dist/modules/src/parser/subParsers/parseLoop.d.ts +4 -0
- package/dist/modules/src/parser/subParsers/parseMatch.d.ts +4 -0
- package/dist/modules/src/parser/subParsers/parseNumber.d.ts +3 -0
- package/dist/modules/src/parser/subParsers/parseObject.d.ts +3 -0
- package/dist/modules/src/parser/subParsers/parseOperand.d.ts +3 -0
- package/dist/modules/src/parser/subParsers/parseRegexpShorthand.d.ts +3 -0
- package/dist/modules/src/parser/subParsers/parseReservedSymbol.d.ts +3 -0
- package/dist/modules/src/parser/subParsers/parseString.d.ts +4 -0
- package/dist/modules/src/parser/subParsers/parseSymbol.d.ts +3 -0
- package/dist/modules/src/parser/subParsers/parseTry.d.ts +4 -0
- package/dist/modules/src/parser/types.d.ts +129 -0
- package/dist/modules/src/symbolPatterns.d.ts +2 -0
- package/dist/modules/src/testFramework/index.d.ts +15 -0
- package/dist/modules/src/tokenizer/minifyTokenStream.d.ts +4 -0
- package/dist/modules/src/tokenizer/operators.d.ts +12 -0
- package/dist/modules/src/tokenizer/reservedNames.d.ts +66 -0
- package/dist/modules/src/tokenizer/token.d.ts +84 -0
- package/dist/modules/src/tokenizer/tokenize.d.ts +8 -0
- package/dist/modules/src/tokenizer/tokenizers.d.ts +14 -0
- package/dist/modules/src/transformer/index.d.ts +2 -0
- package/dist/modules/src/typeGuards/annotatedArrays.d.ts +16 -0
- package/dist/modules/src/typeGuards/array.d.ts +9 -0
- package/dist/modules/src/typeGuards/astNode.d.ts +19 -0
- package/dist/modules/src/typeGuards/dvala.d.ts +26 -0
- package/dist/modules/src/typeGuards/dvalaFunction.d.ts +12 -0
- package/dist/modules/src/typeGuards/index.d.ts +7 -0
- package/dist/modules/src/typeGuards/number.d.ts +66 -0
- package/dist/modules/src/typeGuards/string.d.ts +15 -0
- package/dist/modules/src/untokenizer/index.d.ts +2 -0
- package/dist/modules/src/utils/arity.d.ts +10 -0
- package/dist/modules/src/utils/debug/debugTools.d.ts +1 -0
- package/dist/modules/src/utils/debug/getCodeMarker.d.ts +2 -0
- package/dist/modules/src/utils/debug/getSourceCodeInfo.d.ts +2 -0
- package/dist/modules/src/utils/docString/generateDocString.d.ts +2 -0
- package/dist/modules/src/utils/getAssertionError.d.ts +3 -0
- package/dist/modules/src/utils/index.d.ts +14 -0
- package/dist/modules/src/utils/maybePromise.d.ts +54 -0
- package/dist/modules/src/utils/symbols.d.ts +3 -0
- package/dist/modules/string.esm.js +2 -0
- package/dist/modules/string.esm.js.map +1 -0
- package/dist/modules/string.js +2 -0
- package/dist/modules/string.js.map +1 -0
- package/dist/modules/vector.esm.js +2 -0
- package/dist/modules/vector.esm.js.map +1 -0
- package/dist/modules/vector.js +2 -0
- package/dist/modules/vector.js.map +1 -0
- package/dist/reference/api.d.ts +75 -0
- package/dist/reference/datatype.d.ts +3 -0
- package/dist/reference/effect.d.ts +3 -0
- package/dist/reference/index.d.ts +191 -0
- package/dist/reference/shorthand.d.ts +3 -0
- package/dist/src/AutoCompleter/AutoCompleter.d.ts +25 -0
- package/dist/src/Dvala/Cache.d.ts +16 -0
- package/dist/src/Dvala/Dvala.d.ts +68 -0
- package/dist/src/allModules.d.ts +2 -0
- package/dist/src/builtin/bindingNode.d.ts +11 -0
- package/dist/src/builtin/core/array.d.ts +2 -0
- package/dist/src/builtin/core/assertion.d.ts +2 -0
- package/dist/src/builtin/core/bitwise.d.ts +2 -0
- package/dist/src/builtin/core/collection.d.ts +2 -0
- package/dist/src/builtin/core/functional.d.ts +2 -0
- package/dist/src/builtin/core/math.d.ts +2 -0
- package/dist/src/builtin/core/meta.d.ts +3 -0
- package/dist/src/builtin/core/misc.d.ts +2 -0
- package/dist/src/builtin/core/object.d.ts +2 -0
- package/dist/src/builtin/core/predicates.d.ts +2 -0
- package/dist/src/builtin/core/regexp.d.ts +2 -0
- package/dist/src/builtin/core/sequence.d.ts +2 -0
- package/dist/src/builtin/core/string.d.ts +2 -0
- package/dist/src/builtin/core/vector.d.ts +2 -0
- package/dist/src/builtin/index.d.ts +13 -0
- package/dist/src/builtin/interface.d.ts +113 -0
- package/dist/src/builtin/modules/assertion/docs.d.ts +2 -0
- package/dist/src/builtin/modules/assertion/index.d.ts +2 -0
- package/dist/src/builtin/modules/bitwise/index.d.ts +2 -0
- package/dist/src/builtin/modules/collection/index.d.ts +2 -0
- package/dist/src/builtin/modules/convert/index.d.ts +2 -0
- package/dist/src/builtin/modules/functional/index.d.ts +2 -0
- package/dist/src/builtin/modules/grid/docs.d.ts +2 -0
- package/dist/src/builtin/modules/grid/fromArray.d.ts +8 -0
- package/dist/src/builtin/modules/grid/index.d.ts +2 -0
- package/dist/src/builtin/modules/grid/transpose.d.ts +2 -0
- package/dist/src/builtin/modules/interface.d.ts +11 -0
- package/dist/src/builtin/modules/linear-algebra/docs.d.ts +2 -0
- package/dist/src/builtin/modules/linear-algebra/helpers/calcFractionalRanks.d.ts +1 -0
- package/dist/src/builtin/modules/linear-algebra/helpers/collinear.d.ts +2 -0
- package/dist/src/builtin/modules/linear-algebra/helpers/corrleation.d.ts +8 -0
- package/dist/src/builtin/modules/linear-algebra/helpers/covariance.d.ts +4 -0
- package/dist/src/builtin/modules/linear-algebra/helpers/dot.d.ts +1 -0
- package/dist/src/builtin/modules/linear-algebra/helpers/gaussJordanElimination.d.ts +7 -0
- package/dist/src/builtin/modules/linear-algebra/helpers/getUnit.d.ts +2 -0
- package/dist/src/builtin/modules/linear-algebra/helpers/isZeroVector.d.ts +1 -0
- package/dist/src/builtin/modules/linear-algebra/helpers/kendallTau.d.ts +10 -0
- package/dist/src/builtin/modules/linear-algebra/helpers/length.d.ts +1 -0
- package/dist/src/builtin/modules/linear-algebra/helpers/pearsonCorr.d.ts +1 -0
- package/dist/src/builtin/modules/linear-algebra/helpers/scale.d.ts +1 -0
- package/dist/src/builtin/modules/linear-algebra/helpers/solve.d.ts +8 -0
- package/dist/src/builtin/modules/linear-algebra/helpers/subtract.d.ts +1 -0
- package/dist/src/builtin/modules/linear-algebra/index.d.ts +4 -0
- package/dist/src/builtin/modules/math/index.d.ts +2 -0
- package/dist/src/builtin/modules/matrix/docs.d.ts +2 -0
- package/dist/src/builtin/modules/matrix/helpers/adjugate.d.ts +1 -0
- package/dist/src/builtin/modules/matrix/helpers/band.d.ts +9 -0
- package/dist/src/builtin/modules/matrix/helpers/cofactor.d.ts +1 -0
- package/dist/src/builtin/modules/matrix/helpers/determinant.d.ts +6 -0
- package/dist/src/builtin/modules/matrix/helpers/diagonal.d.ts +1 -0
- package/dist/src/builtin/modules/matrix/helpers/inverse.d.ts +6 -0
- package/dist/src/builtin/modules/matrix/helpers/isBanded.d.ts +11 -0
- package/dist/src/builtin/modules/matrix/helpers/isDiagonal.d.ts +10 -0
- package/dist/src/builtin/modules/matrix/helpers/isIdentity.d.ts +1 -0
- package/dist/src/builtin/modules/matrix/helpers/isOrthogonal.d.ts +1 -0
- package/dist/src/builtin/modules/matrix/helpers/isSquare.d.ts +1 -0
- package/dist/src/builtin/modules/matrix/helpers/isSymetric.d.ts +8 -0
- package/dist/src/builtin/modules/matrix/helpers/isTriangular.d.ts +13 -0
- package/dist/src/builtin/modules/matrix/helpers/matrixMultiply.d.ts +7 -0
- package/dist/src/builtin/modules/matrix/helpers/minor.d.ts +1 -0
- package/dist/src/builtin/modules/matrix/helpers/norm1.d.ts +1 -0
- package/dist/src/builtin/modules/matrix/helpers/trace.d.ts +8 -0
- package/dist/src/builtin/modules/matrix/index.d.ts +4 -0
- package/dist/src/builtin/modules/number-theory/binomialCefficient.d.ts +1 -0
- package/dist/src/builtin/modules/number-theory/combinations.d.ts +2 -0
- package/dist/src/builtin/modules/number-theory/derangements.d.ts +2 -0
- package/dist/src/builtin/modules/number-theory/divisors.d.ts +4 -0
- package/dist/src/builtin/modules/number-theory/docs.d.ts +2 -0
- package/dist/src/builtin/modules/number-theory/factorial.d.ts +3 -0
- package/dist/src/builtin/modules/number-theory/index.d.ts +4 -0
- package/dist/src/builtin/modules/number-theory/partitions.d.ts +2 -0
- package/dist/src/builtin/modules/number-theory/permutations.d.ts +2 -0
- package/dist/src/builtin/modules/number-theory/powerSet.d.ts +2 -0
- package/dist/src/builtin/modules/number-theory/primeFactors.d.ts +11 -0
- package/dist/src/builtin/modules/number-theory/sequences/abundant.d.ts +2 -0
- package/dist/src/builtin/modules/number-theory/sequences/arithmetic.d.ts +2 -0
- package/dist/src/builtin/modules/number-theory/sequences/bell.d.ts +1 -0
- package/dist/src/builtin/modules/number-theory/sequences/bernoulli.d.ts +2 -0
- package/dist/src/builtin/modules/number-theory/sequences/catalan.d.ts +1 -0
- package/dist/src/builtin/modules/number-theory/sequences/collatz.d.ts +2 -0
- package/dist/src/builtin/modules/number-theory/sequences/composite.d.ts +3 -0
- package/dist/src/builtin/modules/number-theory/sequences/deficient.d.ts +2 -0
- package/dist/src/builtin/modules/number-theory/sequences/factorial.d.ts +1 -0
- package/dist/src/builtin/modules/number-theory/sequences/fibonacci.d.ts +1 -0
- package/dist/src/builtin/modules/number-theory/sequences/geometric.d.ts +2 -0
- package/dist/src/builtin/modules/number-theory/sequences/golomb.d.ts +2 -0
- package/dist/src/builtin/modules/number-theory/sequences/happy.d.ts +2 -0
- package/dist/src/builtin/modules/number-theory/sequences/index.d.ts +27 -0
- package/dist/src/builtin/modules/number-theory/sequences/juggler.d.ts +2 -0
- package/dist/src/builtin/modules/number-theory/sequences/lookAndSay.d.ts +2 -0
- package/dist/src/builtin/modules/number-theory/sequences/lucas.d.ts +1 -0
- package/dist/src/builtin/modules/number-theory/sequences/lucky.d.ts +2 -0
- package/dist/src/builtin/modules/number-theory/sequences/mersenne.d.ts +1 -0
- package/dist/src/builtin/modules/number-theory/sequences/padovan.d.ts +2 -0
- package/dist/src/builtin/modules/number-theory/sequences/partition.d.ts +1 -0
- package/dist/src/builtin/modules/number-theory/sequences/pell.d.ts +1 -0
- package/dist/src/builtin/modules/number-theory/sequences/perfect.d.ts +1 -0
- package/dist/src/builtin/modules/number-theory/sequences/perfectCube.d.ts +2 -0
- package/dist/src/builtin/modules/number-theory/sequences/perfectPower.d.ts +10 -0
- package/dist/src/builtin/modules/number-theory/sequences/perfectSquare.d.ts +2 -0
- package/dist/src/builtin/modules/number-theory/sequences/poligonal.d.ts +2 -0
- package/dist/src/builtin/modules/number-theory/sequences/prime.d.ts +3 -0
- package/dist/src/builtin/modules/number-theory/sequences/recaman.d.ts +9 -0
- package/dist/src/builtin/modules/number-theory/sequences/sylvester.d.ts +1 -0
- package/dist/src/builtin/modules/number-theory/sequences/thueMorse.d.ts +2 -0
- package/dist/src/builtin/modules/number-theory/sequences/tribonacci.d.ts +1 -0
- package/dist/src/builtin/modules/random/docs.d.ts +2 -0
- package/dist/src/builtin/modules/random/index.d.ts +2 -0
- package/dist/src/builtin/modules/sequence/index.d.ts +2 -0
- package/dist/src/builtin/modules/string/index.d.ts +2 -0
- package/dist/src/builtin/modules/vector/bincount.d.ts +9 -0
- package/dist/src/builtin/modules/vector/calcMad.d.ts +1 -0
- package/dist/src/builtin/modules/vector/calcMean.d.ts +1 -0
- package/dist/src/builtin/modules/vector/calcMedad.d.ts +1 -0
- package/dist/src/builtin/modules/vector/calcMedian.d.ts +1 -0
- package/dist/src/builtin/modules/vector/calcStdDev.d.ts +2 -0
- package/dist/src/builtin/modules/vector/calcVariance.d.ts +2 -0
- package/dist/src/builtin/modules/vector/docs.d.ts +2 -0
- package/dist/src/builtin/modules/vector/entropy.d.ts +8 -0
- package/dist/src/builtin/modules/vector/histogram.d.ts +9 -0
- package/dist/src/builtin/modules/vector/index.d.ts +2 -0
- package/dist/src/builtin/modules/vector/mode.d.ts +6 -0
- package/dist/src/builtin/modules/vector/outliers.d.ts +7 -0
- package/dist/src/builtin/modules/vector/percentile.d.ts +7 -0
- package/dist/src/builtin/modules/vector/quartiles.d.ts +1 -0
- package/dist/src/builtin/modules/vector/reductionFunctions/entropy.d.ts +2 -0
- package/dist/src/builtin/modules/vector/reductionFunctions/giniCoefficient.d.ts +2 -0
- package/dist/src/builtin/modules/vector/reductionFunctions/index.d.ts +13 -0
- package/dist/src/builtin/modules/vector/reductionFunctions/iqr.d.ts +2 -0
- package/dist/src/builtin/modules/vector/reductionFunctions/kurtosis.d.ts +5 -0
- package/dist/src/builtin/modules/vector/reductionFunctions/mad.d.ts +2 -0
- package/dist/src/builtin/modules/vector/reductionFunctions/mean.d.ts +4 -0
- package/dist/src/builtin/modules/vector/reductionFunctions/medad.d.ts +2 -0
- package/dist/src/builtin/modules/vector/reductionFunctions/median.d.ts +2 -0
- package/dist/src/builtin/modules/vector/reductionFunctions/prod.d.ts +2 -0
- package/dist/src/builtin/modules/vector/reductionFunctions/rms.d.ts +2 -0
- package/dist/src/builtin/modules/vector/reductionFunctions/skewness.d.ts +3 -0
- package/dist/src/builtin/modules/vector/reductionFunctions/span.d.ts +2 -0
- package/dist/src/builtin/modules/vector/reductionFunctions/standardDeviation.d.ts +3 -0
- package/dist/src/builtin/modules/vector/reductionFunctions/sum.d.ts +2 -0
- package/dist/src/builtin/modules/vector/reductionFunctions/variance.d.ts +3 -0
- package/dist/src/builtin/normalExpressions/index.d.ts +8 -0
- package/dist/src/builtin/specialExpressionTypes.d.ts +26 -0
- package/dist/src/builtin/specialExpressions/and.d.ts +6 -0
- package/dist/src/builtin/specialExpressions/array.d.ts +6 -0
- package/dist/src/builtin/specialExpressions/block.d.ts +6 -0
- package/dist/src/builtin/specialExpressions/cond.d.ts +6 -0
- package/dist/src/builtin/specialExpressions/defined.d.ts +5 -0
- package/dist/src/builtin/specialExpressions/effect.d.ts +5 -0
- package/dist/src/builtin/specialExpressions/functions.d.ts +6 -0
- package/dist/src/builtin/specialExpressions/if.d.ts +6 -0
- package/dist/src/builtin/specialExpressions/import.d.ts +6 -0
- package/dist/src/builtin/specialExpressions/let.d.ts +6 -0
- package/dist/src/builtin/specialExpressions/loop.d.ts +6 -0
- package/dist/src/builtin/specialExpressions/loops.d.ts +9 -0
- package/dist/src/builtin/specialExpressions/match.d.ts +7 -0
- package/dist/src/builtin/specialExpressions/object.d.ts +6 -0
- package/dist/src/builtin/specialExpressions/or.d.ts +6 -0
- package/dist/src/builtin/specialExpressions/parallel.d.ts +6 -0
- package/dist/src/builtin/specialExpressions/perform.d.ts +6 -0
- package/dist/src/builtin/specialExpressions/qq.d.ts +6 -0
- package/dist/src/builtin/specialExpressions/race.d.ts +6 -0
- package/dist/src/builtin/specialExpressions/recur.d.ts +5 -0
- package/dist/src/builtin/specialExpressions/throw.d.ts +5 -0
- package/dist/src/builtin/specialExpressions/try.d.ts +7 -0
- package/dist/src/builtin/specialExpressions/unless.d.ts +6 -0
- package/dist/src/builtin/utils.d.ts +6 -0
- package/dist/src/bundler/index.d.ts +9 -0
- package/dist/src/bundler/interface.d.ts +15 -0
- package/dist/src/bundler.d.ts +3 -0
- package/dist/src/constants/constants.d.ts +19 -0
- package/dist/src/debug.d.ts +115 -0
- package/dist/src/effects.d.ts +106 -0
- package/dist/src/errors.d.ts +24 -0
- package/dist/src/evaluator/ContextStack.d.ts +65 -0
- package/dist/src/evaluator/effectRef.d.ts +27 -0
- package/dist/src/evaluator/effectTypes.d.ts +79 -0
- package/dist/src/evaluator/frames.d.ts +525 -0
- package/dist/src/evaluator/interface.d.ts +14 -0
- package/dist/src/evaluator/serialization.d.ts +45 -0
- package/dist/src/evaluator/standardEffects.d.ts +35 -0
- package/dist/src/evaluator/step.d.ts +159 -0
- package/dist/src/evaluator/suspension.d.ts +53 -0
- package/dist/src/evaluator/trampoline.d.ts +119 -0
- package/dist/src/full.d.ts +17 -0
- package/dist/src/getUndefinedSymbols/index.d.ts +7 -0
- package/dist/src/index.d.ts +18 -0
- package/dist/src/initReferenceData.d.ts +1 -0
- package/dist/src/interface.d.ts +7 -0
- package/dist/src/modules/assertion.d.ts +2 -0
- package/dist/src/modules/bitwise.d.ts +2 -0
- package/dist/src/modules/collection.d.ts +2 -0
- package/dist/src/modules/convert.d.ts +2 -0
- package/dist/src/modules/functional.d.ts +2 -0
- package/dist/src/modules/grid.d.ts +2 -0
- package/dist/src/modules/linear-algebra.d.ts +2 -0
- package/dist/src/modules/math.d.ts +2 -0
- package/dist/src/modules/matrix.d.ts +2 -0
- package/dist/src/modules/number-theory.d.ts +2 -0
- package/dist/src/modules/random.d.ts +2 -0
- package/dist/src/modules/sequence.d.ts +2 -0
- package/dist/src/modules/string.d.ts +2 -0
- package/dist/src/modules/vector.d.ts +2 -0
- package/dist/src/parser/ParserContext.d.ts +20 -0
- package/dist/src/parser/getPrecedence.d.ts +3 -0
- package/dist/src/parser/helpers.d.ts +19 -0
- package/dist/src/parser/index.d.ts +5 -0
- package/dist/src/parser/subParsers/parseArray.d.ts +3 -0
- package/dist/src/parser/subParsers/parseBindingTarget.d.ts +8 -0
- package/dist/src/parser/subParsers/parseCond.d.ts +4 -0
- package/dist/src/parser/subParsers/parseDo.d.ts +3 -0
- package/dist/src/parser/subParsers/parseExpression.d.ts +5 -0
- package/dist/src/parser/subParsers/parseForOrDoseq.d.ts +4 -0
- package/dist/src/parser/subParsers/parseFunction.d.ts +4 -0
- package/dist/src/parser/subParsers/parseFunctionCall.d.ts +3 -0
- package/dist/src/parser/subParsers/parseIfOrUnless.d.ts +5 -0
- package/dist/src/parser/subParsers/parseImplicitBlock.d.ts +5 -0
- package/dist/src/parser/subParsers/parseLet.d.ts +4 -0
- package/dist/src/parser/subParsers/parseLoop.d.ts +4 -0
- package/dist/src/parser/subParsers/parseMatch.d.ts +4 -0
- package/dist/src/parser/subParsers/parseNumber.d.ts +3 -0
- package/dist/src/parser/subParsers/parseObject.d.ts +3 -0
- package/dist/src/parser/subParsers/parseOperand.d.ts +3 -0
- package/dist/src/parser/subParsers/parseRegexpShorthand.d.ts +3 -0
- package/dist/src/parser/subParsers/parseReservedSymbol.d.ts +3 -0
- package/dist/src/parser/subParsers/parseString.d.ts +4 -0
- package/dist/src/parser/subParsers/parseSymbol.d.ts +3 -0
- package/dist/src/parser/subParsers/parseTry.d.ts +4 -0
- package/dist/src/parser/types.d.ts +129 -0
- package/dist/src/symbolPatterns.d.ts +2 -0
- package/dist/src/testFramework/index.d.ts +15 -0
- package/dist/src/tokenizer/minifyTokenStream.d.ts +4 -0
- package/dist/src/tokenizer/operators.d.ts +12 -0
- package/dist/src/tokenizer/reservedNames.d.ts +66 -0
- package/dist/src/tokenizer/token.d.ts +84 -0
- package/dist/src/tokenizer/tokenize.d.ts +8 -0
- package/dist/src/tokenizer/tokenizers.d.ts +14 -0
- package/dist/src/transformer/index.d.ts +2 -0
- package/dist/src/typeGuards/annotatedArrays.d.ts +16 -0
- package/dist/src/typeGuards/array.d.ts +9 -0
- package/dist/src/typeGuards/astNode.d.ts +19 -0
- package/dist/src/typeGuards/dvala.d.ts +26 -0
- package/dist/src/typeGuards/dvalaFunction.d.ts +12 -0
- package/dist/src/typeGuards/index.d.ts +7 -0
- package/dist/src/typeGuards/number.d.ts +66 -0
- package/dist/src/typeGuards/string.d.ts +15 -0
- package/dist/src/untokenizer/index.d.ts +2 -0
- package/dist/src/utils/arity.d.ts +10 -0
- package/dist/src/utils/debug/debugTools.d.ts +1 -0
- package/dist/src/utils/debug/getCodeMarker.d.ts +2 -0
- package/dist/src/utils/debug/getSourceCodeInfo.d.ts +2 -0
- package/dist/src/utils/docString/generateDocString.d.ts +2 -0
- package/dist/src/utils/getAssertionError.d.ts +3 -0
- package/dist/src/utils/index.d.ts +14 -0
- package/dist/src/utils/maybePromise.d.ts +54 -0
- package/dist/src/utils/symbols.d.ts +3 -0
- package/dist/testFramework.esm.js +2 -0
- package/dist/testFramework.esm.js.map +1 -0
- package/dist/testFramework.js +2 -0
- package/dist/testFramework.js.map +1 -0
- package/package.json +144 -16
- package/dist/index.d.ts +0 -2
- package/dist/index.d.ts.map +0 -1
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,MAAM,CAAC,MAAM,OAAO,GAAG,OAAO,CAAC"}
|
|
1
|
+
{"version":3,"file":"index.js","sources":["../src/utils/debug/getCodeMarker.ts","../src/errors.ts","../src/constants/constants.ts","../src/utils/symbols.ts","../src/utils/debug/debugTools.ts","../src/utils/debug/getSourceCodeInfo.ts","../src/utils/getAssertionError.ts","../src/typeGuards/index.ts","../src/typeGuards/dvalaFunction.ts","../src/typeGuards/dvala.ts","../src/typeGuards/string.ts","../src/builtin/core/assertion.ts","../src/typeGuards/number.ts","../src/utils/arity.ts","../src/builtin/core/bitwise.ts","../src/utils/index.ts","../src/utils/maybePromise.ts","../src/typeGuards/array.ts","../src/builtin/core/collection.ts","../src/builtin/core/array.ts","../src/builtin/core/sequence.ts","../src/typeGuards/annotatedArrays.ts","../src/builtin/core/math.ts","../src/builtin/core/misc.ts","../src/builtin/core/object.ts","../src/builtin/core/predicates.ts","../src/builtin/core/regexp.ts","../src/builtin/core/string.ts","../src/builtin/core/functional.ts","../src/utils/docString/generateDocString.ts","../src/builtin/core/meta.ts","../src/builtin/core/vector.ts","../src/builtin/normalExpressions/index.ts","../src/builtin/specialExpressions/and.ts","../src/builtin/specialExpressions/cond.ts","../src/parser/types.ts","../src/builtin/bindingNode.ts","../src/builtin/specialExpressions/object.ts","../src/builtin/specialExpressions/match.ts","../src/builtin/specialExpressions/defined.ts","../src/builtin/specialExpressions/block.ts","../src/builtin/specialExpressions/functions.ts","../src/builtin/specialExpressions/if.ts","../src/builtin/specialExpressions/unless.ts","../src/builtin/specialExpressions/let.ts","../src/builtin/specialExpressions/loop.ts","../src/builtin/specialExpressions/loops.ts","../src/builtin/specialExpressions/or.ts","../src/builtin/specialExpressions/qq.ts","../src/builtin/specialExpressions/recur.ts","../src/builtin/specialExpressions/throw.ts","../src/builtin/specialExpressions/try.ts","../src/builtin/specialExpressions/array.ts","../src/builtin/specialExpressions/effect.ts","../src/builtin/specialExpressions/import.ts","../src/builtin/specialExpressions/parallel.ts","../src/builtin/specialExpressions/perform.ts","../src/builtin/specialExpressions/race.ts","../src/evaluator/suspension.ts","../src/builtin/specialExpressionTypes.ts","../src/builtin/index.ts","../src/tokenizer/reservedNames.ts","../src/evaluator/interface.ts","../src/evaluator/ContextStack.ts","../src/evaluator/effectRef.ts","../src/typeGuards/astNode.ts","../src/getUndefinedSymbols/index.ts","../src/evaluator/effectTypes.ts","../src/evaluator/standardEffects.ts","../src/evaluator/serialization.ts","../src/evaluator/trampoline.ts"],"sourcesContent":["import type { SourceCodeInfo } from '../../tokenizer/token'\n\nexport function getCodeMarker(sourceCodeInfo: SourceCodeInfo): string {\n if (!sourceCodeInfo.position || !sourceCodeInfo.code)\n return ''\n\n const leftPadding = sourceCodeInfo.position.column - 1\n const rightPadding = sourceCodeInfo.code.length - leftPadding - 1\n return `${' '.repeat(Math.max(leftPadding, 0))}^${' '.repeat(Math.max(rightPadding, 0))}`\n}\n","import { getCodeMarker } from '../src/utils/debug/getCodeMarker'\nimport type { Arr } from './interface'\nimport type { SourceCodeInfo } from './tokenizer/token'\n\nfunction getDvalaErrorMessage(message: string, sourceCodeInfo?: SourceCodeInfo) {\n if (!sourceCodeInfo) {\n return message\n }\n const location = `${sourceCodeInfo.position.line}:${sourceCodeInfo.position.column}`\n const filePathLine = sourceCodeInfo.filePath\n ? `\\n${sourceCodeInfo.filePath}:${location}`\n : `\\nLocation ${location}`\n const codeLine = `\\n${sourceCodeInfo.code}`\n const codeMarker = `\\n${getCodeMarker(sourceCodeInfo)}`\n return `${message}${filePathLine}${codeLine}${codeMarker}`\n}\n\nexport class RecurSignal extends Error {\n public params: Arr\n constructor(params: Arr) {\n super(`recur, params: ${params}`)\n Object.setPrototypeOf(this, RecurSignal.prototype)\n this.name = 'RecurSignal'\n this.params = params\n }\n}\n\nexport class DvalaError extends Error {\n public readonly sourceCodeInfo?: SourceCodeInfo\n public readonly shortMessage: string\n constructor(err: unknown, sourceCodeInfo: SourceCodeInfo | undefined) {\n const message = err instanceof Error\n ? err.message\n : `${err}`\n\n super(getDvalaErrorMessage(message, sourceCodeInfo))\n this.shortMessage = message\n this.sourceCodeInfo = sourceCodeInfo\n Object.setPrototypeOf(this, DvalaError.prototype)\n this.name = 'DvalaError'\n }\n\n public getCodeMarker(): string | undefined {\n return this.sourceCodeInfo && getCodeMarker(this.sourceCodeInfo)\n }\n}\n\nexport class UserDefinedError extends DvalaError {\n public userMessage: string\n constructor(message: string, sourceCodeInfo?: SourceCodeInfo) {\n super(message, sourceCodeInfo)\n this.userMessage = message\n Object.setPrototypeOf(this, UserDefinedError.prototype)\n this.name = 'UserDefinedError'\n }\n}\n\nexport class AssertionError extends DvalaError {\n constructor(message: string | Error, sourceCodeInfo?: SourceCodeInfo) {\n super(message, sourceCodeInfo)\n Object.setPrototypeOf(this, AssertionError.prototype)\n this.name = 'AssertionError'\n }\n}\n\nexport class UndefinedSymbolError extends DvalaError {\n public symbol: string\n constructor(symbolName: string, sourceCodeInfo?: SourceCodeInfo) {\n const message = `Undefined symbol '${symbolName}'.`\n super(message, sourceCodeInfo)\n this.symbol = symbolName\n Object.setPrototypeOf(this, UndefinedSymbolError.prototype)\n this.name = 'UndefinedSymbolError'\n }\n}\n\nexport function isDvalaError(error: unknown): error is DvalaError {\n return error instanceof DvalaError\n}\n","export const NodeTypes = {\n Number: 1,\n String: 2,\n NormalExpression: 3,\n SpecialExpression: 4,\n UserDefinedSymbol: 5,\n NormalBuiltinSymbol: 6,\n SpecialBuiltinSymbol: 7,\n ReservedSymbol: 8,\n Binding: 9,\n Spread: 10,\n} as const\n\nconst NodeTypesSet = new Set(Object.values(NodeTypes))\n\nexport type NodeType = typeof NodeTypes[keyof typeof NodeTypes]\n\nexport function getNodeTypeName(type: NodeType): keyof typeof NodeTypes {\n return Object.keys(NodeTypes).find(key => NodeTypes[key as keyof typeof NodeTypes] === type) as keyof typeof NodeTypes\n}\n\n// TODO, is this needed?\nexport function isNodeType(type: unknown): type is NodeType {\n return typeof type === 'number' && NodeTypesSet.has(type as NodeType)\n}\n\nconst functionTypes = [\n 'UserDefined',\n 'Partial',\n 'Comp',\n 'Constantly',\n 'Juxt',\n 'Complement',\n 'EveryPred',\n 'SomePred',\n 'Fnull',\n 'Builtin',\n 'SpecialBuiltin',\n 'NativeJsFunction',\n 'Module',\n] as const\n\nconst functionTypeSet = new Set(functionTypes)\n\nexport type FunctionType = typeof functionTypes[number]\n\nexport function isFunctionType(type: unknown): type is FunctionType {\n return typeof type === 'string' && functionTypeSet.has(type as FunctionType)\n}\n","export const FUNCTION_SYMBOL = '^^fn^^'\nexport const REGEXP_SYMBOL = '^^re^^'\nexport const EFFECT_SYMBOL = '^^ef^^'\n","import { getNodeTypeName, isFunctionType, isNodeType } from '../../constants/constants'\nimport type { AstNode, DvalaFunction } from '../../parser/types'\nimport { FUNCTION_SYMBOL } from '../symbols'\n\nfunction isDvalaFunction(func: unknown): func is DvalaFunction {\n if (func === null || typeof func !== 'object')\n return false\n\n return FUNCTION_SYMBOL in func && 'functionType' in func && isFunctionType(func.functionType)\n}\n\nfunction isNode(value: unknown): value is AstNode {\n if (!Array.isArray(value) || value.length < 2)\n return false\n return isNodeType(value[0])\n}\n\nexport function valueToString(value: unknown): string {\n if (isDvalaFunction(value))\n // eslint-disable-next-line ts/no-unsafe-member-access\n return `<function ${(value as any).name || '\\u03BB'}>`\n\n if (isNode(value))\n return `${getNodeTypeName(value[0])}-node`\n\n if (value === null)\n return 'null'\n\n if (typeof value === 'object' && value instanceof RegExp)\n return `${value}`\n\n if (typeof value === 'object' && value instanceof Error)\n return value.toString()\n\n return JSON.stringify(value)\n}\n","import type { SourceCodeInfo } from '../../tokenizer/token'\n\nexport function getSourceCodeInfo(anyValue: any, sourceCodeInfo: SourceCodeInfo | undefined): SourceCodeInfo | undefined {\n // eslint-disable-next-line ts/no-unsafe-return, ts/no-unsafe-member-access\n return anyValue?.sourceCodeInfo ?? sourceCodeInfo\n}\n","import { DvalaError } from '../errors'\nimport type { SourceCodeInfo } from '../tokenizer/token'\nimport { valueToString } from './debug/debugTools'\nimport { getSourceCodeInfo } from './debug/getSourceCodeInfo'\n\nexport function getAssertionError(typeName: string, value: unknown, sourceCodeInfo?: SourceCodeInfo): DvalaError {\n return new DvalaError(`Expected ${typeName}, got ${valueToString(value)}.`, getSourceCodeInfo(value, sourceCodeInfo))\n}\n","import { DvalaError } from '../errors'\nimport type { UnknownRecord } from '../interface'\nimport type { SourceCodeInfo } from '../tokenizer/token'\nimport { valueToString } from '../utils/debug/debugTools'\nimport { getSourceCodeInfo } from '../utils/debug/getSourceCodeInfo'\n\nfunction isNonUndefined<T>(value: T | undefined): value is T {\n return value !== undefined\n}\n\nexport function asNonUndefined<T>(value: T | undefined, sourceCodeInfo?: SourceCodeInfo): T {\n assertNonUndefined(value, sourceCodeInfo)\n return value\n}\n\nexport function assertNonUndefined<T>(value: T | undefined, sourceCodeInfo?: SourceCodeInfo): asserts value is T {\n if (!isNonUndefined(value))\n throw new DvalaError('Unexpected undefined', getSourceCodeInfo(value, sourceCodeInfo))\n}\n\nexport function isUnknownRecord(value: unknown): value is Record<string, unknown> {\n return value !== null && typeof value === 'object' && !Array.isArray(value)\n}\n\nexport function assertUnknownRecord(value: unknown, sourceCodeInfo?: SourceCodeInfo): asserts value is UnknownRecord {\n if (!isUnknownRecord(value)) {\n throw new DvalaError(\n `Expected ${'UnknownRecord'}, got ${valueToString(value)}.`,\n getSourceCodeInfo(value, sourceCodeInfo),\n )\n }\n}\n\nexport function asUnknownRecord(value: unknown, sourceCodeInfo?: SourceCodeInfo): UnknownRecord {\n assertUnknownRecord(value, sourceCodeInfo)\n return value\n}\n","import type { DvalaFunction, NativeJsFunction, NormalBuiltinFunction, UserDefinedFunction } from '../parser/types'\nimport type { SourceCodeInfo } from '../tokenizer/token'\nimport { getAssertionError } from '../utils/getAssertionError'\nimport { FUNCTION_SYMBOL } from '../utils/symbols'\nimport { isUnknownRecord } from '.'\n\nexport function isDvalaFunction(value: unknown): value is DvalaFunction {\n if (value === null || typeof value !== 'object')\n return false\n\n return !!(value as DvalaFunction)[FUNCTION_SYMBOL]\n}\nexport function asDvalaFunction(value: unknown, sourceCodeInfo?: SourceCodeInfo): DvalaFunction {\n assertDvalaFunction(value, sourceCodeInfo)\n return value\n}\nexport function assertDvalaFunction(value: unknown, sourceCodeInfo?: SourceCodeInfo): asserts value is DvalaFunction {\n if (!isDvalaFunction(value))\n throw getAssertionError('DvalaFunction', value, sourceCodeInfo)\n}\n\nexport function isUserDefinedFunction(value: unknown): value is UserDefinedFunction {\n return isDvalaFunction(value) && value.functionType === 'UserDefined'\n}\nexport function asUserDefinedFunction(value: unknown, sourceCodeInfo?: SourceCodeInfo): UserDefinedFunction {\n assertUserDefinedFunction(value, sourceCodeInfo)\n return value\n}\nexport function assertUserDefinedFunction(\n value: unknown,\n sourceCodeInfo?: SourceCodeInfo,\n): asserts value is UserDefinedFunction {\n if (!isUserDefinedFunction(value))\n throw getAssertionError('NativeJsFunction', value, sourceCodeInfo)\n}\n\nexport function isNativeJsFunction(value: unknown): value is NativeJsFunction {\n return isDvalaFunction(value) && value.functionType === 'NativeJsFunction'\n}\nexport function asNativeJsFunction(value: unknown, sourceCodeInfo?: SourceCodeInfo): NativeJsFunction {\n assertNativeJsFunction(value, sourceCodeInfo)\n return value\n}\nexport function assertNativeJsFunction(\n value: unknown,\n sourceCodeInfo?: SourceCodeInfo,\n): asserts value is NativeJsFunction {\n if (!isNativeJsFunction(value))\n throw getAssertionError('NativeJsFunction', value, sourceCodeInfo)\n}\n\nexport function isBuiltinFunction(value: unknown): value is NormalBuiltinFunction {\n return isUnknownRecord(value) && value.functionType === 'Builtin'\n}\n","import type { Any, Coll, Obj, Seq } from '../interface'\nimport type { EffectRef, FunctionLike, RegularExpression } from '../parser/types'\nimport type { SourceCodeInfo } from '../tokenizer/token'\nimport { getAssertionError } from '../utils/getAssertionError'\nimport { EFFECT_SYMBOL, REGEXP_SYMBOL } from '../utils/symbols'\nimport { isDvalaFunction } from './dvalaFunction'\n\nexport function isAny(value: unknown): value is Any {\n // TODO weak test\n return value !== undefined\n}\nexport function asAny(value: unknown, sourceCodeInfo?: SourceCodeInfo): Any {\n assertAny(value, sourceCodeInfo)\n return value\n}\nexport function assertAny(value: unknown, sourceCodeInfo?: SourceCodeInfo): asserts value is Any {\n if (!isAny(value))\n throw getAssertionError('not undefined', value, sourceCodeInfo)\n}\n\nexport function isSeq(value: unknown): value is Seq {\n return Array.isArray(value) || typeof value === 'string'\n}\nexport function asSeq(value: unknown, sourceCodeInfo?: SourceCodeInfo): Seq {\n assertSeq(value, sourceCodeInfo)\n return value\n}\nexport function assertSeq(value: unknown, sourceCodeInfo?: SourceCodeInfo): asserts value is Seq {\n if (!isSeq(value))\n throw getAssertionError('string or array', value, sourceCodeInfo)\n}\n\nexport function isObj(value: unknown): value is Obj {\n return !(\n value === null\n || typeof value !== 'object'\n || Array.isArray(value)\n || value instanceof RegExp\n || isDvalaFunction(value)\n || isRegularExpression(value)\n || isEffectRef(value)\n )\n}\nexport function asObj(value: unknown, sourceCodeInfo?: SourceCodeInfo): Obj {\n assertObj(value, sourceCodeInfo)\n return value\n}\nexport function assertObj(value: unknown, sourceCodeInfo?: SourceCodeInfo): asserts value is Obj {\n if (!isObj(value))\n throw getAssertionError('object', value, sourceCodeInfo)\n}\n\nexport function isColl(value: unknown): value is Coll {\n return isSeq(value) || isObj(value)\n}\nexport function asColl(value: unknown, sourceCodeInfo?: SourceCodeInfo): Coll {\n assertColl(value, sourceCodeInfo)\n return value\n}\nexport function assertColl(value: unknown, sourceCodeInfo?: SourceCodeInfo): asserts value is Coll {\n if (!isColl(value))\n throw getAssertionError('string, array or object', value, sourceCodeInfo)\n}\n\nexport function isRegularExpression(regexp: unknown): regexp is RegularExpression {\n if (regexp === null || typeof regexp !== 'object')\n return false\n\n return !!(regexp as RegularExpression)[REGEXP_SYMBOL]\n}\nexport function asRegularExpression(value: unknown, sourceCodeInfo?: SourceCodeInfo): RegularExpression {\n assertRegularExpression(value, sourceCodeInfo)\n return value\n}\nexport function assertRegularExpression(\n value: unknown,\n sourceCodeInfo?: SourceCodeInfo,\n): asserts value is RegularExpression {\n if (!isRegularExpression(value))\n throw getAssertionError('RegularExpression', value, sourceCodeInfo)\n}\n\nexport function isStringOrRegularExpression(value: unknown): value is string | RegularExpression {\n return isRegularExpression(value) || typeof value === 'string'\n}\nexport function asStringOrRegularExpression(\n value: unknown,\n sourceCodeInfo?: SourceCodeInfo,\n): string | RegularExpression {\n assertStringOrRegularExpression(value, sourceCodeInfo)\n return value\n}\nexport function assertStringOrRegularExpression(\n value: unknown,\n sourceCodeInfo?: SourceCodeInfo,\n): asserts value is string | RegularExpression {\n if (!isStringOrRegularExpression(value))\n throw getAssertionError('string or RegularExpression', value, sourceCodeInfo)\n}\n\nexport function isEffectRef(value: unknown): value is EffectRef {\n if (value === null || typeof value !== 'object')\n return false\n\n return !!(value as EffectRef)[EFFECT_SYMBOL]\n}\nexport function asEffectRef(value: unknown, sourceCodeInfo?: SourceCodeInfo): EffectRef {\n assertEffectRef(value, sourceCodeInfo)\n return value\n}\nexport function assertEffectRef(\n value: unknown,\n sourceCodeInfo?: SourceCodeInfo,\n): asserts value is EffectRef {\n if (!isEffectRef(value))\n throw getAssertionError('EffectRef', value, sourceCodeInfo)\n}\n\nfunction isFunctionLike(value: unknown): value is FunctionLike {\n if (typeof value === 'number')\n return true\n if (isColl(value))\n return true\n if (isDvalaFunction(value))\n return true\n\n return false\n}\nexport function asFunctionLike(value: unknown, sourceCodeInfo?: SourceCodeInfo): FunctionLike {\n assertFunctionLike(value, sourceCodeInfo)\n return value\n}\nexport function assertFunctionLike(value: unknown, sourceCodeInfo?: SourceCodeInfo): asserts value is FunctionLike {\n if (!isFunctionLike(value))\n throw getAssertionError('FunctionLike', value, sourceCodeInfo)\n}\n","import type { SourceCodeInfo } from '../tokenizer/token'\nimport { getAssertionError } from '../utils/getAssertionError'\n\ntype StringAssertionOptions =\n | {\n nonEmpty?: true\n char?: never\n }\n | {\n nonEmpty?: never\n char?: true\n }\n\nexport function isString(value: unknown, options: StringAssertionOptions = {}): value is string {\n if (typeof value !== 'string')\n return false\n\n if (options.nonEmpty && value.length === 0)\n return false\n\n if (options.char && value.length !== 1)\n return false\n\n return true\n}\n\nexport function assertString(\n value: unknown,\n sourceCodeInfo: SourceCodeInfo | undefined,\n options: StringAssertionOptions = {},\n): asserts value is string {\n if (!isString(value, options)) {\n throw getAssertionError(\n `${options.nonEmpty ? 'non empty string' : options.char ? 'character' : 'string'}`,\n value,\n sourceCodeInfo,\n )\n }\n}\n\nexport function asString(\n value: unknown,\n sourceCodeInfo: SourceCodeInfo | undefined,\n options: StringAssertionOptions = {},\n): string {\n assertString(value, sourceCodeInfo, options)\n return value\n}\n\nexport function isStringOrNumber(value: unknown): value is string | number {\n return typeof value === 'string' || typeof value === 'number'\n}\nexport function asStringOrNumber(value: unknown, sourceCodeInfo?: SourceCodeInfo): string | number {\n assertStringOrNumber(value, sourceCodeInfo)\n return value\n}\nexport function assertStringOrNumber(\n value: unknown,\n sourceCodeInfo?: SourceCodeInfo,\n): asserts value is string | number {\n if (!isStringOrNumber(value))\n throw getAssertionError('string or number', value, sourceCodeInfo)\n}\n","import type { Any } from '../../interface'\nimport { AssertionError } from '../../errors'\nimport { asAny } from '../../typeGuards/dvala'\nimport { assertString } from '../../typeGuards/string'\nimport type { BuiltinNormalExpressions } from '../interface'\n\nexport const assertionNormalExpression: BuiltinNormalExpressions = {\n assert: {\n evaluate: (params, sourceCodeInfo): Any => {\n const value = params[0]\n const message = params.length === 2 ? params[1] : `${value}`\n assertString(message, sourceCodeInfo)\n if (!value)\n throw new AssertionError(message, sourceCodeInfo)\n\n return asAny(value, sourceCodeInfo)\n },\n arity: { min: 1, max: 2 },\n docs: {\n category: 'assertion',\n description: 'If $value is falsy it throws `AssertionError` with $message. If no $message is provided, message is set to $value.',\n returns: {\n type: 'any',\n },\n args: {\n value: {\n type: 'any',\n },\n message: {\n type: 'string',\n },\n },\n variants: [\n {\n argumentNames: [\n 'value',\n ],\n },\n {\n argumentNames: [\n 'value',\n 'message',\n ],\n },\n ],\n examples: [\n 'try assert(0, \"Expected a positive value\") catch (e) e.message end',\n ],\n seeAlso: ['assertion.assert-truthy', 'assertion.assert-true'],\n hideOperatorForm: true,\n },\n },\n}\n","import { DvalaError } from '../errors'\nimport type { SourceCodeInfo } from '../tokenizer/token'\nimport { valueToString } from '../utils/debug/debugTools'\nimport { getSourceCodeInfo } from '../utils/debug/getSourceCodeInfo'\n\ntype SignOptions =\n | {\n positive?: true\n negative?: never\n nonPositive?: never\n nonNegative?: never\n zero?: never\n nonZero?: never\n }\n | {\n positive?: never\n negative?: true\n nonPositive?: never\n nonNegative?: never\n zero?: never\n nonZero?: never\n }\n | {\n positive?: never\n negative?: never\n nonPositive?: true\n nonNegative?: never\n zero?: never\n nonZero?: never\n }\n | {\n positive?: never\n negative?: never\n nonPositive?: never\n nonNegative?: true\n zero?: never\n nonZero?: never\n }\n | {\n positive?: never\n negative?: never\n nonPositive?: never\n nonNegative?: never\n zero?: true\n nonZero?: never\n }\n | {\n positive?: never\n negative?: never\n nonPositive?: never\n nonNegative?: never\n zero?: never\n nonZero?: true\n }\n\ntype GtOptions =\n | {\n gt?: number\n gte?: never\n }\n | {\n gt?: never\n gte?: number\n }\n\ntype LtOptions =\n | {\n lt?: number\n lte?: never\n }\n | {\n lt?: never\n lte?: number\n }\n\ntype NumberOptions = {\n integer?: true\n finite?: true\n} & SignOptions &\nGtOptions &\nLtOptions\n\nfunction getRangeString(options: NumberOptions): string {\n const hasUpperAndLowerBound\n = (typeof options.gt === 'number' || typeof options.gte === 'number')\n && (typeof options.lt === 'number' || typeof options.lte === 'number')\n if (hasUpperAndLowerBound) {\n return `${typeof options.gt === 'number' ? `${options.gt} < n ` : `${options.gte} <= n `}${\n typeof options.lt === 'number' ? `< ${options.lt}` : `<= ${options.lte}`\n }`\n }\n else if (typeof options.gt === 'number' || typeof options.gte === 'number') {\n return `${typeof options.gt === 'number' ? `n > ${options.gt}` : `n >= ${options.gte}`}`\n }\n else if (typeof options.lt === 'number' || typeof options.lte === 'number') {\n return `${typeof options.lt === 'number' ? `n < ${options.lt}` : `n <= ${options.lte}`}`\n }\n else { return '' }\n}\n\nfunction getSignString(options: NumberOptions): string {\n return options.positive\n ? 'positive'\n : options.negative\n ? 'negative'\n : options.nonNegative\n ? 'non negative'\n : options.nonPositive\n ? 'non positive'\n : options.nonZero\n ? 'non zero'\n : ''\n}\n\nfunction getNumberTypeName(options: NumberOptions): string {\n if (options.zero)\n return 'zero'\n\n const sign = getSignString(options)\n const numberType = options.integer ? 'integer' : 'number'\n const finite = options.finite ? 'finite' : ''\n const range = getRangeString(options)\n\n return [sign, finite, numberType, range].filter(x => !!x).join(' ')\n}\n\nexport function isNumber(value: unknown, options: NumberOptions = {}): value is number {\n if (typeof value !== 'number')\n return false\n\n if (Number.isNaN(value))\n return false\n\n if (options.integer && !Number.isInteger(value))\n return false\n\n if (options.finite && !Number.isFinite(value))\n return false\n\n if (options.zero && value !== 0)\n return false\n\n if (options.nonZero && value === 0)\n return false\n\n if (options.positive && value <= 0)\n return false\n\n if (options.negative && value >= 0)\n return false\n\n if (options.nonPositive && value > 0)\n return false\n\n if (options.nonNegative && value < 0)\n return false\n\n if (typeof options.gt === 'number' && value <= options.gt)\n return false\n\n if (typeof options.gte === 'number' && value < options.gte)\n return false\n\n if (typeof options.lt === 'number' && value >= options.lt)\n return false\n\n if (typeof options.lte === 'number' && value > options.lte)\n return false\n\n return true\n}\n\nexport function assertNumber(\n value: unknown,\n sourceCodeInfo?: SourceCodeInfo,\n options: NumberOptions = {},\n): asserts value is number {\n if (!isNumber(value, options)) {\n throw new DvalaError(\n `Expected ${getNumberTypeName(options)}, got ${valueToString(value)}.`,\n getSourceCodeInfo(value, sourceCodeInfo),\n )\n }\n}\n\nexport function asNumber(\n value: unknown,\n sourceCodeInfo: SourceCodeInfo | undefined,\n options: NumberOptions = {},\n): number {\n assertNumber(value, sourceCodeInfo, options)\n return value\n}\n","import type { Arity } from '../builtin/interface'\nimport { DvalaError } from '../errors'\nimport type { FunctionLike } from '../parser/types'\nimport type { SourceCodeInfo } from '../tokenizer/token'\nimport { isColl } from '../typeGuards/dvala'\nimport { valueToString } from './debug/debugTools'\n\nexport function arityAccepts(arity: Arity, nbrOfParams: number): boolean {\n const { min, max } = arity\n if (typeof min === 'number' && nbrOfParams < min) {\n return false\n }\n if (typeof max === 'number' && nbrOfParams > max) {\n return false\n }\n return true\n}\n\nexport function arityAcceptsMin(arity: Arity, nbrOfParams: number): boolean {\n const { min } = arity\n if (typeof min === 'number' && nbrOfParams < min) {\n return false\n }\n return true\n}\n\nexport function getCommonArityFromFunctions(params: FunctionLike[]): Arity | null {\n return params.reduce((acc: Arity | null, param): Arity | null => {\n if (acc === null) {\n return null\n }\n const arity: Arity = (typeof param === 'number' || isColl(param)) ? toFixedArity(1) : param.arity\n const { min: aMin, max: aMax } = arity\n const { min: bMin, max: bMax } = acc\n const min = typeof aMin === 'number' && typeof bMin === 'number'\n ? Math.max(aMin, bMin)\n : typeof aMin === 'number' ? aMin : typeof bMin === 'number' ? bMin : undefined\n const max = typeof aMax === 'number' && typeof bMax === 'number'\n ? Math.min(aMax, bMax)\n : typeof aMax === 'number' ? aMax : typeof bMax === 'number' ? bMax : undefined\n\n if (typeof min === 'number' && typeof max === 'number' && min > max) {\n return null\n }\n\n return { min, max }\n }, {})\n}\n\nexport function getArityFromFunction(param: FunctionLike): Arity {\n return (typeof param === 'number' || isColl(param)) ? toFixedArity(1) : param.arity\n}\n\nexport function assertNumberOfParams(arity: Arity, length: number, sourceCodeInfo: SourceCodeInfo | undefined): void {\n const { min, max } = arity\n if (typeof min === 'number' && length < min) {\n throw new DvalaError(\n `Wrong number of arguments, expected at least ${min}, got ${valueToString(length)}.`,\n sourceCodeInfo,\n )\n }\n\n if (typeof max === 'number' && length > max) {\n throw new DvalaError(\n `Wrong number of arguments, expected at most ${max}, got ${valueToString(length)}.`,\n sourceCodeInfo,\n )\n }\n}\n\nexport function canBeOperator(count: Arity): boolean {\n if (typeof count.max === 'number' && count.max < 2) {\n return false\n }\n\n if (typeof count.min === 'number' && count.min > 2) {\n return false\n }\n\n return true\n}\n\nexport function toFixedArity(arity: number): Arity {\n return { min: arity, max: arity }\n}\n","import { assertNumber } from '../../typeGuards/number'\nimport { toFixedArity } from '../../utils/arity'\nimport type { Argument, BuiltinNormalExpressions } from '../interface'\n\nfunction getOperatorArgs(a: 'integer', b: 'integer'): Record<string, Argument> {\n return { a: { type: a }, b: { type: b } }\n}\n\nexport const bitwiseNormalExpression: BuiltinNormalExpressions = {\n '<<': {\n evaluate: ([num, count], sourceCodeInfo): number => {\n assertNumber(num, sourceCodeInfo, { integer: true })\n assertNumber(count, sourceCodeInfo, { integer: true, nonNegative: true })\n\n return num << count\n },\n arity: toFixedArity(2),\n docs: {\n category: 'bitwise',\n returns: { type: 'integer' },\n args: { ...getOperatorArgs('integer', 'integer') },\n variants: [{ argumentNames: ['a', 'b'] }],\n description: 'Shifts $a arithmetically left by $b bit positions.',\n seeAlso: ['>>', '>>>'],\n examples: [\n '1 << 10',\n '<<(1, 10)',\n '<<(-4, 2)',\n ],\n },\n },\n '>>': {\n evaluate: ([num, count], sourceCodeInfo): number => {\n assertNumber(num, sourceCodeInfo, { integer: true })\n assertNumber(count, sourceCodeInfo, { integer: true, nonNegative: true })\n\n return num >> count\n },\n arity: toFixedArity(2),\n docs: {\n category: 'bitwise',\n returns: { type: 'integer' },\n args: { ...getOperatorArgs('integer', 'integer') },\n variants: [{ argumentNames: ['a', 'b'] }],\n description: 'Shifts $a arithmetically right by $b bit positions.',\n seeAlso: ['<<', '>>>'],\n examples: [\n '2048 >> 10',\n '>>(2048, 10)',\n '>>>(-16, 2)',\n '>>(4, 10)',\n ],\n },\n },\n '>>>': {\n evaluate: ([num, count], sourceCodeInfo): number => {\n assertNumber(num, sourceCodeInfo, { integer: true })\n assertNumber(count, sourceCodeInfo, { integer: true, nonNegative: true })\n\n return num >>> count\n },\n arity: toFixedArity(2),\n docs: {\n category: 'bitwise',\n returns: { type: 'integer' },\n args: { ...getOperatorArgs('integer', 'integer') },\n variants: [{ argumentNames: ['a', 'b'] }],\n description: 'Shifts $a arithmetically right by $b bit positions without sign extension.',\n seeAlso: ['<<', '>>'],\n examples: [\n '-16 >>> 2',\n '>>>(2048, 10)',\n '>>>(-16, 2)',\n '>>>(4, 10)',\n '>>>(-1, 10)',\n ],\n },\n },\n '&': {\n evaluate: ([first, ...rest], sourceCodeInfo): number => {\n assertNumber(first, sourceCodeInfo, { integer: true })\n\n return rest.reduce((result: number, value) => {\n assertNumber(value, sourceCodeInfo, { integer: true })\n return result & value\n }, first)\n },\n arity: { min: 2 },\n docs: {\n category: 'bitwise',\n returns: { type: 'integer' },\n args: {\n ...getOperatorArgs('integer', 'integer'),\n c: { type: 'integer', rest: true },\n },\n variants: [\n { argumentNames: ['a', 'b'] },\n { argumentNames: ['a', 'b', 'c'] },\n ],\n description: 'Returns bitwise `and` of all arguments.',\n seeAlso: ['|', 'xor', 'bitwise.bit-not', 'bitwise.bit-and-not'],\n examples: [\n '0b0011 & 0b0110',\n '&(0b0011, 0b0110)',\n '&(0b0011, 0b0110, 0b1001)',\n ],\n },\n },\n '|': {\n evaluate: ([first, ...rest], sourceCodeInfo): number => {\n assertNumber(first, sourceCodeInfo, { integer: true })\n\n return rest.reduce((result: number, value) => {\n assertNumber(value, sourceCodeInfo, { integer: true })\n return result | value\n }, first)\n },\n arity: { min: 2 },\n docs: {\n category: 'bitwise',\n returns: { type: 'integer' },\n args: {\n ...getOperatorArgs('integer', 'integer'),\n c: { type: 'integer', rest: true },\n },\n variants: [\n { argumentNames: ['a', 'b'] },\n { argumentNames: ['a', 'b', 'c'] },\n ],\n description: 'Returns bitwise `or` of all arguments.',\n seeAlso: ['&', 'xor', 'bitwise.bit-not', 'bitwise.bit-and-not'],\n examples: [\n '0b0011 | 0b0110',\n '|(0b0011, 0b0110)',\n '|(0b1000, 0b0100, 0b0010)',\n ],\n },\n },\n 'xor': {\n evaluate: ([first, ...rest], sourceCodeInfo): number => {\n assertNumber(first, sourceCodeInfo, { integer: true })\n\n return rest.reduce((result: number, value) => {\n assertNumber(value, sourceCodeInfo, { integer: true })\n return result ^ value\n }, first)\n },\n arity: { min: 2 },\n docs: {\n category: 'bitwise',\n returns: { type: 'integer' },\n args: {\n ...getOperatorArgs('integer', 'integer'),\n c: { type: 'integer', rest: true },\n },\n variants: [\n { argumentNames: ['a', 'b'] },\n { argumentNames: ['a', 'b', 'c'] },\n ],\n description: 'Returns bitwise `xor` of all arguments.',\n seeAlso: ['&', '|', 'bitwise.bit-not', 'bitwise.bit-and-not'],\n examples: [\n '0b0011 xor 0b0110',\n 'xor(0b0011, 0b0110)',\n 'xor(0b11110000, 0b00111100, 0b10101010)',\n ],\n },\n },\n}\n","import type { Any, Coll, Obj } from '../interface'\nimport type { SourceCodeInfo } from '../tokenizer/token'\nimport { asAny, isColl, isObj, isRegularExpression } from '../typeGuards/dvala'\nimport { isNumber } from '../typeGuards/number'\nimport { asString, assertStringOrNumber } from '../typeGuards/string'\nimport { isUnknownRecord } from '../typeGuards'\nimport { DvalaError } from '../errors'\n\nexport function collHasKey(coll: unknown, key: string | number): boolean {\n if (!isColl(coll))\n return false\n\n if (typeof coll === 'string' || Array.isArray(coll)) {\n if (!isNumber(key, { integer: true }))\n return false\n\n return key >= 0 && key < coll.length\n }\n return !!Object.getOwnPropertyDescriptor(coll, key)\n}\n\nexport function compare<T extends string | number>(a: T, b: T, sourceCodeInfo: SourceCodeInfo | undefined): number {\n assertStringOrNumber(a, sourceCodeInfo)\n assertStringOrNumber(b, sourceCodeInfo)\n\n if (typeof a === 'string' && typeof b === 'string') {\n return a < b ? -1 : a > b ? 1 : 0\n }\n if (typeof a === 'number' && typeof b === 'number') {\n return Math.sign((a) - (b))\n }\n throw new DvalaError(`Cannot compare values of different types: ${typeof a} and ${typeof b}`, sourceCodeInfo)\n}\n\nexport function deepEqual(a: unknown, b: unknown, sourceCodeInfo?: SourceCodeInfo): boolean {\n if (a === b)\n return true\n\n if (typeof a === 'number' && typeof b === 'number')\n return approxEqual(a, b)\n\n if (Array.isArray(a) && Array.isArray(b)) {\n if (a.length !== b.length)\n return false\n\n for (let i = 0; i < a.length; i += 1) {\n if (!deepEqual(asAny(a[i], sourceCodeInfo), asAny(b[i], sourceCodeInfo), sourceCodeInfo))\n return false\n }\n return true\n }\n if (isRegularExpression(a) && isRegularExpression(b))\n return a.s === b.s && a.f === b.f\n\n if (isUnknownRecord(a) && isUnknownRecord(b)) {\n const aKeys = Object.keys(a)\n const bKeys = Object.keys(b)\n if (aKeys.length !== bKeys.length)\n return false\n\n for (let i = 0; i < aKeys.length; i += 1) {\n const key = asString(aKeys[i], sourceCodeInfo)\n if (!deepEqual(a[key], b[key], sourceCodeInfo))\n return false\n }\n return true\n }\n return false\n}\n\nexport function toNonNegativeInteger(num: number): number {\n return Math.max(0, Math.ceil(num))\n}\n\nexport function toAny(value: unknown): Any {\n return (value ?? null) as Any\n}\n\nfunction clone<T>(value: T): T {\n if (isObj(value)) {\n return Object.entries(value).reduce((result: Obj, entry) => {\n const [key, val] = entry\n result[key] = clone(val)\n return result\n }, {}) as T\n }\n if (Array.isArray(value))\n // eslint-disable-next-line ts/no-unsafe-return\n return value.map(item => clone(item)) as unknown as T\n\n return value\n}\n\nexport function cloneColl<T extends Coll>(value: T): T {\n return clone(value)\n}\n\nexport function joinSets<T>(...results: Set<T>[]): Set<T> {\n const result = new Set<T>()\n for (const symbols of results)\n symbols.forEach(symbol => result.add(symbol))\n\n return result\n}\n\nexport function addToSet<T>(target: Set<T>, source: Set<T>): void {\n source.forEach(symbol => target.add(symbol))\n}\n\nexport const EPSILON = 1e-10\n\nexport function approxEqual(a: number, b: number, epsilon: number = EPSILON): boolean {\n if (a === b) {\n return true\n }\n\n const diff = Math.abs(a - b)\n\n if (a === 0 || b === 0 || diff < epsilon) {\n // Use absolute error for values near zero\n return diff < epsilon\n }\n const absA = Math.abs(a)\n const absB = Math.abs(b)\n\n // Use relative error for larger values\n return diff / (absA + absB) < epsilon\n}\n\nexport function approxZero(value: number): boolean {\n return Math.abs(value) < EPSILON\n}\n\nexport function smartTrim(str: string, minIndent = 0): string {\n const lines = str.split('\\n')\n while (lines[0]?.match(/^\\s*$/)) {\n lines.shift() // Remove leading empty lines\n }\n while (lines[lines.length - 1]?.match(/^\\s*$/)) {\n lines.pop() // Remove trailing empty lines\n }\n const indent = lines.reduce((acc, line) => {\n if (line.match(/^\\s*$/))\n return acc // Skip empty lines\n const lineIndent = line.match(/^\\s*/)![0].length\n return Math.min(acc, lineIndent)\n }, Infinity)\n return lines.map(line => ' '.repeat(minIndent) + line.slice(indent)).join('\\n').trimEnd()\n}\n","/**\n * MaybePromise utilities for transparent async support.\n *\n * The sync path stays zero-overhead — when no async JS functions are involved,\n * everything runs synchronously with only `instanceof Promise` checks as overhead.\n * When an async value is detected, the evaluation chain switches to Promise-based\n * execution for the remainder.\n */\n\nexport type MaybePromise<T> = T | Promise<T>\n\n/**\n * Chain a value that might be a Promise. If the value is sync, calls fn synchronously.\n * If it's a Promise, chains with .then().\n */\nexport function chain<T, U>(value: MaybePromise<T>, fn: (v: T) => MaybePromise<U>): MaybePromise<U> {\n if (value instanceof Promise) {\n return value.then(fn)\n }\n return fn(value)\n}\n\n/**\n * Like Array.map but handles MaybePromise callbacks sequentially.\n * In the sync case, runs as a simple loop. Switches to async only when needed.\n */\nexport function mapSequential<T, U>(\n arr: readonly T[],\n fn: (elem: T, index: number) => MaybePromise<U>,\n): MaybePromise<U[]> {\n const results: U[] = []\n for (let i = 0; i < arr.length; i++) {\n const result = fn(arr[i]!, i)\n if (result instanceof Promise) {\n return chainRemainingMap(result, results, arr, fn, i)\n }\n results.push(result)\n }\n return results\n}\n\nasync function chainRemainingMap<T, U>(\n currentPromise: Promise<U>,\n results: U[],\n arr: readonly T[],\n fn: (elem: T, index: number) => MaybePromise<U>,\n startIndex: number,\n): Promise<U[]> {\n results.push(await currentPromise)\n for (let i = startIndex + 1; i < arr.length; i++) {\n results.push(await fn(arr[i]!, i))\n }\n return results\n}\n\n/**\n * Like Array.reduce but handles MaybePromise callbacks sequentially.\n * In the sync case, runs as a simple loop. Switches to async only when needed.\n */\nexport function reduceSequential<T, U>(\n arr: readonly T[],\n fn: (acc: U, elem: T, index: number) => MaybePromise<U>,\n initial: U,\n): MaybePromise<U> {\n let result: U = initial\n for (let i = 0; i < arr.length; i++) {\n const next = fn(result, arr[i]!, i)\n if (next instanceof Promise) {\n return chainRemainingReduce(next, arr, fn, i)\n }\n result = next\n }\n return result\n}\n\nasync function chainRemainingReduce<T, U>(\n currentPromise: Promise<U>,\n arr: readonly T[],\n fn: (acc: U, elem: T, index: number) => MaybePromise<U>,\n startIndex: number,\n): Promise<U> {\n let result = await currentPromise\n for (let i = startIndex + 1; i < arr.length; i++) {\n result = await fn(result, arr[i]!, i)\n }\n return result\n}\n\n/**\n * Like Array.forEach but handles MaybePromise callbacks sequentially.\n * In the sync case, runs as a simple loop. Switches to async only when needed.\n */\nexport function forEachSequential<T>(\n arr: readonly T[],\n fn: (elem: T, index: number) => MaybePromise<void>,\n): MaybePromise<void> {\n for (let i = 0; i < arr.length; i++) {\n const result = fn(arr[i]!, i)\n if (result instanceof Promise) {\n return chainRemainingForEach(result, arr, fn, i)\n }\n }\n}\n\nasync function chainRemainingForEach<T>(\n currentPromise: Promise<void>,\n arr: readonly T[],\n fn: (elem: T, index: number) => MaybePromise<void>,\n startIndex: number,\n): Promise<void> {\n await currentPromise\n for (let i = startIndex + 1; i < arr.length; i++) {\n await fn(arr[i]!, i)\n }\n}\n\n/**\n * Try/catch that handles MaybePromise values correctly.\n * If tryFn returns a Promise, catches both sync throws and Promise rejections.\n */\nexport function tryCatch<T>(\n tryFn: () => MaybePromise<T>,\n catchFn: (error: unknown) => MaybePromise<T>,\n): MaybePromise<T> {\n try {\n const result = tryFn()\n if (result instanceof Promise) {\n return result.catch(catchFn)\n }\n return result\n }\n catch (error) {\n return catchFn(error)\n }\n}\n\n/**\n * Like Array.some but handles MaybePromise callbacks sequentially.\n * Returns the first truthy MaybePromise result, or false.\n */\nexport function someSequential<T>(\n arr: readonly T[],\n fn: (elem: T, index: number) => MaybePromise<unknown>,\n): MaybePromise<boolean> {\n for (let i = 0; i < arr.length; i++) {\n const result = fn(arr[i]!, i)\n if (result instanceof Promise) {\n return chainRemainingSome(result, arr, fn, i)\n }\n if (result)\n return true\n }\n return false\n}\n\nasync function chainRemainingSome<T>(\n currentPromise: Promise<unknown>,\n arr: readonly T[],\n fn: (elem: T, index: number) => MaybePromise<unknown>,\n startIndex: number,\n): Promise<boolean> {\n if (await currentPromise)\n return true\n for (let i = startIndex + 1; i < arr.length; i++) {\n if (await fn(arr[i]!, i))\n return true\n }\n return false\n}\n\n/**\n * Like Array.every but handles MaybePromise callbacks sequentially.\n * Returns false as soon as a falsy result is found.\n */\nexport function everySequential<T>(\n arr: readonly T[],\n fn: (elem: T, index: number) => MaybePromise<unknown>,\n): MaybePromise<boolean> {\n for (let i = 0; i < arr.length; i++) {\n const result = fn(arr[i]!, i)\n if (result instanceof Promise) {\n return chainRemainingEvery(result, arr, fn, i)\n }\n if (!result)\n return false\n }\n return true\n}\n\nasync function chainRemainingEvery<T>(\n currentPromise: Promise<unknown>,\n arr: readonly T[],\n fn: (elem: T, index: number) => MaybePromise<unknown>,\n startIndex: number,\n): Promise<boolean> {\n if (!await currentPromise)\n return false\n for (let i = startIndex + 1; i < arr.length; i++) {\n if (!await fn(arr[i]!, i))\n return false\n }\n return true\n}\n\n/**\n * Like Array.filter but handles MaybePromise callbacks sequentially.\n * Returns the filtered array.\n */\nexport function filterSequential<T>(\n arr: readonly T[],\n fn: (elem: T, index: number) => MaybePromise<unknown>,\n): MaybePromise<T[]> {\n const results: T[] = []\n for (let i = 0; i < arr.length; i++) {\n const result = fn(arr[i]!, i)\n if (result instanceof Promise) {\n return chainRemainingFilter(result, results, arr, fn, i)\n }\n if (result)\n results.push(arr[i]!)\n }\n return results\n}\n\nasync function chainRemainingFilter<T>(\n currentPromise: Promise<unknown>,\n results: T[],\n arr: readonly T[],\n fn: (elem: T, index: number) => MaybePromise<unknown>,\n startIndex: number,\n): Promise<T[]> {\n if (await currentPromise)\n results.push(arr[startIndex]!)\n for (let i = startIndex + 1; i < arr.length; i++) {\n if (await fn(arr[i]!, i))\n results.push(arr[i]!)\n }\n return results\n}\n\n/**\n * Like Array.findIndex but handles MaybePromise callbacks sequentially.\n * Returns -1 if no element matches.\n */\nexport function findIndexSequential<T>(\n arr: readonly T[],\n fn: (elem: T, index: number) => MaybePromise<unknown>,\n): MaybePromise<number> {\n for (let i = 0; i < arr.length; i++) {\n const result = fn(arr[i]!, i)\n if (result instanceof Promise) {\n return chainRemainingFindIndex(result, arr, fn, i)\n }\n if (result)\n return i\n }\n return -1\n}\n\nasync function chainRemainingFindIndex<T>(\n currentPromise: Promise<unknown>,\n arr: readonly T[],\n fn: (elem: T, index: number) => MaybePromise<unknown>,\n startIndex: number,\n): Promise<number> {\n if (await currentPromise)\n return startIndex\n for (let i = startIndex + 1; i < arr.length; i++) {\n if (await fn(arr[i]!, i))\n return i\n }\n return -1\n}\n","import type { SourceCodeInfo } from '../tokenizer/token'\nimport { getAssertionError } from '../utils/getAssertionError'\n\n// isArray not needed, use Array.isArary\nexport function asArray(value: unknown, sourceCodeInfo?: SourceCodeInfo): unknown[] {\n assertArray(value, sourceCodeInfo)\n return value\n}\nexport function assertArray(value: unknown, sourceCodeInfo?: SourceCodeInfo): asserts value is unknown[] {\n if (!Array.isArray(value))\n throw getAssertionError('array', value, sourceCodeInfo)\n}\n\nexport function isStringArray(value: unknown): value is string[] {\n return Array.isArray(value) && value.every(v => typeof v === 'string')\n}\nexport function asStringArray(value: unknown, sourceCodeInfo?: SourceCodeInfo): string[] {\n assertStringArray(value, sourceCodeInfo)\n return value\n}\nexport function assertStringArray(value: unknown, sourceCodeInfo?: SourceCodeInfo): asserts value is string[] {\n if (!isStringArray(value))\n throw getAssertionError('array of strings', value, sourceCodeInfo)\n}\n\nexport function isCharArray(value: unknown): value is string[] {\n return Array.isArray(value) && value.every(v => typeof v === 'string' && v.length === 1)\n}\nexport function asCharArray(value: unknown, sourceCodeInfo?: SourceCodeInfo): string[] {\n assertCharArray(value, sourceCodeInfo)\n return value\n}\nexport function assertCharArray(value: unknown, sourceCodeInfo?: SourceCodeInfo): asserts value is string[] {\n if (!isCharArray(value))\n throw getAssertionError('array of strings', value, sourceCodeInfo)\n}\n","import type { ContextStack } from '../../evaluator/ContextStack'\nimport type { ExecuteFunction } from '../../evaluator/interface'\nimport type { Any, Arr, Coll, Obj, Seq } from '../../interface'\nimport type { SourceCodeInfo } from '../../tokenizer/token'\nimport { collHasKey, deepEqual, toAny } from '../../utils'\nimport { asAny, asFunctionLike, assertAny, assertColl, assertFunctionLike, assertObj, assertSeq, isObj, isSeq } from '../../typeGuards/dvala'\nimport type { BuiltinNormalExpressions } from '../interface'\nimport { assertArray } from '../../typeGuards/array'\nimport { assertNumber, isNumber } from '../../typeGuards/number'\nimport { assertString, assertStringOrNumber, isString, isStringOrNumber } from '../../typeGuards/string'\nimport type { FunctionLike } from '../../parser/types'\nimport { DvalaError } from '../../errors'\nimport { toFixedArity } from '../../utils/arity'\nimport type { MaybePromise } from '../../utils/maybePromise'\nimport { chain, mapSequential, reduceSequential } from '../../utils/maybePromise'\n\nfunction mapObjects({\n colls,\n contextStack,\n executeFunction,\n fn,\n sourceCodeInfo,\n}: {\n colls: unknown[]\n fn: FunctionLike\n sourceCodeInfo: SourceCodeInfo | undefined\n contextStack: ContextStack\n executeFunction: ExecuteFunction\n}): MaybePromise<Obj> {\n assertObj(colls[0], sourceCodeInfo)\n const keys = Object.keys(colls[0])\n const params: Record<string, unknown[]> = {}\n colls.forEach((obj) => {\n assertObj(obj, sourceCodeInfo)\n const objKeys = Object.keys(obj)\n if (objKeys.length !== keys.length) {\n throw new DvalaError(`All objects must have the same keys. Expected: ${keys.join(', ')}. Found: ${objKeys.join(', ')}`, sourceCodeInfo)\n }\n if (!objKeys.every(key => keys.includes(key))) {\n throw new DvalaError(`All objects must have the same keys. Expected: ${keys.join(', ')}. Found: ${objKeys.join(', ')}`, sourceCodeInfo)\n }\n Object.entries(obj).forEach(([key, value]) => {\n if (!params[key])\n params[key] = []\n params[key].push(value)\n })\n })\n\n const initialObj: Obj = {}\n return reduceSequential(keys, (result: Obj, key) => {\n return chain(\n executeFunction(fn, params[key]!, contextStack, sourceCodeInfo),\n (value) => {\n result[key] = value\n return result\n },\n )\n }, initialObj)\n}\n\nfunction get(coll: Coll, key: string | number): Any | undefined {\n if (isObj(coll)) {\n if (typeof key === 'string' && collHasKey(coll, key))\n return toAny(coll[key])\n }\n else {\n if (isNumber(key, { nonNegative: true, integer: true }) && key >= 0 && key < coll.length)\n return toAny(coll[key])\n }\n return undefined\n}\n\nfunction assoc(coll: Coll, key: string | number, value: Any, sourceCodeInfo?: SourceCodeInfo) {\n assertColl(coll, sourceCodeInfo)\n assertStringOrNumber(key, sourceCodeInfo)\n if (Array.isArray(coll) || typeof coll === 'string') {\n assertNumber(key, sourceCodeInfo, { integer: true })\n assertNumber(key, sourceCodeInfo, { gte: 0 })\n assertNumber(key, sourceCodeInfo, { lte: coll.length })\n if (typeof coll === 'string') {\n assertString(value, sourceCodeInfo, { char: true })\n return `${coll.slice(0, key)}${value}${coll.slice(key + 1)}`\n }\n const copy = [...coll]\n copy[key] = value\n return copy\n }\n assertString(key, sourceCodeInfo)\n const copy = { ...coll }\n copy[key] = value\n return copy\n}\n\nexport const collectionNormalExpression: BuiltinNormalExpressions = {\n 'filter': {\n evaluate: ([coll, fn]: Arr, sourceCodeInfo, contextStack, { executeFunction }): MaybePromise<Coll> => {\n assertColl(coll, sourceCodeInfo)\n assertFunctionLike(fn, sourceCodeInfo)\n if (Array.isArray(coll)) {\n return reduceSequential(coll, (result: Arr, elem) => {\n return chain(executeFunction(fn, [elem], contextStack, sourceCodeInfo), (keep) => {\n if (keep)\n result.push(elem)\n return result\n })\n }, [] as Arr)\n }\n if (isString(coll)) {\n const chars = coll.split('')\n return chain(\n reduceSequential(chars, (result: string[], elem) => {\n return chain(executeFunction(fn, [elem], contextStack, sourceCodeInfo), (keep) => {\n if (keep)\n result.push(elem)\n return result\n })\n }, [] as string[]),\n filtered => filtered.join(''),\n )\n }\n const entries = Object.entries(coll)\n const initialObj: Obj = {}\n return reduceSequential(entries, (result: Obj, [key, value]) => {\n return chain(executeFunction(fn, [value], contextStack, sourceCodeInfo), (keep) => {\n if (keep)\n result[key] = value\n return result\n })\n }, initialObj)\n },\n arity: toFixedArity(2),\n docs: {\n category: 'collection',\n returns: { type: 'collection' },\n args: {\n a: { type: 'collection' },\n b: { type: 'function' },\n coll: { type: 'collection' },\n fun: { type: 'function' },\n },\n variants: [{ argumentNames: ['coll', 'fun'] }],\n description: 'Creates a new collection with all elements that pass the test implemented by $fun.',\n seeAlso: ['collection.filteri', 'map', 'sequence.remove'],\n examples: [\n `\nfilter(\n [\"Albert\", \"Mojir\", 160, [1, 2]],\n string?\n)`,\n `\nfilter(\n [5, 10, 15, 20],\n -> $ > 10\n)`,\n `\nfilter(\n { a: 1, b: 2 },\n odd?\n)`,\n ],\n },\n },\n 'map': {\n evaluate: (params, sourceCodeInfo, contextStack, { executeFunction }) => {\n const fn = asFunctionLike(params.at(-1), sourceCodeInfo)\n\n if (isObj(params[0])) {\n return mapObjects({\n colls: params.slice(0, -1),\n fn,\n sourceCodeInfo,\n contextStack,\n executeFunction,\n })\n }\n\n const seqs = params.slice(0, -1) as Seq[]\n assertSeq(seqs[0], sourceCodeInfo)\n\n const isStr = typeof seqs[0] === 'string'\n let len = seqs[0].length\n seqs.slice(1).forEach((seq) => {\n if (isStr) {\n assertString(seq, sourceCodeInfo)\n }\n else {\n assertArray(seq, sourceCodeInfo)\n }\n len = Math.min(len, seq.length)\n })\n\n const paramArray: unknown[][] = []\n for (let i = 0; i < len; i++) {\n paramArray.push(seqs.map(seq => seq[i]))\n }\n\n const mapped = mapSequential(paramArray, p => executeFunction(fn, p, contextStack, sourceCodeInfo))\n\n if (!isStr) {\n return mapped\n }\n return chain(mapped, (resolvedMapped) => {\n resolvedMapped.forEach(char => assertString(char, sourceCodeInfo))\n return resolvedMapped.join('')\n })\n },\n arity: { min: 2 },\n docs: {\n category: 'collection',\n returns: { type: 'collection' },\n args: {\n a: { type: 'collection' },\n b: { type: 'function' },\n colls: { type: 'collection', rest: true, description: 'At least one.' },\n fun: { type: 'function' },\n },\n variants: [{ argumentNames: ['colls', 'fun'] }],\n description: 'Creates a new collection populated with the results of calling $fun on every element in $colls.',\n seeAlso: ['collection.mapi', 'filter', 'reduce', 'mapcat', 'grid.cell-map', 'grid.cell-mapi'],\n examples: [\n '[1, 2, 3] map -',\n '[1, 2, 3] map -> -($)',\n 'map([\"Albert\", \"Mojir\", 42], str)',\n 'map([1, 2, 3], inc)',\n 'map([1, 2, 3], [1, 10, 100], *)',\n 'map({ a: 1, b: 2 }, inc)',\n 'map({ a: 1, b: 2 }, { a: 10, b: 20 }, +)',\n ],\n },\n },\n 'reduce': {\n evaluate: ([coll, fn, initial], sourceCodeInfo, contextStack, { executeFunction }): MaybePromise<Any> => {\n assertColl(coll, sourceCodeInfo)\n assertFunctionLike(fn, sourceCodeInfo)\n assertAny(initial, sourceCodeInfo)\n\n if (typeof coll === 'string') {\n assertString(initial, sourceCodeInfo)\n if (coll.length === 0)\n return initial\n\n return reduceSequential(coll.split(''), (result: Any, elem) => {\n return executeFunction(fn, [result, elem], contextStack, sourceCodeInfo)\n }, initial)\n }\n else if (Array.isArray(coll)) {\n if (coll.length === 0)\n return initial\n\n return reduceSequential(coll, (result: Any, elem) => {\n return executeFunction(fn, [result, elem], contextStack, sourceCodeInfo)\n }, initial)\n }\n else {\n if (Object.keys(coll).length === 0)\n return initial\n\n return reduceSequential(Object.entries(coll), (result: Any, [, elem]) => {\n return executeFunction(fn, [result, elem], contextStack, sourceCodeInfo)\n }, initial)\n }\n },\n arity: toFixedArity(3),\n docs: {\n category: 'collection',\n returns: { type: 'any' },\n args: {\n fun: { type: 'function' },\n coll: { type: 'collection' },\n initial: { type: 'any' },\n },\n variants: [{ argumentNames: ['coll', 'fun', 'initial'] }],\n description: 'Runs $fun function on each element of the $coll, passing in the return value from the calculation on the preceding element. The final result of running the reducer across all elements of the $coll is a single value.',\n seeAlso: ['collection.reduce-right', 'collection.reducei', 'collection.reductions', 'map', 'grid.cell-reduce', 'grid.cell-reducei'],\n examples: [\n 'reduce([1, 2, 3], +, 0)',\n 'reduce([], +, 0)',\n 'reduce({ a: 1, b: 2 }, +, 0)',\n `\nreduce(\n [1, 2, 3, 4, 5, 6, 7, 8, 9],\n (result, value) -> result + (even?(value) ? value : 0),\n 0)`,\n ],\n },\n },\n 'get': {\n evaluate: (params, sourceCodeInfo) => {\n const [coll, key] = params\n const defaultValue = toAny(params[2])\n assertStringOrNumber(key, sourceCodeInfo)\n if (coll === null)\n return defaultValue\n\n assertColl(coll, sourceCodeInfo)\n const result = get(coll, key)\n return result === undefined ? defaultValue : result\n },\n arity: { min: 2, max: 3 },\n docs: {\n category: 'collection',\n returns: { type: 'any' },\n args: {\n 'a': { type: 'collection' },\n 'b': { type: ['string', 'integer'] },\n 'not-found': { type: 'any', description: 'Default value to return if $b is not found.' },\n },\n variants: [\n { argumentNames: ['a', 'b'] },\n { argumentNames: ['a', 'b', 'not-found'] },\n ],\n description: 'Returns value in $a mapped at $b.',\n seeAlso: ['collection.get-in', 'contains?', 'find', 'nth'],\n examples: [\n '[1, 2, 3] get 1',\n '{ a: 1 } get \"a\"',\n '\"Albert\" get \"3\"',\n `\nget(\n [1, 2, 3],\n 1, // Optional comma after last argument\n)`,\n `\nget(\n [],\n 1\n)`,\n `\nget(\n [],\n 1,\n \"default\"\n)`,\n `\nget(\n { a: 1 },\n \"a\"\n)`,\n `\nget(\n { a: 1 },\n \"b\"\n)`,\n `\nget(\n { a: 1 },\n \"b\",\n \"default\"\n)`,\n `\nget(\n null,\n \"a\"\n)`,\n `\nget(\n null,\n \"b\",\n \"default\"\n)`,\n ],\n },\n },\n 'count': {\n evaluate: ([coll], sourceCodeInfo): number => {\n if (coll === null)\n return 0\n\n if (typeof coll === 'string')\n return coll.length\n\n assertColl(coll, sourceCodeInfo)\n if (Array.isArray(coll))\n return coll.length\n\n return Object.keys(coll).length\n },\n arity: toFixedArity(1),\n docs: {\n category: 'collection',\n returns: { type: 'number' },\n args: {\n coll: { type: ['collection', 'null'] },\n },\n variants: [{ argumentNames: ['coll'] }],\n description: 'Returns number of elements in $coll.',\n seeAlso: ['empty?'],\n examples: [\n 'count([1, 2, 3])',\n 'count([])',\n 'count({ a: 1 })',\n 'count(\"\")',\n 'count(\"Albert\")',\n 'count(null)',\n ],\n },\n },\n 'contains?': {\n evaluate: ([coll, key], sourceCodeInfo): boolean => {\n if (coll === null)\n return false\n\n assertColl(coll, sourceCodeInfo)\n if (isString(coll)) {\n assertString(key, sourceCodeInfo)\n return coll.includes(key)\n }\n if (isSeq(coll)) {\n assertAny(key, sourceCodeInfo)\n return !!coll.find(elem => deepEqual(asAny(elem), key, sourceCodeInfo))\n }\n assertString(key, sourceCodeInfo)\n return key in coll\n },\n arity: toFixedArity(2),\n docs: {\n category: 'collection',\n returns: { type: 'boolean' },\n args: {\n a: { type: ['collection', 'null'] },\n b: { type: ['string', 'integer'] },\n },\n variants: [{ argumentNames: ['a', 'b'] }],\n description: 'Returns `true` if $a contains $b, otherwise returns `false`. For strings, it checks if substring is included.',\n seeAlso: ['get', 'find', 'index-of'],\n examples: [\n '[1, 2, 3] contains? 1',\n 'null contains? 1',\n '{ a: 1, b: 2 } contains? \"a\"',\n `\ncontains?(\n [],\n 1\n)`,\n `\ncontains?(\n [1],\n 1\n)`,\n `\ncontains?(\n [1, 2, 3],\n 1\n)`,\n `\ncontains?(\n {},\n \"a\"\n)`,\n `\ncontains?(\n { a: 1, b: 2 },\n \"a\"\n)`,\n ],\n },\n },\n 'assoc': {\n evaluate: ([coll, key, value], sourceCodeInfo): Coll => {\n assertColl(coll, sourceCodeInfo)\n assertStringOrNumber(key, sourceCodeInfo)\n assertAny(value, sourceCodeInfo)\n return assoc(coll, key, value, sourceCodeInfo)\n },\n arity: toFixedArity(3),\n docs: {\n category: 'collection',\n returns: { type: 'collection' },\n args: {\n coll: { type: 'collection' },\n key: { type: ['string', 'number'] },\n value: { type: 'any' },\n kvs: { type: 'any', description: 'Key-value pairs to associate.', rest: true },\n },\n variants: [\n { argumentNames: ['coll', 'key', 'value'] },\n { argumentNames: ['coll', 'key', 'value', 'kvs'] },\n ],\n description: `\nAdd or replace the value of element $key to $value in $coll. Repeated for all key-value pairs in $kvs.\nIf $coll is an 'array', $key must be \\`number\\` satisfying \\`0 <=\\` $key \\`<= length\\`.`,\n seeAlso: ['collection.assoc-in', 'dissoc', 'merge', 'collection.update'],\n examples: [\n `\nassoc(\n [1, 2, 3],\n 1,\n \"Two\"\n)`,\n `\nassoc(\n [1, 2, 3],\n 3,\n \"Four\"\n)`,\n `\nassoc(\n { a: 1, b: 2 },\n \"a\",\n \"One\")`,\n `\nassoc(\n { a: 1, b: 2 },\n \"c\",\n \"Three\")`,\n `\nassoc(\n \"Albert\",\n 6,\n \"a\")`,\n ],\n },\n },\n '++': {\n evaluate: (params, sourceCodeInfo): Any => {\n if (!isNumber(params[0])) {\n assertColl(params[0], sourceCodeInfo)\n }\n if (Array.isArray(params[0])) {\n return params.reduce((result: Arr, arr) => {\n assertArray(arr, sourceCodeInfo)\n return result.concat(arr)\n }, [])\n }\n else if (isStringOrNumber(params[0])) {\n return params.reduce((result: string, s) => {\n assertStringOrNumber(s, sourceCodeInfo)\n return `${result}${s}`\n }, '')\n }\n else {\n return params.reduce((result: Obj, obj) => {\n assertObj(obj, sourceCodeInfo)\n return Object.assign(result, obj)\n }, {})\n }\n },\n arity: { min: 1 },\n docs: {\n category: 'collection',\n returns: { type: 'collection' },\n args: {\n a: { type: 'collection' },\n b: { type: 'collection' },\n colls: { type: 'collection', rest: true },\n },\n variants: [\n { argumentNames: ['a'] },\n { argumentNames: ['a', 'colls'] },\n ],\n description: 'Concatenates collections into one collection.',\n seeAlso: ['mapcat', 'str', 'join', 'push', 'sequence.unshift'],\n examples: [\n '\"Albert\" ++ \" \" ++ \"Mojir\"',\n '\"Albert\" ++ \"Mojir\"',\n\n '++(\"Albert\", \"-\", \"Mojir\")',\n '++(\"Albert\")',\n\n '++(\"A\", \"l\", \"b\", \"e\", \"r\", \"t\")',\n '++([1, 2], [3, 4])',\n '++([], [3, 4])',\n '++([1, 2], [])',\n '++([1, 2], [3, 4], [5, 6])',\n '++([])',\n '++({ a: 1, b: 2 }, { b: 1, c: 2 })',\n '++({}, { a: 1 })',\n ],\n },\n },\n}\n","import type { Arr } from '../../interface'\nimport { assertArray } from '../../typeGuards/array'\nimport { asNumber, assertNumber } from '../../typeGuards/number'\nimport type { BuiltinNormalExpressions } from '../interface'\nimport { assertFunctionLike } from '../../typeGuards/dvala'\nimport { toFixedArity } from '../../utils/arity'\nimport { chain, mapSequential } from '../../utils/maybePromise'\n\nexport const arrayNormalExpression: BuiltinNormalExpressions = {\n 'range': {\n evaluate: (params, sourceCodeInfo): Arr => {\n const [first, second, third] = params\n let from: number\n let to: number\n let step: number\n assertNumber(first, sourceCodeInfo, { finite: true })\n\n if (params.length === 1) {\n from = 0\n to = first\n step = to >= 0 ? 1 : -1\n }\n else if (params.length === 2) {\n assertNumber(second, sourceCodeInfo, { finite: true })\n from = first\n to = second\n step = to >= from ? 1 : -1\n }\n else {\n assertNumber(second, sourceCodeInfo, { finite: true })\n assertNumber(third, sourceCodeInfo, { finite: true })\n from = first\n to = second\n step = third\n if (to > from)\n assertNumber(step, sourceCodeInfo, { positive: true })\n else if (to < from)\n assertNumber(step, sourceCodeInfo, { negative: true })\n else\n assertNumber(step, sourceCodeInfo, { nonZero: true })\n }\n\n const result: number[] = []\n\n for (let i = from; step < 0 ? i > to : i < to; i += step)\n result.push(i)\n\n return result\n },\n arity: { min: 1, max: 3 },\n docs: {\n category: 'array',\n returns: { type: 'number', array: true },\n args: {\n a: { type: 'number' },\n b: { type: 'number' },\n step: { type: 'number' },\n },\n variants: [\n { argumentNames: ['b'] },\n { argumentNames: ['a', 'b'] },\n { argumentNames: ['a', 'b', 'step'] },\n ],\n description: `$range creates an array with a range of numbers from $a to $b (exclusive), by $step.\n\n$a defaults to 0.\n$step defaults to 1.`,\n seeAlso: ['repeat', 'vector.linspace'],\n examples: [\n 'range(4)',\n 'range(1, 4)',\n '1 range 10',\n 'range(0.4, 4.9)',\n `\nrange(\n 0.25, // start value\n 1, // end value (exclusive)\n 0.25, // step value\n)`,\n ],\n },\n },\n\n 'repeat': {\n evaluate: ([value, count], sourceCodeInfo): Arr => {\n assertNumber(count, sourceCodeInfo, { integer: true, nonNegative: true })\n const result: Arr = []\n for (let i = 0; i < count; i += 1)\n result.push(value)\n\n return result\n },\n arity: toFixedArity(2),\n docs: {\n category: 'array',\n returns: { type: 'any', array: true },\n args: {\n a: { type: 'any' },\n b: { type: 'integer' },\n },\n variants: [{ argumentNames: ['a', 'b'] }],\n description: 'Returns an array with $a repeated $b times.',\n seeAlso: ['range', 'string.string-repeat'],\n examples: [\n 'repeat(10, 3)',\n 'repeat(10, 0)',\n '\"Albert\" repeat 5',\n ],\n },\n },\n\n 'flatten': {\n evaluate: ([seq, depth], sourceCodeInfo): Arr => {\n assertArray(seq, sourceCodeInfo)\n\n const actualDepth = depth === undefined || depth === Number.POSITIVE_INFINITY\n ? Number.POSITIVE_INFINITY\n : asNumber(depth, sourceCodeInfo, { integer: true, nonNegative: true })\n\n return seq.flat(actualDepth)\n },\n arity: { min: 1, max: 2 },\n docs: {\n category: 'array',\n returns: { type: 'any', array: true },\n args: {\n x: { type: ['array', 'any'], description: 'If $x is not an array, `[ ]` is returned.' },\n },\n variants: [{ argumentNames: ['x'] }],\n description: 'Takes a nested array $x and flattens it.',\n seeAlso: ['mapcat'],\n examples: [\n 'flatten([1, 2, [3, 4], 5])',\n `\nlet foo = \"bar\";\nflatten([\n 1,\n \" 2 A \",\n [foo, [4, [\"ABC\"]]],\n 6,\n])`,\n ],\n hideOperatorForm: true,\n },\n },\n 'mapcat': {\n evaluate: ([arr, fn], sourceCodeInfo, contextStack, { executeFunction }) => {\n assertArray(arr, sourceCodeInfo)\n assertFunctionLike(fn, sourceCodeInfo)\n return chain(\n mapSequential(arr, elem => executeFunction(fn, [elem], contextStack, sourceCodeInfo)),\n mapped => mapped.flat(1),\n )\n },\n arity: toFixedArity(2),\n docs: {\n category: 'array',\n returns: { type: 'collection' },\n args: {\n a: { type: 'collection' },\n b: { type: 'function' },\n colls: { type: 'collection', array: true },\n fun: { type: 'function' },\n },\n variants: [{ argumentNames: ['colls', 'fun'] }],\n description: 'Returns the result of applying concat to the result of applying map to $fun and $colls.',\n seeAlso: ['flatten', 'map', '++'],\n examples: [\n '[[3, 2, 1, 0], [6, 5, 4], [9, 8, 7]] mapcat reverse',\n 'mapcat([[3, 2, 1, 0], [6, 5, 4], [9, 8, 7]], reverse)',\n '[[3, 2, 1, 0,], [6, 5, 4,], [9, 8, 7]] mapcat reverse',\n `\nlet foo = (n) -> do\n [n - 1, n, n + 1]\nend;\n[1, 2, 3] mapcat foo`,\n `\nmapcat(\n [[1, 2], [2, 2], [2, 3]],\n -> $ filter odd?\n)`,\n ],\n },\n },\n 'moving-fn': {\n evaluate: ([arr, windowSize, fn], sourceCodeInfo, contextStack, { executeFunction }) => {\n assertArray(arr, sourceCodeInfo)\n assertNumber(windowSize, sourceCodeInfo, { integer: true, lte: arr.length })\n assertFunctionLike(fn, sourceCodeInfo)\n\n const windows: Arr[] = []\n for (let i = 0; i <= arr.length - windowSize; i++) {\n windows.push(arr.slice(i, i + windowSize))\n }\n return mapSequential(windows, window => executeFunction(fn, [window], contextStack, sourceCodeInfo))\n },\n arity: toFixedArity(3),\n docs: {\n category: 'array',\n returns: { type: 'array' },\n args: {\n arr: { type: 'array' },\n windowSize: { type: 'number', description: 'The size of the moving window.' },\n fn: { type: 'function' },\n },\n variants: [{ argumentNames: ['arr', 'windowSize', 'fn'] }],\n description: 'Returns the result of applying $fn to each moving window of size $windowSize in $arr.',\n seeAlso: ['running-fn', 'vector.moving-mean'],\n examples: [\n 'moving-fn([1, 2, 3], 2, sum)',\n 'moving-fn([1, 2, 3], 1, sum)',\n 'moving-fn([1, 2, 3], 3, sum)',\n ],\n },\n },\n 'running-fn': {\n evaluate: ([arr, fn], sourceCodeInfo, contextStack, { executeFunction }) => {\n assertArray(arr, sourceCodeInfo)\n assertFunctionLike(fn, sourceCodeInfo)\n\n const subArrays: Arr[] = []\n for (let i = 0; i < arr.length; i += 1) {\n subArrays.push(arr.slice(0, i + 1))\n }\n return mapSequential(subArrays, subArr => executeFunction(fn, [subArr], contextStack, sourceCodeInfo))\n },\n arity: toFixedArity(2),\n docs: {\n category: 'array',\n returns: { type: 'array' },\n args: {\n a: { type: 'array' },\n b: { type: 'function' },\n },\n variants: [{ argumentNames: ['a', 'b'] }],\n description: 'Returns the result of applying $b to each element of $a.',\n seeAlso: ['moving-fn', 'vector.running-mean'],\n examples: [\n 'running-fn([1, 2, 3], sum)',\n 'running-fn([1, 2, 3], max)',\n 'running-fn([1, 2, 3], min)',\n ],\n },\n },\n}\n","import type { Any, Arr, Seq } from '../../interface'\nimport { assertCharArray } from '../../typeGuards/array'\nimport { asAny, assertAny, assertFunctionLike, assertSeq } from '../../typeGuards/dvala'\nimport { assertNumber } from '../../typeGuards/number'\nimport { assertString, assertStringOrNumber } from '../../typeGuards/string'\nimport { compare, deepEqual, toAny } from '../../utils'\nimport { toFixedArity } from '../../utils/arity'\nimport type { MaybePromise } from '../../utils/maybePromise'\nimport { chain, findIndexSequential, reduceSequential } from '../../utils/maybePromise'\nimport type { BuiltinNormalExpressions } from '../interface'\n\nexport const sequenceNormalExpression: BuiltinNormalExpressions = {\n 'nth': {\n evaluate: (params, sourceCodeInfo): Any => {\n const [seq, i] = params\n const defaultValue = toAny(params[2])\n\n assertNumber(i, sourceCodeInfo, { integer: true })\n\n if (seq === null)\n return defaultValue\n\n assertSeq(seq, sourceCodeInfo)\n if (i >= 0 && i < seq.length) {\n const result = toAny(seq[i])\n return result\n }\n else {\n return defaultValue\n }\n },\n arity: { min: 2, max: 3 },\n docs: {\n category: 'sequence',\n returns: { type: 'any' },\n args: {\n 'a': { type: 'sequence' },\n 'b': { type: 'integer' },\n 'seq': { type: ['sequence', 'null'] },\n 'n': { type: 'integer' },\n 'not-found': { type: 'any' },\n },\n variants: [\n { argumentNames: ['seq', 'n'] },\n { argumentNames: ['seq', 'n', 'not-found'] },\n ],\n description: 'Accesses element $n of $seq. Accessing out-of-bounds indices returns $not-found, if present, else `null`.',\n seeAlso: ['first', 'second', 'last', 'get', 'slice'],\n examples: [\n '[1, 2, 3] nth 1',\n '\"A string\" nth 3',\n 'nth([1, 2, 3], 1)',\n 'nth([1, 2, 3], 3)',\n 'nth([1, 2, 3], -1)',\n 'nth([1, 2, 3], 3, 99)',\n 'nth(\"A string\", 1)',\n 'nth(\"A string\", 3)',\n 'nth(\"A string\", -3)',\n 'nth(\"A string\", 30, \"X\")',\n 'nth(null, 1)',\n 'nth(null, 1, \"Default value\")',\n ],\n },\n },\n 'first': {\n evaluate: ([array], sourceCodeInfo): Any => {\n if (array === null)\n return null\n\n assertSeq(array, sourceCodeInfo)\n const result = toAny(array[0])\n\n return result\n },\n arity: toFixedArity(1),\n docs: {\n category: 'sequence',\n returns: { type: 'any' },\n args: { seq: { type: ['sequence', 'null'] } },\n variants: [{ argumentNames: ['seq'] }],\n description: 'Returns the first element of $seq. If $seq is empty or `null`, `null` is returned.',\n seeAlso: ['second', 'last', 'nth', 'rest', 'next'],\n examples: [\n 'first([\"Albert\", \"Mojir\", 160, [1, 2]])',\n 'first([])',\n 'first(null)',\n ],\n },\n },\n 'last': {\n evaluate: ([array], sourceCodeInfo): Any => {\n if (array === null)\n return null\n\n assertSeq(array, sourceCodeInfo)\n const result = toAny(array.at(-1))\n\n return result\n },\n arity: toFixedArity(1),\n docs: {\n category: 'sequence',\n returns: { type: 'any' },\n args: { seq: { type: ['sequence', 'null'] } },\n variants: [{ argumentNames: ['seq'] }],\n description: 'Returns the last element of $seq. If $seq is empty, `null` is returned.',\n seeAlso: ['first', 'second', 'nth', 'pop'],\n examples: [\n 'last([\"Albert\", \"Mojir\", 160, [1, 2]])',\n 'last([1, 2])',\n 'last([1])',\n 'last([])',\n 'last(null)',\n ],\n },\n },\n 'pop': {\n evaluate: ([seq], sourceCodeInfo): Seq => {\n assertSeq(seq, sourceCodeInfo)\n if (typeof seq === 'string') {\n return seq.substring(0, seq.length - 1)\n }\n\n return seq.slice(0, seq.length - 1)\n },\n arity: toFixedArity(1),\n docs: {\n category: 'sequence',\n returns: { type: ['sequence', 'null'], rest: true },\n args: { seq: { type: 'sequence' } },\n variants: [{ argumentNames: ['seq'] }],\n description: 'Returns a copy of $seq with last element removed. If $seq is empty `null` is returned.',\n seeAlso: ['push', 'last'],\n examples: [\n 'pop([1, 2, 3])',\n 'pop([])',\n ],\n },\n },\n 'index-of': {\n evaluate: ([seq, value], sourceCodeInfo): number | null => {\n assertAny(value, sourceCodeInfo)\n if (seq === null)\n return null\n\n assertSeq(seq, sourceCodeInfo)\n if (typeof seq === 'string') {\n assertString(value, sourceCodeInfo)\n const index = seq.indexOf(value)\n return index !== -1 ? index : null\n }\n else {\n const index = seq.findIndex(item => deepEqual(asAny(item, sourceCodeInfo), value), sourceCodeInfo)\n return index !== -1 ? index : null\n }\n },\n arity: toFixedArity(2),\n docs: {\n category: 'sequence',\n returns: { type: ['number', 'null'] },\n args: {\n a: { type: 'sequence' },\n b: { type: 'any' },\n seq: { type: ['sequence', 'null'] },\n x: { type: 'any' },\n },\n variants: [{ argumentNames: ['seq', 'x'] }],\n description: 'Returns the index of $x in $seq. If element is not present in $seq `null` is returned.',\n seeAlso: ['sequence.last-index-of', 'sequence.position', 'contains?'],\n examples: [\n '[[1], [2], [1], [2]] index-of [1]',\n 'index-of([\"Albert\", \"Mojir\", 160, [1, 2]], \"Mojir\")',\n 'index-of([5, 10, 15, 20], 15)',\n 'index-of([5, 10, 15, 20], 1)',\n 'index-of(null, 1)',\n ],\n },\n },\n 'push': {\n evaluate: ([seq, ...values], sourceCodeInfo): Seq => {\n assertSeq(seq, sourceCodeInfo)\n if (typeof seq === 'string') {\n assertCharArray(values, sourceCodeInfo)\n return [seq, ...values].join('')\n }\n else {\n return [...seq, ...values]\n }\n },\n arity: { min: 2 },\n docs: {\n category: 'sequence',\n returns: { type: 'sequence' },\n args: {\n a: { type: 'sequence' },\n b: { type: 'any' },\n seq: { type: 'sequence' },\n values: { type: 'any', rest: true, description: 'At least one.' },\n },\n variants: [{ argumentNames: ['seq', 'values'] }],\n description: 'Returns copy of $seq with $values added to the end of it.',\n seeAlso: ['sequence.unshift', 'pop', '++'],\n examples: [\n '[1, 2, 3] push 4',\n '\"Albert\" push \"!\"',\n 'push([1, 2, 3], 4)',\n 'push([1, 2, 3], 4, 5, 6)',\n `\nlet l = [1, 2, 3];\npush(l, 4);\nl`,\n ],\n },\n },\n 'rest': {\n evaluate: ([seq], sourceCodeInfo): Arr | string => {\n assertSeq(seq, sourceCodeInfo)\n if (Array.isArray(seq)) {\n if (seq.length <= 1)\n return []\n\n return seq.slice(1)\n }\n return seq.substring(1)\n },\n arity: toFixedArity(1),\n docs: {\n category: 'sequence',\n returns: { type: ['sequence', 'null'] },\n args: { seq: { type: 'sequence' } },\n variants: [{ argumentNames: ['seq'] }],\n description: `If $seq is an array, returns a new array with all but the first element from $seq.\nIf $seq has less than two elements, an empty array is returned.\nFor string $seq returns all but the first characters in $seq.`,\n seeAlso: ['next', 'first'],\n examples: [\n 'rest([\"Albert\", \"Mojir\", 160, [1, 2]])',\n 'rest([\"Albert\"])',\n 'rest([])',\n 'rest(\"Albert\")',\n 'rest(\"A\",)',\n 'rest(\"\")',\n ],\n },\n },\n 'next': {\n evaluate: ([seq], sourceCodeInfo): Arr | string | null => {\n assertSeq(seq, sourceCodeInfo)\n if (Array.isArray(seq)) {\n if (seq.length <= 1)\n return null\n\n return seq.slice(1)\n }\n if (seq.length <= 1)\n return null\n\n return seq.substring(1)\n },\n arity: toFixedArity(1),\n docs: {\n category: 'sequence',\n returns: { type: ['sequence', 'null'] },\n args: { seq: { type: 'sequence' } },\n variants: [{ argumentNames: ['seq'] }],\n description: 'If $seq is an array, returns a new array with all but the first element from $seq. If $seq has less than two elements, `null` is returned. For string $seq returns all but the first characters in $seq. If length of string $seq is less than two, `null` is returned.',\n seeAlso: ['rest', 'first'],\n examples: [\n 'next([\"Albert\", \"Mojir\", 160, [1, 2]])',\n 'next([\"Albert\"])',\n 'next([])',\n 'next(\"Albert\")',\n 'next(\"A\",)',\n 'next(\"\")',\n ],\n },\n },\n 'reverse': {\n evaluate: ([seq], sourceCodeInfo): Any => {\n if (seq === null)\n return null\n\n assertSeq(seq, sourceCodeInfo)\n if (Array.isArray(seq)) {\n return [...seq].reverse()\n }\n\n return seq.split('').reverse().join('')\n },\n arity: toFixedArity(1),\n docs: {\n category: 'sequence',\n returns: { type: ['sequence', 'null'] },\n args: { seq: { type: ['sequence', 'null'] } },\n variants: [{ argumentNames: ['seq'] }],\n description: 'If $seq is an array, creates a new array with the elements from $seq in reversed order. If $seq is a string, returns new reversed string.',\n seeAlso: ['sort'],\n examples: [\n 'reverse([\"Albert\", \"Mojir\", 160, [1, 2]])',\n 'reverse([])',\n 'reverse(\"Albert\")',\n 'reverse(null)',\n ],\n },\n },\n 'second': {\n evaluate: ([seq], sourceCodeInfo): Any => {\n if (seq === null)\n return null\n\n assertSeq(seq, sourceCodeInfo)\n return toAny(seq[1])\n },\n arity: toFixedArity(1),\n docs: {\n category: 'sequence',\n returns: { type: 'any' },\n args: { seq: { type: ['sequence', 'null'] } },\n variants: [{ argumentNames: ['seq'] }],\n description: 'Returns the second element of $seq. If $seq has less than two elements or is `null`, `null` is returned.',\n seeAlso: ['first', 'last', 'nth'],\n examples: [\n 'second([\"Albert\", \"Mojir\", 160, [1, 2]])',\n 'second([1])',\n 'second([])',\n 'second(null)',\n ],\n },\n },\n 'slice': {\n evaluate: (params, sourceCodeInfo): Any => {\n const [seq, from, to] = params\n assertSeq(seq, sourceCodeInfo)\n assertNumber(from, sourceCodeInfo, { integer: true })\n\n if (params.length === 2) {\n if (Array.isArray(seq)) {\n return seq.slice(from)\n }\n return seq.slice(from)\n }\n\n assertNumber(to, sourceCodeInfo, { integer: true })\n if (Array.isArray(seq)) {\n return seq.slice(from, to)\n }\n return seq.slice(from, to)\n },\n arity: { min: 2, max: 3 },\n docs: {\n category: 'sequence',\n returns: { type: 'sequence' },\n args: {\n a: { type: 'sequence' },\n b: { type: 'integer' },\n seq: { type: 'sequence', rest: true },\n start: { type: 'integer', description: 'Defaults to `0`.' },\n stop: { type: 'integer', description: 'Defaults lenght of sequence + 1.' },\n },\n variants: [\n { argumentNames: ['seq'] },\n { argumentNames: ['seq', 'start'] },\n { argumentNames: ['seq', 'start', 'stop'] },\n ],\n description: 'Returns a copy of a portion of $seq from index $start (inclusive) to $stop (exclusive).',\n seeAlso: ['take', 'drop', 'sequence.splice', 'nth'],\n examples: [\n '[1, 2, 3, 4, 5] slice 2',\n 'slice([1, 2, 3, 4, 5], 2, 4)',\n 'slice([1, 2, 3, 4, 5], 2)',\n ],\n },\n },\n 'some': {\n evaluate: ([seq, fn]: Arr, sourceCodeInfo, contextStack, { executeFunction }): MaybePromise<Any> => {\n assertFunctionLike(fn, sourceCodeInfo)\n if (seq === null)\n return null\n\n assertSeq(seq, sourceCodeInfo)\n\n if (seq.length === 0)\n return null\n\n const items = typeof seq === 'string' ? seq.split('') : seq\n return reduceSequential(\n items,\n (found: Any, elem) => {\n if (found !== null)\n return found\n return chain(executeFunction(fn, [elem], contextStack, sourceCodeInfo), (result) => {\n return result ? toAny(elem) : null\n })\n },\n null as Any,\n )\n },\n arity: toFixedArity(2),\n docs: {\n category: 'sequence',\n returns: { type: 'any' },\n args: {\n a: { type: 'sequence' },\n b: { type: 'function' },\n seq: { type: ['sequence', 'null'] },\n fun: { type: 'function' },\n },\n variants: [{ argumentNames: ['seq', 'fun'] }],\n description: 'Returns the first element that passes the test implemented by $fun. I no element was found, `null` is returned.',\n seeAlso: ['sequence.position', 'collection.any?', 'find'],\n examples: [\n `\nsome(\n [\"Albert\", \"Mojir\", 160, [1, 2]],\n string?\n)`,\n `\nsome(\n [5, 10, 15, 20],\n -> $ > 10\n)`,\n `\nsome(\n [1, 2, 3, 4],\n -> $ > 10\n)`,\n `\nsome(\n [],\n -> $ > 10\n)`,\n `\nsome(\n null,\n -> $ > 10\n)`,\n ],\n },\n },\n 'sort': {\n evaluate: (params: Arr, sourceCodeInfo, _contextStack, { executeFunction: _executeFunction }): Seq => {\n const [seq] = params\n const defaultComparer = params.length === 1\n const comparer = defaultComparer ? null : params[1]\n assertSeq(seq, sourceCodeInfo)\n\n if (typeof seq === 'string') {\n const result = seq.split('')\n if (defaultComparer) {\n result.sort((a, b) => compare(a, b, sourceCodeInfo))\n }\n else {\n assertFunctionLike(comparer, sourceCodeInfo)\n // Note: sort comparator must be synchronous — async comparators would need a different approach\n result.sort((a, b) => {\n const compareValue = _executeFunction(comparer, [a, b], _contextStack, sourceCodeInfo)\n if (compareValue instanceof Promise) {\n throw new TypeError('Async functions cannot be used as sort comparators')\n }\n assertNumber(compareValue, sourceCodeInfo, { finite: true })\n return compareValue\n })\n }\n return result.join('')\n }\n\n const result = [...seq]\n if (defaultComparer) {\n result.sort((a, b) => {\n assertStringOrNumber(a, sourceCodeInfo)\n assertStringOrNumber(b, sourceCodeInfo)\n return compare(a, b, sourceCodeInfo)\n })\n }\n else {\n result.sort((a, b) => {\n assertFunctionLike(comparer, sourceCodeInfo)\n // Note: sort comparator must be synchronous\n const compareValue = _executeFunction(comparer, [a, b], _contextStack, sourceCodeInfo)\n if (compareValue instanceof Promise) {\n throw new TypeError('Async functions cannot be used as sort comparators')\n }\n assertNumber(compareValue, sourceCodeInfo, { finite: true })\n return compareValue\n })\n }\n return result\n },\n arity: { min: 1, max: 2 },\n docs: {\n category: 'sequence',\n returns: { type: 'any', rest: true },\n args: {\n a: { type: 'sequence' },\n b: { type: 'function' },\n seq: { type: 'sequence' },\n fun: { type: 'function' },\n },\n variants: [\n { argumentNames: ['seq'] },\n { argumentNames: ['seq', 'fun'] },\n ],\n description: 'Returns a new sequence with the elements from $seq sorted according to $fun. If no $fun is supplied, builtin `compare` will be used.',\n seeAlso: ['sequence.sort-by', 'compare', 'reverse', 'vector.sort-indices'],\n examples: [\n '[3, 1, 2] sort (a, b) -> b - a',\n 'sort([3, 1, 2])',\n `\nsort(\n [3, 1, 2],\n (a, b) -> cond case a < b then -1 case a > b then 1 case true then -1 end\n)`,\n `\nsort(\n [3, 1, 2],\n (a, b) -> cond case a > b then -1 case a < b then 1 case true then -1 end\n)`,\n ],\n },\n },\n 'take': {\n evaluate: ([input, n], sourceCodeInfo): Seq => {\n assertNumber(n, sourceCodeInfo)\n assertSeq(input, sourceCodeInfo)\n const num = Math.max(Math.ceil(n), 0)\n return input.slice(0, num)\n },\n arity: toFixedArity(2),\n docs: {\n category: 'sequence',\n returns: { type: 'sequence' },\n args: {\n a: { type: 'sequence' },\n b: { type: 'integer' },\n n: { type: 'integer' },\n seq: { type: 'sequence' },\n },\n variants: [{ argumentNames: ['seq', 'n'] }],\n description: 'Constructs a new array/string with the $n first elements from $seq.',\n seeAlso: ['take-last', 'take-while', 'drop', 'slice', 'sequence.split-at'],\n examples: [\n 'take([1, 2, 3, 4, 5], 3)',\n '[1, 2, 3, 4, 5] take 3',\n 'take([1, 2, 3, 4, 5], 0)',\n 'take(\"Albert\", 2)',\n 'take(\"Albert\", 50)',\n ],\n },\n },\n 'take-last': {\n evaluate: ([array, n], sourceCodeInfo): Seq => {\n assertSeq(array, sourceCodeInfo)\n assertNumber(n, sourceCodeInfo)\n const num = Math.max(Math.ceil(n), 0)\n const from = array.length - num\n return array.slice(from)\n },\n arity: toFixedArity(2),\n docs: {\n category: 'sequence',\n returns: { type: 'sequence' },\n args: {\n a: { type: 'sequence' },\n b: { type: 'integer' },\n n: { type: 'integer' },\n seq: { type: 'sequence' },\n },\n variants: [{ argumentNames: ['seq', 'n'] }],\n description: 'Constructs a new array with the $n last elements from $seq.',\n seeAlso: ['take', 'drop-last'],\n examples: [\n 'take-last([1, 2, 3, 4, 5], 3)',\n '[1, 2, 3, 4, 5] take-last 3',\n 'take-last([1, 2, 3, 4, 5], 0)',\n ],\n },\n },\n 'drop': {\n evaluate: ([input, n], sourceCodeInfo): Seq => {\n assertNumber(n, sourceCodeInfo)\n const num = Math.max(Math.ceil(n), 0)\n assertSeq(input, sourceCodeInfo)\n return input.slice(num)\n },\n arity: toFixedArity(2),\n docs: {\n category: 'sequence',\n returns: { type: 'sequence' },\n args: {\n a: { type: 'sequence' },\n b: { type: 'integer' },\n seq: { type: 'sequence' },\n n: { type: 'integer' },\n },\n variants: [{ argumentNames: ['seq', 'n'] }],\n description: 'Constructs a new array/string with the $n first elements dropped from $seq.',\n seeAlso: ['drop-last', 'drop-while', 'take', 'slice', 'sequence.split-at'],\n examples: [\n 'drop([1, 2, 3, 4, 5], 3)',\n '[1, 2, 3, 4, 5] drop 0',\n 'drop(\"Albert\", 2)',\n 'drop(\"Albert\", 50)',\n ],\n },\n },\n 'drop-last': {\n evaluate: ([array, n], sourceCodeInfo): Seq => {\n assertSeq(array, sourceCodeInfo)\n assertNumber(n, sourceCodeInfo)\n const num = Math.max(Math.ceil(n), 0)\n const from = array.length - num\n return array.slice(0, from)\n },\n arity: toFixedArity(2),\n docs: {\n category: 'sequence',\n returns: { type: 'sequence' },\n args: {\n a: { type: 'sequence' },\n b: { type: 'integer' },\n seq: { type: 'sequence' },\n n: { type: 'integer' },\n },\n variants: [{ argumentNames: ['seq', 'n'] }],\n description: 'Constructs a new array with the $n last elements dropped from $seq.',\n seeAlso: ['drop', 'take-last'],\n examples: [\n 'drop-last([1, 2, 3, 4, 5], 3)',\n '[1, 2, 3, 4, 5] drop-last 3',\n 'drop-last([1, 2, 3, 4, 5], 0)',\n ],\n },\n },\n 'take-while': {\n evaluate: ([seq, fn]: Arr, sourceCodeInfo, contextStack, { executeFunction }): MaybePromise<Any> => {\n assertSeq(seq, sourceCodeInfo)\n assertFunctionLike(fn, sourceCodeInfo)\n\n const arr = typeof seq === 'string' ? seq.split('') : Array.from(seq)\n // Find the first index where the predicate is false\n return chain(\n findIndexSequential(arr, elem => chain(\n executeFunction(fn, [elem], contextStack, sourceCodeInfo),\n result => !result,\n )),\n (index) => {\n const taken = index === -1 ? arr : arr.slice(0, index)\n return typeof seq === 'string' ? taken.join('') : taken\n },\n )\n },\n arity: toFixedArity(2),\n docs: {\n category: 'sequence',\n returns: { type: 'sequence' },\n args: {\n a: { type: 'sequence' },\n b: { type: 'function' },\n seq: { type: 'sequence' },\n fun: { type: 'function' },\n },\n variants: [{ argumentNames: ['seq', 'fun'] }],\n description: 'Returns the members of $seq in order, stopping before the first one for which `predicate` returns a falsy value.',\n seeAlso: ['take', 'drop-while', 'sequence.split-with'],\n examples: [\n `take-while(\n [1, 2, 3, 2, 1],\n -> $ < 3\n)`,\n `take-while(\n [1, 2, 3, 2, 1],\n -> $ > 3\n)`,\n ],\n },\n },\n 'drop-while': {\n evaluate: ([seq, fn]: Arr, sourceCodeInfo, contextStack, { executeFunction }): MaybePromise<Any> => {\n assertSeq(seq, sourceCodeInfo)\n assertFunctionLike(fn, sourceCodeInfo)\n\n const arr = Array.isArray(seq) ? seq : seq.split('')\n return chain(\n findIndexSequential(arr, elem => chain(\n executeFunction(fn, [elem], contextStack, sourceCodeInfo),\n result => !result,\n )),\n (from) => {\n if (from === -1)\n return typeof seq === 'string' ? '' : []\n return typeof seq === 'string' ? arr.slice(from).join('') : seq.slice(from)\n },\n )\n },\n arity: toFixedArity(2),\n docs: {\n category: 'sequence',\n returns: { type: 'sequence' },\n args: {\n a: { type: 'sequence' },\n b: { type: 'function' },\n seq: { type: 'sequence' },\n fun: { type: 'function' },\n },\n variants: [{ argumentNames: ['seq', 'fun'] }],\n description: 'Returns the members of $seq in order, skipping the fist elements for witch the `predicate` returns a truethy value.',\n seeAlso: ['drop', 'take-while', 'sequence.split-with'],\n examples: [\n `drop-while(\n [1, 2, 3, 2, 1],\n -> $ < 3\n)`,\n `drop-while(\n [1, 2, 3, 2, 1],\n -> $ > 3\n)`,\n ],\n },\n },\n}\n","import { DvalaError } from '../errors'\nimport type { Any } from '../interface'\nimport type { SourceCodeInfo } from '../tokenizer/token'\nimport { isNumber } from './number'\n\nconst annotatedArrays = new WeakSet<unknown[]>()\nconst vectors = new WeakSet<unknown[]>()\nconst notVectors = new WeakSet<unknown[]>()\nconst matrices = new WeakSet<unknown[]>()\nconst notMatrices = new WeakSet<unknown[]>()\nconst grids = new WeakSet<unknown[]>()\nconst notGrids = new WeakSet<unknown[]>()\n\nexport function annotate<T>(value: T): T {\n if (!Array.isArray(value)) {\n return value\n }\n if (annotatedArrays.has(value)) {\n return value\n }\n isVector(value)\n if (!isMatrix(value)) {\n isGrid(value)\n }\n\n return value\n}\nexport function isVector(vector: unknown): vector is number[] {\n if (!Array.isArray(vector)) {\n return false\n }\n\n if (vectors.has(vector)) {\n return true\n }\n if (notVectors.has(vector)) {\n return false\n }\n\n if (vector.every(elem => isNumber(elem))) {\n annotatedArrays.add(vector)\n vectors.add(vector)\n return true\n }\n notVectors.add(vector)\n return false\n}\n\nexport function assertVector(vector: unknown, sourceCodeInfo: SourceCodeInfo | undefined): asserts vector is number[] {\n if (!isVector(vector)) {\n throw new DvalaError(`Expected a vector, but got ${vector}`, sourceCodeInfo)\n }\n}\n\nexport function is2dVector(vector: unknown): vector is [number, number] {\n if (!isVector(vector)) {\n return false\n }\n return vector.length === 2\n}\nexport function assert2dVector(vector: unknown, sourceCodeInfo: SourceCodeInfo | undefined): asserts vector is [number, number] {\n if (!is2dVector(vector)) {\n throw new DvalaError(`Expected a 2d vector, but got ${vector}`, sourceCodeInfo)\n }\n}\n\nexport function is3dVector(vector: unknown): vector is [number, number, number] {\n if (!isVector(vector)) {\n return false\n }\n return vector.length === 3\n}\nexport function assert3dVector(vector: unknown, sourceCodeInfo: SourceCodeInfo | undefined): asserts vector is [number, number, number] {\n if (!is3dVector(vector)) {\n throw new DvalaError(`Expected a 3d vector, but got ${vector}`, sourceCodeInfo)\n }\n}\n\nexport function assertNonEmptyVector(vector: unknown, sourceCodeInfo: SourceCodeInfo | undefined): asserts vector is number[] {\n assertVector(vector, sourceCodeInfo)\n if (vector.length === 0) {\n throw new DvalaError(`Expected a non empty vector, but got ${vector}`, sourceCodeInfo)\n }\n}\n\nexport function isGrid(grid: unknown): grid is unknown[][] {\n if (!Array.isArray(grid)) {\n return false\n }\n if (grids.has(grid)) {\n return true\n }\n if (notGrids.has(grid)) {\n return false\n }\n if (grid.length === 0) {\n notGrids.add(grid)\n return false\n }\n if (!Array.isArray(grid[0])) {\n notGrids.add(grid)\n return false\n }\n const nbrOfCols = grid[0].length\n for (const row of grid.slice(1)) {\n if (!Array.isArray(row)) {\n notGrids.add(grid)\n return false\n }\n if (row.length !== nbrOfCols) {\n notGrids.add(grid)\n return false\n }\n }\n annotatedArrays.add(grid)\n grids.add(grid)\n return true\n}\n\nexport function assertGrid(grid: unknown, sourceCodeInfo: SourceCodeInfo | undefined): asserts grid is Any[][] {\n if (!isGrid(grid)) {\n throw new DvalaError(`Expected a grid, but got ${grid}`, sourceCodeInfo)\n }\n}\n\nexport function isMatrix(matrix: unknown): matrix is number[][] {\n if (!Array.isArray(matrix)) {\n return false\n }\n if (matrices.has(matrix)) {\n return true\n }\n if (notMatrices.has(matrix)) {\n return false\n }\n if (matrix.length === 0) {\n notMatrices.add(matrix)\n return false\n }\n if (!Array.isArray(matrix[0]) || matrix[0].length === 0) {\n notMatrices.add(matrix)\n return false\n }\n const nbrOfCols = matrix[0].length\n for (const row of matrix) {\n if (!Array.isArray(row) || row.length !== nbrOfCols || row.some(cell => !isNumber(cell))) {\n notMatrices.add(matrix)\n return false\n }\n }\n annotatedArrays.add(matrix)\n grids.add(matrix)\n matrices.add(matrix)\n return true\n}\n\nexport function assertMatrix(matrix: unknown, sourceCodeInfo: SourceCodeInfo | undefined): asserts matrix is number[][] {\n if (!isMatrix(matrix)) {\n throw new DvalaError(`Expected a matrix, but got ${matrix}`, sourceCodeInfo)\n }\n}\n\nexport function assertSquareMatrix(matrix: unknown, sourceCodeInfo: SourceCodeInfo | undefined): asserts matrix is number[][] {\n if (!isMatrix(matrix)) {\n throw new DvalaError(`Expected a matrix, but got ${matrix}`, sourceCodeInfo)\n }\n if (matrix.length !== matrix[0]!.length) {\n throw new DvalaError(`Expected square matrix, but got ${matrix.length} and ${matrix[0]!.length}`, sourceCodeInfo)\n }\n}\n\nexport function isSquareMatrix(matrix: unknown): matrix is number[][] {\n if (!isMatrix(matrix)) {\n return false\n }\n if (matrix.length !== matrix[0]!.length) {\n return false\n }\n return true\n}\n","import { DvalaError } from '../../errors'\nimport type { SourceCodeInfo } from '../../tokenizer/token'\nimport { assertNonEmptyVector, isMatrix, isVector } from '../../typeGuards/annotatedArrays'\nimport { assertNumber, isNumber } from '../../typeGuards/number'\nimport { toFixedArity } from '../../utils/arity'\nimport type { BuiltinNormalExpressions } from '../interface'\n\ntype NumberVectorOrMatrix = number | number[] | number[][]\n\nfunction getNumberVectorOrMatrixOperation(\n params: unknown[],\n sourceCodeInfo: SourceCodeInfo | undefined,\n):\n | ['number', number[]]\n | ['vector', number[][]]\n | ['matrix', number[][][]] {\n let hasVector: boolean = false\n let hasMatrix: boolean = false\n for (const param of params) {\n if (isVector(param)) {\n hasVector = true\n }\n else if (isMatrix(param)) {\n hasMatrix = true\n }\n else if (!isNumber(param)) {\n throw new DvalaError(`Invalid parameter type: ${typeof param}`, sourceCodeInfo)\n }\n }\n if (hasMatrix) {\n if (hasVector) {\n throw new DvalaError('Cannot mix vector and matrix types', sourceCodeInfo)\n }\n let rows: number | null = null\n let cold: number | null = null\n for (const param of params) {\n if (isMatrix(param)) {\n if (rows === null) {\n rows = param.length\n cold = param[0]!.length\n }\n else {\n if (param.length !== rows || param[0]!.length !== cold) {\n throw new DvalaError('Matrix dimensions do not match', sourceCodeInfo)\n }\n }\n }\n }\n const matrices = params.map((param) => {\n if (isMatrix(param)) {\n return param\n }\n return Array.from({ length: rows as number }, () => Array.from({ length: cold as number }, () => param as number))\n })\n return ['matrix', matrices]\n }\n if (hasVector) {\n let length: number | null = null\n for (const param of params) {\n if (isVector(param)) {\n if (length === null) {\n length = param.length\n }\n else {\n if (param.length !== length) {\n throw new DvalaError('Vector lengths do not match', sourceCodeInfo)\n }\n }\n }\n }\n const vectors = params.map((param) => {\n if (isVector(param)) {\n return param\n }\n return Array.from({ length: length as number }, () => param as number)\n })\n\n return ['vector', vectors]\n }\n return ['number', params as number[]]\n}\n\nfunction unaryMathOp(\n fn: (val: number) => number,\n): (params: unknown[], sourceCodeInfo: SourceCodeInfo | undefined) => NumberVectorOrMatrix {\n return (params, sourceCodeInfo) => {\n const [operation, operands] = getNumberVectorOrMatrixOperation(params, sourceCodeInfo)\n if (operation === 'number') {\n return fn(operands[0]!)\n }\n else if (operation === 'vector') {\n return operands[0]!.map(val => fn(val))\n }\n else {\n return operands[0]!.map(row => row.map(val => fn(val)))\n }\n }\n}\n\nfunction binaryMathOp(\n fn: (a: number, b: number) => number,\n): (params: unknown[], sourceCodeInfo: SourceCodeInfo | undefined) => NumberVectorOrMatrix {\n return (params, sourceCodeInfo) => {\n const [operation, operands] = getNumberVectorOrMatrixOperation(params, sourceCodeInfo)\n if (operation === 'number') {\n return fn(operands[0]!, operands[1]!)\n }\n else if (operation === 'vector') {\n return operands[0]!.map((val, i) => fn(val, operands[1]![i]!))\n }\n else {\n return operands[0]!.map((row, i) => row.map((val, j) => fn(val, operands[1]![i]![j]!)))\n }\n }\n}\n\nfunction reduceMathOp(\n identity: number,\n fn: (a: number, b: number) => number,\n): (params: unknown[], sourceCodeInfo: SourceCodeInfo | undefined) => NumberVectorOrMatrix {\n return (params, sourceCodeInfo) => {\n if (params.length === 0)\n return identity\n const [operation, operands] = getNumberVectorOrMatrixOperation(params, sourceCodeInfo)\n if (operation === 'number') {\n return operands.reduce((a, b) => fn(a, b), identity)\n }\n else if (operation === 'vector') {\n const [first, ...rest] = operands\n return rest.reduce((acc, v) => acc.map((val, i) => fn(val, v[i]!)), first!)\n }\n else {\n const [first, ...rest] = operands\n return rest.reduce((acc, m) => acc.map((row, i) => row.map((val, j) => fn(val, m[i]![j]!))), first!)\n }\n }\n}\n\nexport const mathNormalExpression: BuiltinNormalExpressions = {\n 'inc': {\n evaluate: unaryMathOp(val => val + 1),\n arity: toFixedArity(1),\n docs: {\n category: 'math',\n returns: { type: 'number' },\n args: {\n x: { type: ['number', 'vector', 'matrix'] },\n },\n variants: [{ argumentNames: ['x'] }],\n description: 'The `inc` function increments its argument by 1, working on `numbers` and element-wise on `vectors` and `matrices`. When applied to collections, it increases each element by 1 while preserving the original structure.',\n seeAlso: ['dec', '+'],\n examples: [\n 'inc(0)',\n 'inc(1)',\n 'inc(100.1)',\n 'inc([1, 2, 3])',\n 'inc([[1, 2], [3, 4]])',\n ],\n },\n },\n 'dec': {\n evaluate: unaryMathOp(val => val - 1),\n arity: toFixedArity(1),\n docs: {\n category: 'math',\n returns: { type: ['number', 'vector', 'matrix'] },\n args: {\n x: { type: ['number', 'vector', 'matrix'] },\n },\n variants: [{ argumentNames: ['x'] }],\n description: 'The `dec` function decrements its argument by 1, working on `numbers` and element-wise on `vectors` and `matrices`. When applied to collections, it decreases each element by 1 while preserving the original structure.',\n seeAlso: ['inc', '-'],\n examples: [\n 'dec(0)',\n 'dec(1)',\n 'dec(100.1)',\n 'dec([1, 2, 3])',\n 'dec([[1, 2], [3, 4]])',\n ],\n },\n },\n '+': {\n evaluate: reduceMathOp(0, (a, b) => a + b),\n arity: {},\n docs: {\n category: 'math',\n returns: { type: ['number', 'vector', 'matrix'] },\n args: {\n a: { type: ['number', 'vector', 'matrix'] },\n b: { type: ['number', 'vector', 'matrix'] },\n xs: { type: ['number', 'vector', 'matrix'], rest: true },\n },\n variants: [{ argumentNames: ['xs'] }],\n description: 'The `+` function performs addition of numbers and element-wise addition of `vectors` and `matrices` of compatible dimensions, returning the same type as its inputs. When used with mixed types, it adds the scalar to each element of the collection.',\n seeAlso: ['-', '*', '/', 'inc'],\n examples: [\n '1 + 2',\n '1 + 20 + 30',\n '+(1, 2, 3, 4)',\n '+()',\n '+(1)',\n '[1, 2, 3] + 2',\n '[1, 2, 3] + [4, 5, 6]',\n '[[1, 2, 3], [4, 5, 6]] + [[7, 8, 9], [10, 11, 12]]',\n '[[1, 2, 3], [4, 5, 6]] + 2',\n ],\n },\n },\n '*': {\n evaluate: reduceMathOp(1, (a, b) => a * b),\n arity: {},\n docs: {\n category: 'math',\n returns: { type: ['number', 'vector', 'matrix'] },\n args: {\n a: { type: ['number', 'vector', 'matrix'] },\n b: { type: ['number', 'vector', 'matrix'] },\n xs: { type: ['number', 'vector', 'matrix'], rest: true },\n },\n variants: [{ argumentNames: ['xs'] }],\n description: 'The `*` function performs multiplication of `numbers` and element-wise multiplication of `vectors` and `matrices` of compatible dimensions, returning the same type as its inputs. When used with mixed types, it multiplies each element of the collection by the scalar.',\n seeAlso: ['/', '+', '-', '^'],\n examples: [\n '6 * 7',\n '-1 * 4',\n '*(4, 7)',\n '*(1, 2, 3, 4, 5)',\n '*()',\n '*(8)',\n '[1, 2, 3] * 2',\n '[1, 2, 3] * [4, 5, 6]',\n '[[1, 2, 3], [4, 5, 6]] * [[7, 8, 9], [10, 11, 12]]',\n '[[1, 2, 3], [4, 5, 6]] * 2',\n ],\n },\n },\n '/': {\n evaluate: (params, sourceCodeInfo): NumberVectorOrMatrix => {\n if (params.length === 0) {\n return 1\n }\n\n const [operation, operands] = getNumberVectorOrMatrixOperation(params, sourceCodeInfo)\n\n if (operation === 'number') {\n const [first, ...rest] = operands\n if (rest.length === 0) {\n return 1 / first!\n }\n return rest.reduce((result, param) => {\n return result / param\n }, first!)\n }\n else if (operation === 'vector') {\n const firstVector = operands[0]!\n const restVectors = operands.slice(1)\n return restVectors.reduce((acc, vector) => acc.map((val, i) => val / vector[i]!), firstVector)\n }\n else {\n const firstMatrix = operands[0]!\n const restMatrices = operands.slice(1)\n return restMatrices.reduce((acc, matrix) => acc.map((row, i) => row.map((val, j) => val / matrix[i]![j]!)), firstMatrix)\n }\n },\n arity: {},\n docs: {\n category: 'math',\n returns: { type: ['number', 'vector', 'matrix'] },\n args: {\n a: { type: ['number', 'vector', 'matrix'] },\n b: { type: ['number', 'vector', 'matrix'] },\n xs: { type: ['number', 'vector', 'matrix'], rest: true },\n },\n variants: [{ argumentNames: ['xs'] }],\n description: 'The `/` function performs division of `numbers` and element-wise division of `vectors` and `matrices` of compatible dimensions, returning the same type as its inputs. When used with mixed types, it divides each element of the collection by the scalar.',\n seeAlso: ['*', '+', '-', 'quot', 'mod', '%'],\n examples: [\n '12 / 100',\n '-1 / 4',\n '/(7, 4)',\n '/(1, 2, 4, 8)',\n '/()',\n '/(8)',\n '[1, 2, 3] / 2',\n '[1, 2, 3] / [4, 5, 6]',\n '[[1, 2, 3], [4, 5, 6]] / [[7, 8, 9], [10, 11, 12]]',\n '[[1, 2, 3], [4, 5, 6]] / 2',\n ],\n },\n },\n '-': {\n evaluate: (params, sourceCodeInfo): NumberVectorOrMatrix => {\n if (params.length === 0) {\n return 0\n }\n\n const [operation, operands] = getNumberVectorOrMatrixOperation(params, sourceCodeInfo)\n\n if (operation === 'number') {\n const [first, ...rest] = operands\n if (rest.length === 0)\n return -first!\n\n return rest.reduce((result, param) => {\n return result - param\n }, first!)\n }\n else if (operation === 'vector') {\n const firstVector = operands[0]!\n const restVectors = operands.slice(1)\n return restVectors.reduce((acc, vector) => acc.map((val, i) => val - vector[i]!), firstVector)\n }\n else {\n const firstMatrix = operands[0]!\n const restMatrices = operands.slice(1)\n return restMatrices.reduce((acc, matrix) => acc.map((row, i) => row.map((val, j) => val - matrix[i]![j]!)), firstMatrix)\n }\n },\n arity: {},\n docs: {\n category: 'math',\n returns: { type: ['number', 'vector', 'matrix'] },\n args: {\n a: { type: ['number', 'vector', 'matrix'] },\n b: { type: ['number', 'vector', 'matrix'] },\n xs: { type: ['number', 'vector', 'matrix'], rest: true },\n },\n variants: [{ argumentNames: ['xs'] }],\n description: 'Computes difference between first value and sum of the rest. When called with only one argument, it does negation.',\n seeAlso: ['+', '*', '/', 'dec', 'abs'],\n examples: [\n '50 - 8',\n '1 - 1 - 1',\n '-()',\n '-(4, 2)',\n '-(4, 3, 2, 1,)',\n '[1, 2, 3] - 2',\n '[1, 2, 3] - [4, 5, 6]',\n '[[1, 2, 3], [4, 5, 6]] - [[7, 8, 9], [10, 11, 12]]',\n '[[1, 2, 3], [4, 5, 6]] - 2',\n ],\n },\n },\n 'quot': {\n evaluate: binaryMathOp((a, b) => Math.trunc(a / b)),\n arity: toFixedArity(2),\n docs: {\n category: 'math',\n returns: { type: ['number', 'vector', 'matrix'] },\n args: {\n a: { type: ['number', 'vector', 'matrix'] },\n b: { type: ['number', 'vector', 'matrix'] },\n },\n variants: [{ argumentNames: ['a', 'b'] }],\n description: 'The `quot` function performs integer division truncated toward zero, working on `numbers` and element-wise on `vectors` and `matrices` of compatible dimensions. When used with mixed types, it applies integer division between each element of the collection and the scalar.',\n seeAlso: ['mod', '%', '/', 'trunc'],\n examples: [\n 'quot(5, 3)',\n 'quot(5.2, 3.1)',\n 'quot(-5, 3)',\n '5 quot -3',\n '-5 quot -3',\n 'quot(5, 0)',\n 'quot(0, 5)',\n '[1, 2, 3] quot 2',\n '2 quot [1, 2, 3]',\n 'quot([1, 2, 3], [4, 5, 6])',\n '[[1, 2, 3], [4, 5, 6]] quot [[7, 8, 9], [10, 11, 12]]',\n 'quot([[1, 2, 3], [4, 5, 6]], 2)',\n '[[1, 2, 3], [4, 5, 6]] quot [[7, 8, 9], [10, 11, 12]]',\n ],\n },\n },\n 'mod': {\n evaluate: binaryMathOp((a, b) => a - b * Math.floor(a / b)),\n arity: toFixedArity(2),\n docs: {\n category: 'math',\n returns: { type: ['number', 'vector', 'matrix'] },\n args: {\n a: { type: ['number', 'vector', 'matrix'] },\n b: { type: ['number', 'vector', 'matrix'] },\n },\n variants: [{ argumentNames: ['a', 'b'] }],\n description: 'The `mod` function computes the modulo of division with the same sign as the divisor, working on `numbers` and element-wise on `vectors` and `matrices` of compatible dimensions. When used with mixed types, it applies the modulo operation between each element of the collection and the scalar.',\n seeAlso: ['%', 'quot', '/'],\n examples: [\n 'mod(5, 3)',\n 'mod(5.2, 3.1)',\n 'mod(-5, 3)',\n '5 mod -3',\n '-5 mod -3',\n '[1, 2, 3] mod 2',\n '2 mod [1, 2, 3]',\n 'mod([1, 2, 3], [4, 5, 6])',\n '[[1, 2, 3], [4, 5, 6]] mod [[7, 8, 9], [10, 11, 12]]',\n 'mod([[1, 2, 3], [4, 5, 6]], 2)',\n ],\n },\n },\n '%': {\n evaluate: binaryMathOp((a, b) => a % b),\n arity: toFixedArity(2),\n docs: {\n category: 'math',\n returns: { type: ['number', 'vector', 'matrix'] },\n args: {\n a: { type: ['number', 'vector', 'matrix'] },\n b: { type: ['number', 'vector', 'matrix'] },\n },\n variants: [{ argumentNames: ['a', 'b'] }],\n description: 'The `%` function computes the remainder of division with the same sign as the dividend, working on `numbers` and element-wise on `vectors` and `matrices` of compatible dimensions. When used with mixed types, it applies the remainder operation between each element of the collection and the scalar.',\n seeAlso: ['mod', 'quot', '/'],\n examples: [\n '5 % 3',\n '5.2 % 3.1',\n '-5 % 3',\n '%(5, -3)',\n '%(-5, -3)',\n '[1, 2, 3] % 2',\n '2 % [1, 2, 3]',\n '%([1, 2, 3], [4, 5, 6])',\n '[[1, 2, 3], [4, 5, 6]] % [[7, 8, 9], [10, 11, 12]]',\n '%([[1, 2, 3], [4, 5, 6]], 2)',\n ],\n },\n },\n 'sqrt': {\n evaluate: unaryMathOp(val => Math.sqrt(val)),\n arity: toFixedArity(1),\n docs: {\n category: 'math',\n returns: { type: ['number', 'vector', 'matrix'] },\n args: {\n x: { type: ['number', 'vector', 'matrix'] },\n },\n variants: [{ argumentNames: ['x'] }],\n description: 'The `sqrt` function calculates the square root of `numbers` and computes element-wise square roots of `vectors` and `matrices`. When applied to collections, it returns the square root of each element while preserving the original structure.',\n seeAlso: ['cbrt', '^'],\n examples: [\n 'sqrt(0)',\n 'sqrt(9)',\n 'sqrt(2)',\n 'sqrt(0)',\n 'sqrt(9)',\n 'sqrt(2)',\n 'sqrt([1, 4, 9])',\n 'sqrt([[1, 4], [9, 16]])',\n ],\n },\n },\n 'cbrt': {\n evaluate: unaryMathOp(val => Math.cbrt(val)),\n arity: toFixedArity(1),\n docs: {\n category: 'math',\n returns: { type: ['number', 'vector', 'matrix'] },\n args: {\n x: { type: ['number', 'vector', 'matrix'] },\n },\n variants: [{ argumentNames: ['x'] }],\n description: 'The `cbrt` function calculates the cube root of `numbers` and computes element-wise cube roots of `vectors` and `matrices`. When applied to collections, it returns the cube root of each element while preserving the original structure.',\n seeAlso: ['sqrt', '^'],\n examples: [\n 'cbrt(0)',\n 'cbrt(27)',\n 'cbrt(2)',\n 'cbrt(1)',\n 'cbrt(0)',\n 'cbrt(27)',\n 'cbrt(2)',\n 'cbrt(1)',\n 'cbrt([1, 8, 27])',\n 'cbrt([[1, 8], [27, 64]])',\n ],\n },\n },\n '^': {\n evaluate: binaryMathOp((a, b) => a ** b),\n arity: toFixedArity(2),\n docs: {\n category: 'math',\n returns: { type: ['number', 'vector', 'matrix'] },\n args: {\n a: { type: ['number', 'vector', 'matrix'] },\n b: { type: ['number', 'vector', 'matrix'] },\n },\n variants: [{ argumentNames: ['a', 'b'] }],\n description: 'The ^ function computes exponentiation, raising the first argument to the power of the second, working on `numbers` and element-wise on `vectors` and `matrices` of compatible dimensions. When used with mixed types, it applies the power operation between each element of the collection and the scalar.',\n seeAlso: ['sqrt', 'cbrt', '*', 'math.ln'],\n examples: [\n '2 ^ 3',\n '2 ^ 0',\n '2 ^ -3',\n '^(-2, 3)',\n '^(-2, -3)',\n '[1, 2, 3] ^ 2',\n '2 ^ [1, 2, 3]',\n '^([1, 2, 3], [4, 5, 6])',\n '[[1, 2, 3], [4, 5, 6]] ^ [[7, 8, 9], [10, 11, 12]]',\n '^([[1, 2, 3], [4, 5, 6]], 2)',\n ],\n },\n },\n 'round': {\n evaluate: ([value, decimals], sourceCodeInfo): NumberVectorOrMatrix => {\n const [operation, operands] = getNumberVectorOrMatrixOperation([value], sourceCodeInfo)\n if (operation === 'number') {\n if (decimals === undefined || decimals === 0) {\n return Math.round(operands[0]!)\n }\n else {\n assertNumber(decimals, sourceCodeInfo, { integer: true, positive: true })\n const factor = 10 ** decimals\n return Math.round(operands[0]! * factor) / factor\n }\n }\n else if (operation === 'vector') {\n const vector = operands[0]!\n if (decimals === undefined || decimals === 0) {\n return vector.map(val => Math.round(val))\n }\n else {\n assertNumber(decimals, sourceCodeInfo, { integer: true, positive: true })\n const factor = 10 ** decimals\n return vector.map(val => Math.round(val * factor) / factor)\n }\n }\n else {\n const matrix = operands[0]!\n if (decimals === undefined || decimals === 0) {\n return matrix.map(row => row.map(val => Math.round(val)))\n }\n else {\n assertNumber(decimals, sourceCodeInfo, { integer: true, positive: true })\n const factor = 10 ** decimals\n return matrix.map(row => row.map(val => Math.round(val * factor) / factor))\n }\n }\n },\n arity: { min: 1, max: 2 },\n docs: {\n category: 'math',\n returns: { type: ['number', 'vector', 'matrix'] },\n args: {\n a: { type: ['number', 'vector', 'matrix'] },\n b: { type: 'integer' },\n },\n variants: [\n { argumentNames: ['a'] },\n { argumentNames: ['a', 'b'] },\n ],\n description: 'The `round` function rounds a `number` to the nearest `integer` or to a specified number of `decimal` places, working on `numbers` and element-wise on `vectors` and `matrices`. When applied to collections, it rounds each element while preserving the original structure.',\n seeAlso: ['floor', 'ceil', 'trunc'],\n examples: [\n 'round(2)',\n 'round(2.49)',\n 'round(2.5)',\n 'round(-2.49)',\n 'round(-2.5)',\n 'round(-2.501)',\n 'round(1.23456789, 4)',\n '1.123456789 round 2',\n 'round([1.23456789, 2.3456789], 1)',\n '[1.23456789, 2.3456789] round 4',\n '[[1.23456789, 2.3456789], [3.456789, 4.56789]] round 4',\n 'round([[1.23456789, 2.3456789], [3.456789, 4.56789]], 2)',\n ],\n },\n },\n 'trunc': {\n evaluate: unaryMathOp(val => Math.trunc(val)),\n arity: toFixedArity(1),\n docs: {\n category: 'math',\n returns: { type: ['integer', 'vector', 'matrix'] },\n args: {\n x: { type: ['number', 'vector', 'matrix'] },\n },\n variants: [{ argumentNames: ['x'] }],\n description: 'The `trunc` function truncates `numbers` toward zero (removing decimal portions without rounding), working on `numbers` and element-wise on `vectors` and `matrices`. When applied to collections, it truncates each element while preserving the original structure.',\n seeAlso: ['round', 'floor', 'ceil', 'quot'],\n examples: [\n 'trunc(2)',\n 'trunc(2.49)',\n 'trunc(2.5)',\n 'trunc(-2.49)',\n 'trunc(-2.5)',\n 'trunc(-2.501)',\n 'trunc([1.23456789, 2.3456789])',\n 'trunc([[1.23456789, 2.3456789], [3.456789, 4.56789]])',\n ],\n },\n },\n 'floor': {\n evaluate: unaryMathOp(val => Math.floor(val)),\n arity: toFixedArity(1),\n docs: {\n category: 'math',\n returns: { type: ['integer', 'vector', 'matrix'] },\n args: {\n x: { type: ['number', 'vector', 'matrix'] },\n },\n variants: [{ argumentNames: ['x'] }],\n description: 'The `floor` function returns the largest `integer` less than or equal to a `number`, working on `numbers` and element-wise on `vectors` and `matrices`. When applied to collections, it returns the floor of each element while preserving the original structure.',\n seeAlso: ['ceil', 'round', 'trunc'],\n examples: [\n 'floor(2)',\n 'floor(2.49)',\n 'floor(2.5)',\n 'floor(-2.49)',\n 'floor(-2.5)',\n 'floor(-2.501)',\n 'floor([1.23456789, 2.3456789])',\n 'floor([[1.23456789, 2.3456789], [3.456789, 4.56789]])',\n ],\n },\n },\n 'ceil': {\n evaluate: unaryMathOp(val => Math.ceil(val)),\n arity: toFixedArity(1),\n docs: {\n category: 'math',\n returns: { type: ['integer', 'vector', 'matrix'] },\n args: {\n x: { type: ['number', 'vector', 'matrix'] },\n },\n variants: [{ argumentNames: ['x'] }],\n description: 'The `ceil` function returns the smallest `integer` greater than or equal to a `number`, working on `numbers` and element-wise on `vectors` and `matrices`. When applied to collections, it returns the ceiling of each element while preserving the original structure.',\n seeAlso: ['floor', 'round', 'trunc'],\n examples: [\n 'ceil(2)',\n 'ceil(2.49)',\n 'ceil(2.5)',\n 'ceil(-2.49)',\n 'ceil(-2.5)',\n 'ceil(-2.501)',\n 'ceil([1.23456789, 2.3456789])',\n 'ceil([[1.23456789, 2.3456789], [3.456789, 4.56789]])',\n ],\n },\n },\n 'min': {\n evaluate: (params, sourceCodeInfo): number => {\n if (params.length === 1 && isVector(params[0])) {\n const vector = params[0]\n assertNonEmptyVector(vector, sourceCodeInfo)\n return vector.reduce((m, val) => Math.min(m, val), Infinity)\n }\n const [first, ...rest] = params\n assertNumber(first, sourceCodeInfo)\n return rest.reduce((m: number, value) => {\n assertNumber(value, sourceCodeInfo)\n return Math.min(m, value)\n }, first)\n },\n arity: { min: 1 },\n docs: {\n category: 'math',\n returns: { type: 'number' },\n args: {\n a: { type: 'number' },\n b: { type: 'number' },\n xs: { type: 'number', rest: true },\n vector: { type: 'vector' },\n },\n variants: [\n { argumentNames: ['xs'] },\n { argumentNames: ['vector'] },\n ],\n description: 'Returns the smallest value. Accepts either multiple numbers or a single vector of numbers.',\n seeAlso: ['max', 'vector.span', 'vector.min-index'],\n examples: [\n '2 min 3',\n 'min(2, 0, 1)',\n 'min(2, -1, 1)',\n 'min([2, 0, -1])',\n '12 min 14',\n ],\n },\n },\n 'max': {\n evaluate: (params, sourceCodeInfo): number => {\n if (params.length === 1 && isVector(params[0])) {\n const vector = params[0]\n assertNonEmptyVector(vector, sourceCodeInfo)\n return vector.reduce((m, val) => Math.max(m, val), -Infinity)\n }\n const [first, ...rest] = params\n assertNumber(first, sourceCodeInfo)\n return rest.reduce((m: number, value) => {\n assertNumber(value, sourceCodeInfo)\n return Math.max(m, value)\n }, first)\n },\n arity: { min: 1 },\n docs: {\n category: 'math',\n returns: { type: 'number' },\n args: {\n a: { type: 'number' },\n b: { type: 'number' },\n xs: { type: 'number', rest: true },\n vector: { type: 'vector' },\n },\n variants: [\n { argumentNames: ['xs'] },\n { argumentNames: ['vector'] },\n ],\n description: 'Returns the largest value. Accepts either multiple numbers or a single vector of numbers.',\n seeAlso: ['min', 'vector.span', 'vector.max-index'],\n examples: [\n '2 max 3',\n 'max(2, 0, 1)',\n 'max(2, -1, 1)',\n 'max([2, 0, -1])',\n '4 max 2',\n ],\n },\n },\n 'abs': {\n evaluate: unaryMathOp(val => Math.abs(val)),\n arity: toFixedArity(1),\n docs: {\n category: 'math',\n returns: { type: ['number', 'vector', 'matrix'] },\n args: {\n x: { type: ['number', 'vector', 'matrix'] },\n },\n variants: [{ argumentNames: ['x'] }],\n description: 'The abs function returns the absolute value (magnitude) of a `number`, working on `numbers` and element-wise on `vectors` and `matrices`. When applied to collections, it returns the absolute value of each element while preserving the original structure.',\n seeAlso: ['sign', '-'],\n examples: [\n 'abs(-2.3)',\n 'abs(0)',\n 'abs(2.5)',\n 'abs([1, -2, 3])',\n 'abs([[1, -2], [3, -4]])',\n ],\n },\n },\n 'sign': {\n evaluate: unaryMathOp(val => Math.sign(val)),\n arity: toFixedArity(1),\n docs: {\n category: 'math',\n returns: { type: ['number', 'vector', 'matrix'] },\n args: {\n x: { type: ['number', 'vector', 'matrix'] },\n },\n variants: [{ argumentNames: ['x'] }],\n description: 'The `sign` function returns the `sign` of a `number` (-1 for negative, 0 for zero, 1 for positive), working on `numbers` and element-wise on `vectors` and `matrices`. When applied to collections, it returns the sign of each element while preserving the original structure.',\n seeAlso: ['abs'],\n examples: [\n 'sign(-2.3)',\n 'sign(-0)',\n 'sign(0)',\n 'sign(12312)',\n 'sign([1, -2, 3])',\n 'sign([[1, -2], [3, -4]])',\n ],\n },\n },\n}\n","import type { Any } from '../../interface'\nimport type { SourceCodeInfo } from '../../tokenizer/token'\nimport { asAny, assertAny } from '../../typeGuards/dvala'\nimport { assertNumber } from '../../typeGuards/number'\nimport { asStringOrNumber, assertString, assertStringOrNumber } from '../../typeGuards/string'\nimport { compare, deepEqual } from '../../utils'\nimport { toFixedArity } from '../../utils/arity'\nimport type { BuiltinNormalExpressions } from '../interface'\n\nfunction isEqual([first, ...rest]: unknown[], sourceCodeInfo: SourceCodeInfo | undefined) {\n const firstAny = asAny(first, sourceCodeInfo)\n for (const param of rest) {\n if (!deepEqual(firstAny, asAny(param, sourceCodeInfo), sourceCodeInfo))\n return false\n }\n return true\n}\n\nfunction isIdentical([first, ...rest]: unknown[]) {\n for (const param of rest) {\n if (param !== first)\n return false\n }\n return true\n}\n\nexport const miscNormalExpression: BuiltinNormalExpressions = {\n '==': {\n evaluate: (params, sourceCodeInfo): boolean => {\n return isEqual(params, sourceCodeInfo)\n },\n arity: { min: 1 },\n docs: {\n category: 'misc',\n returns: { type: 'boolean' },\n args: {\n a: { type: 'any' },\n b: { type: 'any' },\n x: { type: 'any' },\n ys: { type: 'any', rest: true },\n },\n variants: [\n { argumentNames: ['x'] },\n { argumentNames: ['x', 'ys'] },\n ],\n description: 'Returns `true` if all `values` are structaul equal to each other, otherwise result is `false`.',\n seeAlso: ['!=', 'identical?'],\n examples: [\n '1 == 1',\n '[1, 2] == [1, 2]',\n `\n{\n a: 1,\n b: 2,\n} == {\n b: 2,\n a: 1,\n}`,\n '==(1, 1)',\n '==(1.01, 1)',\n '==(\"1\", 1)',\n '==(\"2\", \"2\", \"2\", \"2\")',\n '==(2, 2, 1, 2)',\n '==([1, 2], [1, 2])',\n '==({ a: 1, b: 2 }, { b: 2, a: 1 })',\n ],\n },\n },\n '!=': {\n evaluate: (params, sourceCodeInfo): boolean => {\n return !isEqual(params, sourceCodeInfo)\n },\n arity: { min: 1 },\n docs: {\n category: 'misc',\n returns: { type: 'boolean' },\n args: {\n a: { type: 'any' },\n b: { type: 'any' },\n x: { type: 'any' },\n ys: { type: 'any', rest: true },\n },\n variants: [\n { argumentNames: ['x'] },\n { argumentNames: ['x', 'ys'] },\n ],\n description: 'Returns `true` if all `values` are not equal to each other, otherwise result is `false`. `(!= a b c)` is same as `(not (== a b c))`.',\n seeAlso: ['==', 'identical?'],\n examples: [\n '1 != 2',\n '3 != 3',\n '!=(3)',\n '!=(3, 3, 2)',\n '!=(\"3\", \"2\", \"1\", \"0\",)',\n '!=(0, -0)',\n ],\n },\n },\n 'identical?': {\n evaluate: (params): boolean => {\n return isIdentical(params)\n },\n arity: { min: 1 },\n docs: {\n category: 'misc',\n returns: { type: 'boolean' },\n args: {\n a: { type: 'any' },\n b: { type: 'any' },\n },\n variants: [{ argumentNames: ['a', 'b'] }],\n description: 'Returns true if $a and $b are referential equal.',\n seeAlso: ['==', '!='],\n examples: [\n 'identical?({ a: 10, b: 20 }, { b: 20, a: 10 })',\n 'identical?([1, true, null], [1, true, null])',\n 'identical?(0.3, 0.1 + 0.2)',\n ],\n },\n },\n '>': {\n evaluate: ([first, ...rest], sourceCodeInfo): boolean => {\n let currentValue = asStringOrNumber(first)\n for (const param of rest) {\n if (compare(currentValue, asStringOrNumber(param), sourceCodeInfo) <= 0)\n return false\n\n currentValue = asStringOrNumber(param)\n }\n return true\n },\n arity: { min: 1 },\n docs: {\n category: 'misc',\n returns: { type: 'boolean' },\n args: {\n a: { type: ['number', 'string'] },\n b: { type: ['number', 'string'] },\n x: { type: ['number', 'string'] },\n ys: { type: ['number', 'string'], rest: true },\n },\n variants: [\n { argumentNames: ['x'] },\n { argumentNames: ['x', 'ys'] },\n ],\n description: 'Returns `true` if $x and $ys are in decreasing order, `false` otherwise.',\n seeAlso: ['<', '>=', '<=', 'compare'],\n examples: [\n '>(1, 0)',\n '>(1.01, 1)',\n '>(1, 1)',\n '>(4, 3, 2, 1)',\n '>(3, 2, 2, 1)',\n ],\n },\n },\n\n '<': {\n evaluate: ([first, ...rest], sourceCodeInfo): boolean => {\n let currentValue = asStringOrNumber(first)\n for (const param of rest) {\n if (compare(currentValue, asStringOrNumber(param), sourceCodeInfo) >= 0)\n return false\n\n currentValue = asStringOrNumber(param)\n }\n return true\n },\n arity: { min: 1 },\n docs: {\n category: 'misc',\n returns: { type: 'boolean' },\n args: {\n a: { type: ['number', 'string'] },\n b: { type: ['number', 'string'] },\n x: { type: ['number', 'string'] },\n ys: { type: ['number', 'string'], rest: true },\n },\n variants: [\n { argumentNames: ['x'] },\n { argumentNames: ['x', 'ys'] },\n ],\n description: 'Returns `true` if $x and $ys are in increasing order, `false` otherwise.',\n seeAlso: ['>', '>=', '<=', 'compare'],\n examples: [\n '<(0, 1)',\n '<(1, 1.01)',\n '<(1, 1)',\n '<(1, 2, 2, 3)',\n '<(\"a\", \"b\")',\n ],\n },\n },\n '>=': {\n evaluate: ([first, ...rest], sourceCodeInfo): boolean => {\n let currentValue = asStringOrNumber(first)\n for (const param of rest) {\n if (compare(currentValue, asStringOrNumber(param), sourceCodeInfo) < 0)\n return false\n\n currentValue = asStringOrNumber(param)\n }\n return true\n },\n arity: { min: 1 },\n docs: {\n category: 'misc',\n returns: { type: 'boolean' },\n args: {\n a: { type: ['number', 'string'] },\n b: { type: ['number', 'string'] },\n x: { type: ['number', 'string'] },\n ys: { type: ['number', 'string'], rest: true },\n },\n variants: [\n { argumentNames: ['x'] },\n { argumentNames: ['x', 'ys'] },\n ],\n description: 'Returns `true` if $x and $ys are in non increasing order, `false` otherwise.',\n seeAlso: ['>', '<', '<=', 'compare'],\n examples: [\n '1 >= 1',\n '0 >= 1',\n '>=(1, 0)',\n '>=(1.01, 1)',\n '>=(1, 1)',\n '>=(4, 3, 2, 1)',\n '>=(3, 2, 2, 1)',\n ],\n },\n },\n '<=': {\n evaluate: ([first, ...rest], sourceCodeInfo): boolean => {\n let currentValue = asStringOrNumber(first)\n for (const param of rest) {\n if (compare(currentValue, asStringOrNumber(param), sourceCodeInfo) > 0)\n return false\n\n currentValue = asStringOrNumber(param)\n }\n return true\n },\n arity: { min: 1 },\n docs: {\n category: 'misc',\n returns: { type: 'boolean' },\n args: {\n a: { type: ['number', 'string'] },\n b: { type: ['number', 'string'] },\n x: { type: ['number', 'string'] },\n ys: { type: ['number', 'string'], rest: true },\n },\n variants: [\n { argumentNames: ['x'] },\n { argumentNames: ['x', 'ys'] },\n ],\n description: 'Returns `true` if $x and $ys are in non decreasing order, `false` otherwise.',\n seeAlso: ['>', '<', '>=', 'compare'],\n examples: [\n '1 <= 1',\n '<=(0, 1)',\n '<=(1, 1.01)',\n '<=(1, 1)',\n '<=(1, 2, 3, 4)',\n '<=(1, 2, 2, 3)',\n ],\n },\n },\n 'not': {\n evaluate: ([first]): boolean => !first,\n arity: toFixedArity(1),\n docs: {\n category: 'misc',\n returns: { type: 'boolean' },\n args: { x: { type: 'any' } },\n variants: [{ argumentNames: ['x'] }],\n description: 'Computes logical negation. Note that any other $x than `false`, `0`, `null` and `\\'\\'` is truthy.',\n seeAlso: ['boolean'],\n examples: [\n 'not(3)',\n 'not(true)',\n 'not(\"A string\")',\n 'not(0)',\n 'not(false)',\n 'not(null)',\n 'not(\"\")',\n ],\n },\n },\n 'epoch->iso-date': {\n evaluate: ([ms], sourceCodeInfo): string => {\n assertNumber(ms, sourceCodeInfo)\n return new Date(ms).toISOString()\n },\n arity: toFixedArity(1),\n docs: {\n category: 'misc',\n returns: { type: 'string' },\n args: { ms: { type: 'number' } },\n variants: [{ argumentNames: ['ms'] }],\n description: 'Returns IOS date time string from `ms` (milliseconds elapsed since the UNIX epoch).',\n seeAlso: ['iso-date->epoch'],\n examples: [\n 'epoch->iso-date(1649756230899)',\n 'epoch->iso-date(0)',\n ],\n },\n },\n 'iso-date->epoch': {\n evaluate: ([dateTime], sourceCodeInfo): number => {\n assertString(dateTime, sourceCodeInfo)\n const ms = new Date(dateTime).valueOf()\n assertNumber(ms, sourceCodeInfo, { finite: true })\n return ms\n },\n arity: toFixedArity(1),\n docs: {\n category: 'misc',\n returns: { type: 'number' },\n args: { iso: { type: 'string' } },\n variants: [{ argumentNames: ['iso'] }],\n description: 'Returns milliseconds elapsed since the UNIX epoch to `iso`.',\n seeAlso: ['epoch->iso-date'],\n examples: [\n 'iso-date->epoch(\"2022-04-12T09:37:10.899Z\")',\n 'iso-date->epoch(\"1980-01-01\")',\n ],\n },\n },\n 'write!': {\n evaluate: (params, sourceCodeInfo): Any => {\n // eslint-disable-next-line no-console\n console.log(...params)\n\n if (params.length > 0)\n return asAny(params[params.length - 1], sourceCodeInfo)\n\n return null\n },\n pure: false,\n arity: {},\n docs: {\n category: 'misc',\n returns: { type: 'any' },\n args: { values: { type: 'any', rest: true } },\n variants: [{ argumentNames: ['values'] }],\n description: 'It logs the $values and then returns the last argument. If called with no arguments `null` is returned.',\n examples: [\n 'write!(\"A string\")',\n 'write!(100, \"items\")',\n 'write!(object(\"a\", 10))',\n 'write!([\"a\", \"b\", \"c\"])',\n 'write!(#\"^start\")',\n 'write!(null, true, false)',\n ],\n hideOperatorForm: true,\n },\n },\n 'boolean': {\n evaluate: ([value]): boolean => {\n return !!value\n },\n arity: toFixedArity(1),\n docs: {\n category: 'misc',\n returns: { type: 'boolean' },\n args: { x: { type: 'any' } },\n variants: [{ argumentNames: ['x'] }],\n description: 'Coerces $x to boolean.',\n seeAlso: ['not', 'boolean?', 'true?', 'false?'],\n examples: [\n 'boolean(0)',\n 'boolean(1)',\n 'boolean(null)',\n 'boolean(\"Albert\")',\n ],\n },\n },\n 'compare': {\n evaluate: ([a, b], sourceCodeInfo): number => {\n assertStringOrNumber(a, sourceCodeInfo)\n assertStringOrNumber(b, sourceCodeInfo)\n return compare(a, b, sourceCodeInfo)\n },\n arity: toFixedArity(2),\n docs: {\n category: 'misc',\n returns: { type: 'number' },\n args: {\n a: { type: ['number', 'string'] },\n b: { type: ['number', 'string'] },\n },\n variants: [{ argumentNames: ['a', 'b'] }],\n description: 'Compares two values. Returns `-1` if $a < $b, `1` if $a > $b and `0` if $a and $b have the same sort order.',\n seeAlso: ['<', '>', '<=', '>=', 'sort', 'sequence.sort-by'],\n examples: [\n 'compare(0, 1)',\n 'compare(0, 0)',\n 'compare(1, 0)',\n 'compare(\"Albert\", \"Mojir\")',\n ],\n },\n },\n 'json-parse': {\n evaluate: ([first], sourceCodeInfo): Any => {\n assertString(first, sourceCodeInfo)\n // eslint-disable-next-line ts/no-unsafe-return\n return JSON.parse(first)\n },\n arity: toFixedArity(1),\n docs: {\n category: 'misc',\n returns: { type: 'any' },\n args: { x: { type: 'string' } },\n variants: [{ argumentNames: ['x'] }],\n description: 'Returns `JSON.parse(`$x`)`.',\n seeAlso: ['json-stringify'],\n examples: [\n 'json-parse(\"[1, 2, 3]\")',\n ],\n },\n },\n 'json-stringify': {\n evaluate: ([first, second], sourceCodeInfo): string => {\n assertAny(first, sourceCodeInfo)\n if (second === undefined)\n return JSON.stringify(first)\n\n assertNumber(second, sourceCodeInfo)\n return JSON.stringify(first, null, second)\n },\n arity: { min: 1, max: 2 },\n docs: {\n category: 'misc',\n returns: { type: 'string' },\n args: {\n x: { type: 'any' },\n indent: { type: 'integer', description: 'Number of spaces to use for indentation.' },\n },\n variants: [\n { argumentNames: ['x'] },\n { argumentNames: ['x', 'indent'] },\n ],\n description: 'Returns `JSON.stringify(`$x`)`. If second argument is provided, returns `JSON.stringify(`$x`, null, `$indent`)`.',\n seeAlso: ['json-parse'],\n examples: [\n 'json-stringify([1, 2, 3])',\n 'json-stringify({ a: { b: 10 }}, 2)',\n ],\n hideOperatorForm: true,\n },\n },\n}\n","import type { Any, Arr, Obj } from '../../interface'\nimport { assertArray, assertStringArray } from '../../typeGuards/array'\nimport { assertFunctionLike, assertObj } from '../../typeGuards/dvala'\nimport { asString, assertString } from '../../typeGuards/string'\nimport { collHasKey, toAny } from '../../utils'\nimport { toFixedArity } from '../../utils/arity'\nimport type { MaybePromise } from '../../utils/maybePromise'\nimport { chain, reduceSequential } from '../../utils/maybePromise'\nimport type { BuiltinNormalExpressions } from '../interface'\n\nexport const objectNormalExpression: BuiltinNormalExpressions = {\n 'keys': {\n evaluate: ([obj], sourceCodeInfo): string[] => {\n assertObj(obj, sourceCodeInfo)\n return Object.keys(obj)\n },\n arity: toFixedArity(1),\n docs: {\n category: 'object',\n returns: { type: 'any', array: true },\n args: { obj: { type: 'object' } },\n variants: [{ argumentNames: ['obj'] }],\n description: 'Returns array of all keys in $obj.',\n seeAlso: ['vals', 'entries', 'zipmap', 'select-keys'],\n examples: [\n 'keys({})',\n 'keys({ x: 10, y: true, z: \"A string\" })',\n 'keys(object(\"x\", 10, \"y\", true, \"z\", \"A string\"))',\n ],\n },\n },\n\n 'vals': {\n evaluate: ([obj], sourceCodeInfo): Arr => {\n assertObj(obj, sourceCodeInfo)\n return Object.values(obj)\n },\n arity: toFixedArity(1),\n docs: {\n category: 'object',\n returns: { type: 'any', array: true },\n args: { obj: { type: 'object' } },\n variants: [{ argumentNames: ['obj'] }],\n description: 'Returns array of all values in $obj.',\n seeAlso: ['keys', 'entries', 'zipmap'],\n examples: [\n 'vals({})',\n 'vals({ x: 10, y: true, z: \"A string\" })',\n 'vals(object(\"x\", 10, \"y\", true, \"z\", \"A string\"))',\n ],\n },\n },\n\n 'entries': {\n evaluate: ([obj], sourceCodeInfo): Array<[string, unknown]> => {\n assertObj(obj, sourceCodeInfo)\n return Object.entries(obj)\n },\n arity: toFixedArity(1),\n docs: {\n category: 'object',\n returns: { type: 'array' },\n args: { obj: { type: 'object' } },\n variants: [{ argumentNames: ['obj'] }],\n description: 'Returns nested array of all key - value pairs in $obj.',\n seeAlso: ['keys', 'vals', 'zipmap', 'find'],\n examples: [\n 'entries({})',\n 'entries({ x: 10, y: true, z: \"A string\" })',\n 'entries(object(\"x\", 10, \"y\", true, \"z\", \"A string\"))',\n ],\n },\n },\n\n 'find': {\n evaluate: ([obj, key], sourceCodeInfo): [string, unknown] | null => {\n assertObj(obj, sourceCodeInfo)\n assertString(key, sourceCodeInfo)\n if (collHasKey(obj, key))\n return [key, obj[key]]\n\n return null\n },\n arity: toFixedArity(2),\n docs: {\n category: 'object',\n returns: { type: ['array', 'null'] },\n args: {\n a: { type: 'object' },\n b: { type: 'string' },\n obj: { type: 'object' },\n key: { type: 'string' },\n },\n variants: [{ argumentNames: ['obj', 'key'] }],\n description: 'Returns entry (key-value pair) for $key, or `null` if $key not present in $obj.',\n seeAlso: ['get', 'contains?', 'entries', 'sequence.position', 'some'],\n examples: [\n '{ a: 1, \"b\": 2 } find \"a\"',\n 'find(object(\"a\", 1, \"b\", 2), \"b\")',\n 'find(object(\"a\", 1, \"b\", 2), \"c\")',\n ],\n },\n },\n\n 'dissoc': {\n evaluate: ([obj, key], sourceCodeInfo): Any => {\n assertObj(obj, sourceCodeInfo)\n assertString(key, sourceCodeInfo)\n const newObj = { ...obj }\n delete newObj[key]\n return newObj\n },\n arity: toFixedArity(2),\n docs: {\n category: 'object',\n returns: { type: 'object' },\n args: {\n a: { type: 'object' },\n b: { type: 'string' },\n obj: { type: 'object' },\n key: { type: 'string' },\n },\n variants: [{ argumentNames: ['obj', 'key'] }],\n description: 'Return shallow copy of $obj with $key deleted.',\n seeAlso: ['assoc', 'select-keys'],\n examples: [\n '{ x: 10, y: 20 } dissoc \"y\"',\n 'dissoc({ x: 10, y: 20 }, \"x\")',\n 'dissoc({ x: 10 }, \"y\")',\n `\nlet o = { a: 5 };\ndissoc(o, \"a\");\no`,\n ],\n },\n },\n\n 'merge': {\n evaluate: (params, sourceCodeInfo): Any => {\n if (params.length === 0)\n return null\n\n const [first, ...rest] = params\n assertObj(first, sourceCodeInfo)\n\n return rest.reduce(\n (result: Obj, obj) => {\n assertObj(obj, sourceCodeInfo)\n return { ...result, ...obj }\n },\n { ...first },\n )\n },\n arity: { min: 0 },\n docs: {\n category: 'object',\n returns: { type: 'object' },\n args: {\n a: { type: 'object' },\n b: { type: 'object' },\n objs: { type: 'object', rest: true },\n },\n variants: [{ argumentNames: ['objs'] }],\n description: `Returns a new object created by merging together all arguments.\n\nIf two keys appears in more than one object the value from the last object is used.\nIf no arguments are provided \\`null\\` is returned.`,\n seeAlso: ['merge-with', 'assoc'],\n examples: [\n '{ x: 10 } merge { y: 20 }',\n 'merge(object(\"x\", 10), object(\"y\", 20))',\n 'merge(object(\"x\", 10), object(\"x\", 15, \"y\", 20))',\n ],\n },\n },\n\n 'merge-with': {\n evaluate: (params: Arr, sourceCodeInfo, contextStack, { executeFunction }): MaybePromise<Any> => {\n const first = params[0]\n const fn = params.at(-1)\n const rest = params.slice(1, -1)\n\n assertObj(first, sourceCodeInfo)\n assertFunctionLike(fn, sourceCodeInfo)\n\n return reduceSequential(\n rest,\n (result: Obj, obj) => {\n assertObj(obj, sourceCodeInfo)\n const entries = Object.entries(obj)\n return chain(\n reduceSequential(\n entries,\n (res: Obj, entry) => {\n const key = asString(entry[0], sourceCodeInfo)\n const val = toAny(entry[1])\n if (collHasKey(res, key)) {\n return chain(executeFunction(fn, [res[key], val], contextStack, sourceCodeInfo), (merged) => {\n res[key] = merged\n return res\n })\n }\n else {\n res[key] = val\n return res\n }\n },\n result,\n ),\n r => r,\n )\n },\n { ...first } satisfies Obj,\n )\n },\n arity: { min: 2 },\n docs: {\n category: 'object',\n returns: { type: 'object' },\n args: {\n objs: { type: 'object', rest: true },\n fun: { type: 'function' },\n },\n variants: [{ argumentNames: ['objs', 'fun'] }],\n description: `\nReturns a new object created by merging together all arguments.\nIf two keys appears in more than one object $fun is used to calculate the new value.\n\nIf no arguments are provided \\`null\\` is returned.`,\n seeAlso: ['merge'],\n examples: [\n 'merge-with(object(\"x\", 10), object(\"y\", 20), +)',\n 'merge-with(object(\"x\", 10), object(\"x\", 15, \"y\", 20), +)',\n 'merge-with({ x: 10 }, { x: 20 }, { x: 30 }, { x: 40 }, -)',\n ],\n hideOperatorForm: true,\n },\n },\n\n 'zipmap': {\n evaluate: ([keys, values], sourceCodeInfo): Any => {\n assertStringArray(keys, sourceCodeInfo)\n assertArray(values, sourceCodeInfo)\n\n const length = Math.min(keys.length, values.length)\n\n const result: Obj = {}\n\n for (let i = 0; i < length; i += 1) {\n const key = asString(keys[i], sourceCodeInfo)\n result[key] = toAny(values[i])\n }\n return result\n },\n arity: toFixedArity(2),\n docs: {\n category: 'object',\n returns: { type: 'object' },\n args: {\n a: { type: 'array' },\n b: { type: 'array' },\n },\n variants: [{ argumentNames: ['a', 'b'] }],\n description: 'Returns a new object created by mapping $a to $b.',\n seeAlso: ['entries', 'keys', 'vals', 'sequence.interleave'],\n examples: [\n '[\"a\", \"b\", \"c\"] zipmap [1, 2, 3]',\n 'zipmap([\"a\", \"b\", \"c\"], [10, null, [1, 2, 3]])',\n 'zipmap([\"a\", \"b\", \"c\"], [1])',\n 'zipmap([], [10, null, [1, 2, 3]])',\n ],\n },\n },\n\n 'select-keys': {\n evaluate: ([obj, keys], sourceCodeInfo): Any => {\n assertStringArray(keys, sourceCodeInfo)\n assertObj(obj, sourceCodeInfo)\n\n return keys.reduce((result: Obj, key) => {\n if (collHasKey(obj, key))\n result[key] = toAny(obj[key])\n\n return result\n }, {})\n },\n arity: toFixedArity(2),\n docs: {\n category: 'object',\n returns: { type: 'object' },\n args: {\n a: { type: 'object' },\n b: { type: 'array' },\n },\n variants: [{ argumentNames: ['a', 'b'] }],\n description: 'Returns an object containing only those entries in $a whose key is in $b.',\n seeAlso: ['dissoc', 'keys'],\n examples: [\n '{ a: 1, b: 2, c: 3 } select-keys [\"a\", \"b\"]',\n 'select-keys({ a: 1, b: 2, c: 3 }, [\"a\", \"b\"])',\n 'select-keys({ a: 1 }, [\"a\", \"b\"])',\n ],\n },\n },\n}\n","import { isDvalaFunction } from '../../typeGuards/dvalaFunction'\nimport { assertColl, isColl, isObj, isRegularExpression, isSeq } from '../../typeGuards/dvala'\nimport { assertNumber, isNumber } from '../../typeGuards/number'\nimport type { BuiltinNormalExpressions } from '../interface'\nimport { isGrid, isMatrix, isVector } from '../../typeGuards/annotatedArrays'\nimport { EPSILON } from '../../utils'\nimport { toFixedArity } from '../../utils/arity'\n\nexport const predicatesNormalExpression: BuiltinNormalExpressions = {\n 'function?': {\n evaluate: ([first]): boolean => isDvalaFunction(first),\n arity: toFixedArity(1),\n docs: {\n category: 'predicate',\n returns: { type: 'boolean' },\n args: { x: { type: 'any' } },\n variants: [{ argumentNames: ['x'] }],\n description: 'Returns `true` if $x is a function, otherwise `false`.',\n seeAlso: ['string?', 'number?', 'boolean?', 'null?', 'array?', 'object?', 'regexp?'],\n examples: [\n 'function?(+)',\n 'function?(/)',\n 'function?((x, y) -> x + y)',\n 'function?(false)',\n 'function?(\"false\")',\n 'function?([1, 2, 3])',\n ],\n },\n },\n\n 'string?': {\n evaluate: ([first]): boolean => typeof first === 'string',\n arity: toFixedArity(1),\n docs: {\n category: 'predicate',\n returns: { type: 'boolean' },\n args: { x: { type: 'any' } },\n variants: [{ argumentNames: ['x'] }],\n description: 'Returns `true` if $x is a string, otherwise `false`.',\n seeAlso: ['blank?', 'number?', 'boolean?', 'null?', 'array?', 'object?', 'regexp?', 'function?', 'collection?', 'sequence?'],\n examples: [\n 'string?(\"\")',\n 'string?(\"A string\")',\n 'string?(true ? \"A string\" : false)',\n 'string?(false)',\n 'string?([1, 2, 3])',\n 'string?(100)',\n ],\n },\n },\n\n 'number?': {\n evaluate: ([first]): boolean => typeof first === 'number',\n arity: toFixedArity(1),\n docs: {\n category: 'predicate',\n returns: { type: 'boolean' },\n args: { x: { type: 'any' } },\n variants: [{ argumentNames: ['x'] }],\n description: 'Returns `true` if $x is a number, otherwise `false`.',\n seeAlso: ['integer?', 'zero?', 'pos?', 'neg?', 'finite?', 'number', 'string?', 'boolean?', 'null?', 'function?'],\n examples: [\n 'number?(0)',\n 'number?(2)',\n 'number?(-0.12)',\n 'number?(false)',\n 'number?([1, 2, 3])',\n 'number?(\"A string\")',\n ],\n },\n },\n\n 'integer?': {\n evaluate: ([first]): boolean => typeof first === 'number' && isNumber(first, { integer: true }),\n arity: toFixedArity(1),\n docs: {\n category: 'predicate',\n returns: { type: 'boolean' },\n args: { x: { type: 'any' } },\n variants: [{ argumentNames: ['x'] }],\n description: 'Returns `true` if $x is an integer, otherwise `false`.',\n seeAlso: ['number?', 'number', 'even?', 'odd?'],\n examples: [\n 'integer?(0)',\n 'integer?(-12)',\n 'integer?(42)',\n 'integer?(10.1)',\n 'integer?((x, y) -> x + y)',\n 'integer?(false)',\n 'integer?(\"false\")',\n 'integer?([1, 2, 3])',\n ],\n },\n },\n\n 'boolean?': {\n evaluate: ([first]): boolean => typeof first === 'boolean',\n arity: toFixedArity(1),\n docs: {\n category: 'predicate',\n returns: { type: 'boolean' },\n args: { x: { type: 'any' } },\n variants: [{ argumentNames: ['x'] }],\n description: 'Returns `true` if $x is a `boolean`, otherwise `false`.',\n seeAlso: ['true?', 'false?', 'boolean', 'string?', 'number?', 'null?', 'function?'],\n examples: [\n 'boolean?(true)',\n 'boolean?(false)',\n 'boolean?([1, 2, 3])',\n 'boolean?(0)',\n 'boolean?(\"A string\")',\n ],\n },\n },\n\n 'null?': {\n evaluate: ([first]): boolean => first === null || first === undefined,\n arity: toFixedArity(1),\n docs: {\n category: 'predicate',\n returns: { type: 'boolean' },\n args: { x: { type: 'any' } },\n variants: [{ argumentNames: ['x'] }],\n description: 'Returns `true` if $x is `null`, otherwise `false`.',\n seeAlso: ['empty?', 'not-empty?', 'string?', 'number?', 'boolean?', 'function?'],\n examples: [\n 'null?(null)',\n 'null?(false)',\n 'null?([1, 2, 3])',\n 'null?(0)',\n 'null?(\"A string\")',\n ],\n },\n },\n\n 'zero?': {\n evaluate: ([value], sourceCodeInfo): boolean => {\n assertNumber(value, sourceCodeInfo, { finite: true })\n return Math.abs(value) < EPSILON\n },\n arity: toFixedArity(1),\n docs: {\n category: 'predicate',\n returns: { type: 'boolean' },\n args: { x: { type: 'number' } },\n variants: [{ argumentNames: ['x'] }],\n description: 'Returns `true` if $x is `0`, otherwise `false`.',\n seeAlso: ['pos?', 'neg?', 'even?', 'number?'],\n examples: [\n 'zero?(0)',\n 'zero?(-0.0)',\n 'zero?(1)',\n 'zero?(0.1)',\n ],\n },\n },\n\n 'pos?': {\n evaluate: ([first], sourceCodeInfo): boolean => {\n assertNumber(first, sourceCodeInfo, { finite: true })\n return first > 0\n },\n arity: toFixedArity(1),\n docs: {\n category: 'predicate',\n returns: { type: 'boolean' },\n args: { x: { type: 'number' } },\n variants: [{ argumentNames: ['x'] }],\n description: 'Returns `true` if $x is greater than `0`, otherwise `false`.',\n seeAlso: ['neg?', 'zero?', 'number?'],\n examples: [\n 'pos?(0)',\n 'pos?(-0.0)',\n 'pos?(1)',\n 'pos?(-0.1)',\n ],\n },\n },\n\n 'neg?': {\n evaluate: ([first], sourceCodeInfo): boolean => {\n assertNumber(first, sourceCodeInfo, { finite: true })\n return first < 0\n },\n arity: toFixedArity(1),\n docs: {\n category: 'predicate',\n returns: { type: 'boolean' },\n args: { x: { type: 'number' } },\n variants: [{ argumentNames: ['x'] }],\n description: 'Returns `true` if $x is less than `0`, otherwise `false`.',\n seeAlso: ['pos?', 'zero?', 'number?'],\n examples: [\n 'neg?(0)',\n 'neg?(-0.0)',\n 'neg?(1)',\n 'neg?(-0.1)',\n ],\n },\n },\n\n 'even?': {\n evaluate: ([first], sourceCodeInfo): boolean => {\n assertNumber(first, sourceCodeInfo, { finite: true })\n return first % 2 === 0\n },\n arity: toFixedArity(1),\n docs: {\n category: 'predicate',\n returns: { type: 'boolean' },\n args: { x: { type: 'number' } },\n variants: [{ argumentNames: ['x'] }],\n description: 'Returns `true` if $x is even, otherwise `false`.',\n seeAlso: ['odd?', 'integer?', 'zero?'],\n examples: [\n 'even?(0)',\n 'even?(-0.0)',\n 'even?(-1)',\n 'even?(2.1)',\n ],\n },\n },\n\n 'odd?': {\n evaluate: ([first], sourceCodeInfo): boolean => {\n assertNumber(first, sourceCodeInfo, { finite: true })\n return isNumber(first, { integer: true }) && first % 2 !== 0\n },\n arity: toFixedArity(1),\n docs: {\n category: 'predicate',\n returns: { type: 'boolean' },\n args: { x: { type: 'number' } },\n variants: [{ argumentNames: ['x'] }],\n description: 'Returns `true` if $x is odd, otherwise `false`.',\n seeAlso: ['even?', 'integer?'],\n examples: [\n 'odd?(1.0)',\n 'odd?(1.001)',\n 'odd?(-1)',\n 'odd?(2.1)',\n ],\n },\n },\n\n 'array?': {\n evaluate: ([first]): boolean => {\n return Array.isArray(first)\n },\n arity: toFixedArity(1),\n docs: {\n category: 'predicate',\n returns: { type: 'boolean' },\n args: { x: { type: 'any' } },\n variants: [{ argumentNames: ['x'] }],\n description: 'Returns `true` if $x is an array, otherwise `false`.',\n seeAlso: ['sequence?', 'collection?', 'object?', 'string?', 'vector?', 'matrix?', 'grid?', 'function?'],\n examples: [\n 'array?([])',\n 'array?([1, 2, 3])',\n 'array?(object(\"a\", 10))',\n 'array?(42)',\n 'array?(10.1)',\n 'array?((x, y) -> x + y)',\n ],\n },\n },\n\n 'collection?': {\n evaluate: ([first]): boolean => {\n return isColl(first)\n },\n arity: toFixedArity(1),\n docs: {\n category: 'predicate',\n returns: { type: 'boolean' },\n args: { x: { type: 'any' } },\n variants: [{ argumentNames: ['x'] }],\n description: 'Returns `true` if $x is a collection i.e. an array, an object or a string, otherwise `false`.',\n seeAlso: ['sequence?', 'array?', 'object?', 'string?'],\n examples: [\n 'collection?([])',\n 'collection?([1, 2, 3])',\n 'collection?(object(\"a\", 10))',\n 'collection?(\"Albert\")',\n 'collection?(42)',\n 'collection?(10.1)',\n 'collection?((x, y) -> x + y)',\n ],\n },\n },\n\n 'sequence?': {\n evaluate: ([first]): boolean => {\n return isSeq(first)\n },\n arity: toFixedArity(1),\n docs: {\n category: 'predicate',\n returns: { type: 'boolean' },\n args: { x: { type: 'any' } },\n variants: [{ argumentNames: ['x'] }],\n description: 'Returns `true` if $x is a sequence i.e. an array or a string, otherwise `false`.',\n seeAlso: ['collection?', 'array?', 'string?'],\n examples: [\n 'sequence?([])',\n 'sequence?([1, 2, 3])',\n 'sequence?(object(\"a\", 10))',\n 'sequence?(\"Albert\")',\n 'sequence?(42)',\n 'sequence?(10.1)',\n 'sequence?((x, y) -> x + y)',\n ],\n },\n },\n\n 'object?': {\n evaluate: ([first]): boolean => isObj(first),\n arity: toFixedArity(1),\n docs: {\n category: 'predicate',\n returns: { type: 'boolean' },\n args: { x: { type: 'any' } },\n variants: [{ argumentNames: ['x'] }],\n description: 'Returns `true` if $x is an object, otherwise `false`.',\n seeAlso: ['collection?', 'array?', 'string?', 'function?'],\n examples: [\n 'object?(object(\"a\", 10))',\n 'object?(42)',\n 'object?(10.1)',\n 'object?((x, y) -> x + y)',\n 'object?(#\"^start\")',\n 'object?(\"false\")',\n 'object?([1, 2, 3])',\n ],\n },\n },\n\n 'regexp?': {\n evaluate: ([value]): boolean => isRegularExpression(value),\n arity: toFixedArity(1),\n docs: {\n category: 'predicate',\n returns: { type: 'boolean' },\n args: { x: { type: 'any' } },\n variants: [{ argumentNames: ['x'] }],\n description: 'Returns `true` if $x is a regexp, otherwise `false`.',\n seeAlso: ['regexp', 're-match', 'string?', 'function?'],\n examples: [\n 'regexp?(regexp(\"^start\"))',\n 'regexp?(#\"^start\")',\n 'regexp?(-12)',\n 'regexp?({})',\n 'regexp?(10.1)',\n 'regexp?((x, y) -> x + y)',\n 'regexp?(false)',\n 'regexp?(\"false\")',\n 'regexp?([1, 2, 3])',\n ],\n },\n },\n\n 'finite?': {\n evaluate: ([value], sourceCodeInfo): boolean => {\n assertNumber(value, sourceCodeInfo)\n return Number.isFinite(value)\n },\n arity: toFixedArity(1),\n docs: {\n category: 'predicate',\n returns: { type: 'boolean' },\n args: { x: { type: 'number' } },\n variants: [{ argumentNames: ['x'] }],\n description: 'Returns `true` if $x is finite, otherwise `false`.',\n seeAlso: ['positive-infinity?', 'negative-infinity?', 'number?'],\n examples: [\n 'finite?(1.0)',\n 'finite?(1 / 0)',\n 'finite?(-1 / 0)',\n ],\n },\n },\n\n 'positive-infinity?': {\n evaluate: ([value], sourceCodeInfo): boolean => {\n assertNumber(value, sourceCodeInfo)\n return value === Number.POSITIVE_INFINITY\n },\n arity: toFixedArity(1),\n docs: {\n category: 'predicate',\n returns: { type: 'boolean' },\n args: { x: { type: 'number' } },\n variants: [{ argumentNames: ['x'] }],\n description: 'Returns `true` if $x equals positive infinity, otherwise `false`.',\n seeAlso: ['negative-infinity?', 'finite?'],\n examples: [\n 'positive-infinity?(1.0)',\n 'positive-infinity?(1 / 0)',\n 'positive-infinity?(-1 / 0)',\n ],\n },\n },\n\n 'negative-infinity?': {\n evaluate: ([value], sourceCodeInfo): boolean => {\n assertNumber(value, sourceCodeInfo)\n return value === Number.NEGATIVE_INFINITY\n },\n arity: toFixedArity(1),\n docs: {\n category: 'predicate',\n returns: { type: 'boolean' },\n args: { x: { type: 'number' } },\n variants: [{ argumentNames: ['x'] }],\n description: 'Returns `true` if $x equals negative infinity, otherwise `false`.',\n seeAlso: ['positive-infinity?', 'finite?'],\n examples: [\n 'negative-infinity?(1.0)',\n 'negative-infinity?(1 / 0)',\n 'negative-infinity?(-1 / 0)',\n ],\n },\n },\n\n 'true?': {\n evaluate: ([value]): boolean => {\n return value === true\n },\n arity: toFixedArity(1),\n docs: {\n category: 'predicate',\n returns: { type: 'boolean' },\n args: { x: { type: 'any' } },\n variants: [{ argumentNames: ['x'] }],\n description: 'Returns `true` if $x is `true`, otherwise `false`.',\n seeAlso: ['false?', 'boolean?', 'boolean'],\n examples: [\n 'true?(false)',\n 'true?(true)',\n 'true?(1)',\n 'true?(0)',\n ],\n },\n },\n\n 'false?': {\n evaluate: ([value]): boolean => {\n return value === false\n },\n arity: toFixedArity(1),\n docs: {\n category: 'predicate',\n returns: { type: 'boolean' },\n args: { x: { type: 'any' } },\n variants: [{ argumentNames: ['x'] }],\n description: 'Returns `true` if $x is `true`, otherwise `false`.',\n seeAlso: ['true?', 'boolean?', 'boolean'],\n examples: [\n 'false?(false)',\n 'false?(true)',\n 'false?(1)',\n 'false?(0)',\n ],\n },\n },\n\n 'empty?': {\n evaluate: ([coll], sourceCodeInfo): boolean => {\n if (coll === null)\n return true\n\n assertColl(coll, sourceCodeInfo)\n if (typeof coll === 'string')\n return coll.length === 0\n\n if (Array.isArray(coll))\n return coll.length === 0\n\n return Object.keys(coll).length === 0\n },\n arity: toFixedArity(1),\n docs: {\n category: 'predicate',\n returns: { type: 'boolean' },\n args: { x: { type: ['collection', 'string', 'null'] } },\n variants: [{ argumentNames: ['x'] }],\n description: 'Returns `true` if $x is empty or `null`, otherwise `false`.',\n seeAlso: ['not-empty?', 'collection.not-empty', 'null?', 'blank?', 'count'],\n examples: [\n 'empty?([])',\n 'empty?([1, 2, 3])',\n 'empty?({})',\n 'empty?({ a: 2 })',\n 'empty?(\"\")',\n 'empty?(\"Albert\")',\n 'empty?(null)',\n ],\n },\n },\n 'not-empty?': {\n evaluate: ([coll], sourceCodeInfo): boolean => {\n if (coll === null)\n return false\n\n assertColl(coll, sourceCodeInfo)\n if (typeof coll === 'string')\n return coll.length > 0\n\n if (Array.isArray(coll))\n return coll.length > 0\n\n return Object.keys(coll).length > 0\n },\n arity: toFixedArity(1),\n docs: {\n category: 'predicate',\n returns: { type: 'boolean' },\n args: { x: { type: ['collection', 'string', 'null'] } },\n variants: [{ argumentNames: ['x'] }],\n description: 'Returns `false` if $x is empty or `null`, otherwise `true`.',\n seeAlso: ['empty?', 'collection.not-empty', 'null?'],\n examples: [\n 'not-empty?([])',\n 'not-empty?([1, 2, 3])',\n 'not-empty?({})',\n 'not-empty?({ a: 2 })',\n 'not-empty?(\"\")',\n 'not-empty?(\"Albert\")',\n 'not-empty?(null)',\n ],\n },\n },\n 'vector?': {\n evaluate: ([vector]): boolean => isVector(vector),\n arity: toFixedArity(1),\n docs: {\n category: 'predicate',\n description: 'Checks if a value is a `vector`. A `vector` is an array of `numbers`.',\n seeAlso: ['matrix?', 'grid?', 'array?'],\n returns: { type: 'boolean' },\n args: { value: { type: 'any', description: 'The value to check.' } },\n variants: [{ argumentNames: ['value'] }],\n examples: [\n 'vector?(1)',\n 'vector?([1, 2, 3])',\n 'vector?([1, 2, \"3\"])',\n ],\n },\n },\n 'matrix?': {\n evaluate: ([matrix]): boolean => isMatrix(matrix),\n arity: toFixedArity(1),\n docs: {\n category: 'predicate',\n description: 'Checks if a value is a `matrix`. A `matrix` is an array of arrays of `numbers`.',\n seeAlso: ['vector?', 'grid?', 'array?'],\n returns: { type: 'boolean' },\n args: { value: { type: 'any', description: 'The value to check.' } },\n variants: [{ argumentNames: ['value'] }],\n examples: [\n 'matrix?(1)',\n 'matrix?([1, 2, 3])',\n 'matrix?([[1, 2], [3, 4]])',\n 'matrix?([[1, 2], [3, \"4\"]])',\n 'matrix?([[1, 2], [3]])',\n ],\n },\n },\n 'grid?': {\n evaluate: ([table]): boolean => isGrid(table),\n arity: toFixedArity(1),\n docs: {\n category: 'predicate',\n description: 'Checks if a `value` is a `grid`. A `grid` is an `array` of `arrays` where all inner `arrays` have the same length.',\n seeAlso: ['vector?', 'matrix?', 'array?'],\n returns: { type: 'boolean' },\n args: { value: { type: 'any', description: 'The value to check.' } },\n variants: [{ argumentNames: ['value'] }],\n examples: [\n 'grid?(\"1\")',\n 'grid?([\"1\", 2, 3])',\n 'grid?([[\"1\", 2], [3, 4]])',\n 'grid?([[\"1\", 2], [3, \"4\"]])',\n 'grid?([[\"1\", 2], [3]])',\n ],\n },\n },\n\n}\n","import { DvalaError } from '../../errors'\nimport type { RegularExpression } from '../../parser/types'\nimport { assertRegularExpression, assertStringOrRegularExpression, isRegularExpression } from '../../typeGuards/dvala'\nimport { assertString, isString } from '../../typeGuards/string'\nimport { toFixedArity } from '../../utils/arity'\nimport { REGEXP_SYMBOL } from '../../utils/symbols'\nimport type { BuiltinNormalExpressions } from '../interface'\n\nexport const regexpNormalExpression: BuiltinNormalExpressions = {\n 'regexp': {\n evaluate: ([sourceArg, flagsArg], sourceCodeInfo): RegularExpression => {\n assertString(sourceArg, sourceCodeInfo)\n const source = sourceArg || '(?:)'\n const flags = typeof flagsArg === 'string' ? flagsArg : ''\n\n try {\n // eslint-disable-next-line no-new\n new RegExp(source, flags) // Throws if invalid regexp\n }\n catch (e) {\n throw new DvalaError(`Invalid regular expression: ${source} ${flags}`, sourceCodeInfo)\n }\n return {\n [REGEXP_SYMBOL]: true,\n sourceCodeInfo,\n s: source,\n f: flags,\n }\n },\n arity: { min: 1, max: 2 },\n docs: {\n category: 'regular-expression',\n returns: { type: 'regexp' },\n args: {\n pattern: { type: 'string' },\n flags: { type: 'string', description: 'Optional flags for the regular expression. Possible values are the same as Javascript RegExp takes.' },\n },\n variants: [\n { argumentNames: ['pattern'] },\n { argumentNames: ['pattern', 'flags'] },\n ],\n description: 'Creates a RegExp from $pattern and $flags.',\n examples: [\n 'regexp(\"^\\\\s*(.*)$\")',\n '#\"^\\\\s*(.*)$\"',\n 'regexp(\"albert\", \"ig\")',\n '#\"albert\"ig',\n ],\n seeAlso: ['-short-regexp', 're-match', 'replace', 'replace-all', 'regexp?'],\n hideOperatorForm: true,\n },\n },\n 're-match': {\n evaluate: ([text, regexp], sourceCodeInfo): string[] | null => {\n assertRegularExpression(regexp, sourceCodeInfo)\n if (!isString(text))\n return null\n\n const regExp = new RegExp(regexp.s, regexp.f)\n const match = regExp.exec(text)\n if (match)\n return [...match]\n\n return null\n },\n arity: toFixedArity(2),\n docs: {\n category: 'regular-expression',\n returns: { type: 'any', array: true },\n args: {\n a: { type: 'regexp' },\n b: { type: 'string' },\n },\n variants: [{ argumentNames: ['a', 'b'] }],\n description: `Matches $b against regular expression $a.\nIf $b is a string and matches the regular expression, a \\`re-match\\`-array is returned, otherwise \\`null\\` is returned.`,\n seeAlso: ['regexp', 'replace', 'replace-all', '-short-regexp', 'regexp?'],\n examples: [\n 're-match(\" A string\", regexp(\"^\\\\\\\\s*(.*)$\"))',\n 're-match(\" A string\", #\"^\\\\s*(.*)$\")',\n 're-match(\"My name is Albert\", #\"albert\"i)',\n 're-match(\"My name is Ben\", #\"albert\"i)',\n 're-match(null, #\"albert\"i)',\n 're-match(1, #\"albert\"i)',\n 're-match({}, #\"albert\"i)',\n ],\n },\n },\n 'replace': {\n evaluate: ([str, regexp, value], sourceCodeInfo): string => {\n assertString(str, sourceCodeInfo)\n assertStringOrRegularExpression(regexp, sourceCodeInfo)\n assertString(value, sourceCodeInfo)\n\n const matcher = isRegularExpression(regexp) ? new RegExp(regexp.s, `${regexp.f}`) : regexp\n return str.replace(matcher, value)\n },\n arity: toFixedArity(3),\n docs: {\n category: 'regular-expression',\n returns: { type: 'any', array: true },\n args: {\n a: { type: 'string' },\n b: { type: ['regexp', 'string'] },\n x: { type: 'string' },\n },\n variants: [{ argumentNames: ['a', 'b', 'x'] }],\n description: 'Returns a new string with first match of regular expression $b replaced by $x.',\n seeAlso: ['replace-all', 'regexp', 're-match', '-short-regexp'],\n examples: [\n 'replace(\"Duck duck\", \"u\", \"i\")',\n 'replace(\"Duck duck\", #\"u\", \"i\")',\n 'replace(\"abcABC\", regexp(\"a\", \"i\"), \"-\")',\n 'replace(\"abcABC\", regexp(\"a\", \"gi\"), \"-\")',\n 'replace(\"abcABC\", #\"a\"i, \"-\")',\n 'replace(\"abcABC\", #\"a\"gi, \"-\")',\n ],\n },\n },\n 'replace-all': {\n evaluate: ([str, regexp, value], sourceCodeInfo): string => {\n assertString(str, sourceCodeInfo)\n assertStringOrRegularExpression(regexp, sourceCodeInfo)\n assertString(value, sourceCodeInfo)\n const matcher = isRegularExpression(regexp) ? new RegExp(regexp.s, `${regexp.f.includes('g') ? regexp.f : `${regexp.f}g`}`) : regexp\n return str.replaceAll(matcher, value)\n },\n arity: toFixedArity(3),\n docs: {\n category: 'regular-expression',\n returns: { type: 'any', array: true },\n args: {\n a: { type: 'string' },\n b: { type: ['regexp', 'string'] },\n x: { type: 'string' },\n },\n variants: [{ argumentNames: ['a', 'b', 'x'] }],\n description: 'Returns a new string with all matches of regular expression $b replaced by $x.',\n seeAlso: ['replace', 'regexp', 're-match', '-short-regexp'],\n examples: [\n 'replace-all(\"Duck duck\", \"u\", \"i\")',\n 'replace-all(\"Duck duck\", regexp(\"u\"), \"i\")',\n 'replace-all(\"abcABC\", regexp(\"a\", \"i\"), \"-\")',\n 'replace-all(\"abcABC\", regexp(\"a\", \"gi\"), \"-\")',\n 'replace-all(\"abcABC\", #\"a\"i, \"-\")',\n 'replace-all(\"abcABC\", #\"a\"gi, \"-\")',\n ],\n },\n },\n}\n","import { DvalaError } from '../../errors'\nimport type { Arr } from '../../interface'\nimport { assertArray } from '../../typeGuards/array'\nimport { assertStringOrRegularExpression, isObj } from '../../typeGuards/dvala'\nimport { assertNumber } from '../../typeGuards/number'\nimport { assertString, assertStringOrNumber } from '../../typeGuards/string'\nimport { toFixedArity } from '../../utils/arity'\nimport type { BuiltinNormalExpressions } from '../interface'\n\nconst blankRegexp = /^\\s*$/\nexport const stringNormalExpression: BuiltinNormalExpressions = {\n 'str': {\n evaluate: (params: Arr) => {\n return params.reduce((result: string, param) => {\n const paramStr\n = param === undefined || param === null\n ? ''\n : isObj(param)\n ? JSON.stringify(param)\n : Array.isArray(param)\n ? JSON.stringify(param)\n : `${param}`\n return result + paramStr\n }, '')\n },\n arity: {},\n docs: {\n category: 'string',\n returns: { type: 'string' },\n args: { values: { type: 'any', rest: true } },\n variants: [{ argumentNames: ['values'] }],\n description: 'Concatenats $values into one string. If `value` equals `null` empty string is returned.',\n seeAlso: ['++', 'join', 'string.template', 'string.string-repeat', 'number'],\n examples: [\n 'str(\"A string\", \", and another string\", \" ...and more\")',\n 'str(\"Just one string\")',\n 'str()',\n 'str(0, false, true, null, #\"^kalle\", [1, 2, 3], {a: \"a\"})',\n ],\n hideOperatorForm: true,\n },\n },\n\n 'number': {\n evaluate: ([str], sourceCodeInfo): number => {\n assertString(str, sourceCodeInfo)\n const number = Number(str)\n if (Number.isNaN(number))\n throw new DvalaError(`Could not convert '${str}' to a number.`, sourceCodeInfo)\n\n return number\n },\n arity: toFixedArity(1),\n docs: {\n category: 'string',\n returns: { type: 'number' },\n args: { s: { type: 'string' } },\n variants: [{ argumentNames: ['s'] }],\n description: 'Parses $s to a number.',\n seeAlso: ['str', 'number?', 'integer?'],\n examples: [\n 'number(\"10\")',\n 'number(\"010\")',\n 'number(\"-1.01\")',\n ],\n },\n },\n\n 'lower-case': {\n evaluate: ([str], sourceCodeInfo): string => {\n assertString(str, sourceCodeInfo)\n return str.toLowerCase()\n },\n arity: toFixedArity(1),\n docs: {\n category: 'string',\n returns: { type: 'string' },\n args: { s: { type: 'string' } },\n variants: [{ argumentNames: ['s'] }],\n description: 'Returns $s converted to lower case.',\n seeAlso: ['upper-case', 'string.capitalize'],\n examples: [\n 'lower-case(\"Albert\")',\n 'lower-case(\"\")',\n ],\n },\n },\n\n 'upper-case': {\n evaluate: ([str], sourceCodeInfo): string => {\n assertString(str, sourceCodeInfo)\n return str.toUpperCase()\n },\n arity: toFixedArity(1),\n docs: {\n category: 'string',\n returns: { type: 'string' },\n args: { s: { type: 'string' } },\n variants: [{ argumentNames: ['s'] }],\n description: 'Returns $s converted to upper case.',\n seeAlso: ['lower-case', 'string.capitalize'],\n examples: [\n 'upper-case(\"Albert\")',\n 'upper-case(\"\")',\n ],\n },\n },\n\n 'trim': {\n evaluate: ([str], sourceCodeInfo): string => {\n assertString(str, sourceCodeInfo)\n return str.trim()\n },\n arity: toFixedArity(1),\n docs: {\n category: 'string',\n returns: { type: 'string' },\n args: { s: { type: 'string' } },\n variants: [{ argumentNames: ['s'] }],\n description: 'Returns a new string with leading and trailing whitespaces removed.',\n seeAlso: ['string.trim-left', 'string.trim-right', 'blank?'],\n examples: [\n 'trim(\" Albert \")',\n 'trim(\" \")',\n 'trim(\"\")',\n ],\n },\n },\n\n 'join': {\n evaluate: ([stringList, delimiter], sourceCodeInfo): string => {\n assertArray(stringList, sourceCodeInfo)\n stringList.forEach(str => assertStringOrNumber(str, sourceCodeInfo))\n assertString(delimiter, sourceCodeInfo)\n return stringList.join(delimiter)\n },\n arity: toFixedArity(2),\n docs: {\n category: 'string',\n returns: { type: 'string' },\n args: {\n a: { type: 'array' },\n b: { type: 'string' },\n arr: { type: 'array' },\n delimiter: { type: 'string' },\n },\n variants: [{ argumentNames: ['arr', 'delimiter'] }],\n description: 'Returns a new string by concatenating all of the elements in $arr, separated by $delimiter.',\n seeAlso: ['split', 'str', '++', 'sequence.interpose'],\n examples: [\n 'map([0, 1, 2, 3, 4, 5, 6, 7, 8, 9], str) join \", \"',\n '([0, 1, 2, 3, 4, 5, 6, 7, 8, 9] map str) join \", \"',\n 'join([\"Albert\", 10], \", \")',\n 'join([\"Albert\", \"Mojir\"], \" \")',\n 'join(map([0, 1, 2, 3, 4, 5, 6, 7, 8, 9], str), \", \")',\n ],\n },\n },\n\n 'split': {\n evaluate: ([str, stringOrRegExpValue, limit], sourceCodeInfo): string[] => {\n assertString(str, sourceCodeInfo)\n assertStringOrRegularExpression(stringOrRegExpValue, sourceCodeInfo)\n if (limit !== undefined)\n assertNumber(limit, sourceCodeInfo, { integer: true, nonNegative: true })\n\n const delimiter\n = typeof stringOrRegExpValue === 'string'\n ? stringOrRegExpValue\n : new RegExp(stringOrRegExpValue.s, stringOrRegExpValue.f)\n return str.split(delimiter, limit)\n },\n arity: { min: 2, max: 3 },\n docs: {\n category: 'string',\n returns: { type: 'string' },\n args: {\n a: { type: 'string' },\n b: { type: 'string' },\n s: { type: 'string' },\n delimiter: { type: 'string' },\n limit: { type: 'integer' },\n },\n variants: [\n { argumentNames: ['s', 'delimiter'] },\n { argumentNames: ['s', 'delimiter', 'limit'] },\n ],\n description: 'Divides $s into an array of substrings. The division is done by searching for `delimiter`. If `limit` as provided, at most `limit` number of substrings are returned.',\n seeAlso: ['join', 'string.split-lines'],\n examples: [\n '\"Albert Mojir\" split \" \"',\n 'split(\"Albert Mojir\", \" \")',\n 'split(\"abcdefghijklmnopqrstuvw\", #\"[aoueiy]\")',\n 'split(\"0123456789\", \"\")',\n 'split(\"0123456789\", \"\", 5) map number',\n ],\n },\n },\n 'blank?': {\n evaluate: ([value], sourceCodeInfo): boolean => {\n if (value === null) {\n return true\n }\n assertString(value, sourceCodeInfo)\n return blankRegexp.test(value)\n },\n arity: toFixedArity(1),\n docs: {\n category: 'string',\n returns: { type: 'boolean' },\n args: { s: { type: ['string', 'null'] } },\n variants: [{ argumentNames: ['s'] }],\n description: 'Returns true if $s is null or only contains whitespace characters.',\n seeAlso: ['trim', 'empty?', 'string?'],\n examples: [\n 'blank?(\"\")',\n 'blank?(null)',\n 'blank?(\"\\n\")',\n 'blank?(\" \")',\n 'blank?(\".\")',\n ],\n },\n },\n}\n","import type { Any, Arr } from '../../interface'\nimport type {\n CompFunction,\n ConstantlyFunction,\n FunctionLike,\n} from '../../parser/types'\nimport { toAny } from '../../utils'\nimport { getArityFromFunction, toFixedArity } from '../../utils/arity'\nimport type { MaybePromise } from '../../utils/maybePromise'\nimport { FUNCTION_SYMBOL } from '../../utils/symbols'\nimport type { BuiltinNormalExpressions } from '../interface'\nimport { assertArray } from '../../typeGuards/array'\nimport { assertFunctionLike } from '../../typeGuards/dvala'\n\nexport const functionalNormalExpression: BuiltinNormalExpressions = {\n '|>': {\n evaluate: ([value, func], sourceCodeInfo, contextStack, { executeFunction }): MaybePromise<Any> => {\n assertFunctionLike(func, sourceCodeInfo)\n return executeFunction(func, [value], contextStack, sourceCodeInfo)\n },\n arity: toFixedArity(2),\n docs: {\n category: 'functional',\n returns: { type: 'any' },\n args: {\n a: { type: 'any' },\n b: { type: 'function' },\n },\n variants: [{ argumentNames: ['a', 'b'] }],\n description: 'Takes a value $a and a function $b, and returns the result of applying $b to $a.',\n seeAlso: ['apply', 'comp'],\n examples: [\n `\n1 |> inc |> inc`,\n `range(10)\n |> map(_, -> $ ^ 2) // [0, 1, 4, 9, 16, 25, 36, 49, 64, 81]\n |> filter(_, odd?) // [1, 9, 25, 49, 81]\n |> reduce(_, +, 0) // 165\n |> sqrt // 12.84523257866513\n |> round(_, 2)`,\n ],\n },\n },\n 'apply': {\n evaluate: ([func, ...params]: Arr, sourceCodeInfo, contextStack, { executeFunction }): MaybePromise<Any> => {\n assertFunctionLike(func, sourceCodeInfo)\n const paramsLength = params.length\n const last = params[paramsLength - 1]\n assertArray(last, sourceCodeInfo)\n const applyArray = [...params.slice(0, -1), ...last]\n return executeFunction(func, applyArray, contextStack, sourceCodeInfo)\n },\n arity: { min: 2 },\n docs: {\n category: 'functional',\n returns: { type: 'any' },\n args: {\n a: { type: 'function' },\n b: { type: 'array' },\n fun: { type: 'function' },\n args: { type: 'array' },\n },\n variants: [{ argumentNames: ['fun', 'args'] }],\n description: 'Call supplied function $fun with specified arguments $args.',\n seeAlso: ['|>'],\n examples: [\n `\napply(+, [1, 2, 3])`,\n `\napply(\n (x, y) -> sqrt(x ^ 2 + y ^ 2),\n [3, 4]\n)`,\n `\n(x, y) -> sqrt(x ^ 2 + y ^ 2) apply [3, 4]`,\n ],\n },\n },\n\n 'identity': {\n evaluate: ([value]): Any => {\n return toAny(value)\n },\n arity: toFixedArity(1),\n docs: {\n category: 'functional',\n returns: { type: 'any' },\n args: { x: { type: 'any' } },\n variants: [{ argumentNames: ['x'] }],\n description: 'Returns $x.',\n seeAlso: ['constantly', 'functional.fnull'],\n examples: ['identity(1)', 'identity(\"Albert\")', 'identity({ a: 1 })', 'identity(null)'],\n },\n },\n\n 'comp': {\n evaluate: (params, sourceCodeInfo): CompFunction => {\n params.forEach(param => assertFunctionLike(param, sourceCodeInfo))\n return {\n [FUNCTION_SYMBOL]: true,\n sourceCodeInfo,\n functionType: 'Comp',\n params,\n arity: params.length > 0 ? getArityFromFunction(params.at(-1) as FunctionLike) : { min: 1, max: 1 },\n }\n },\n arity: {},\n docs: {\n category: 'functional',\n returns: { type: 'function' },\n args: {\n a: { type: 'function' },\n b: { type: 'function' },\n fns: { type: 'function', rest: true },\n },\n variants: [{ argumentNames: ['fns'] }],\n description: `Takes a variable number of functions and returns a function that is the composition of those.\n\n The returned function takes a variable number of arguments,\n applies the rightmost function to the args,\n the next function (right-to-left) to the result, etc.`,\n seeAlso: ['|>', 'functional.juxt', 'functional.complement'],\n examples: [\n `\nlet negative-quotient = comp(-, /);\nnegative-quotient(9, 3)`,\n `\nlet x = { bar: { foo: 42 } };\ncomp(\"foo\", \"bar\")(x)`,\n ],\n },\n },\n\n 'constantly': {\n evaluate: ([value], sourceCodeInfo): ConstantlyFunction => {\n return {\n [FUNCTION_SYMBOL]: true,\n sourceCodeInfo,\n functionType: 'Constantly',\n value: toAny(value),\n arity: {},\n }\n },\n arity: toFixedArity(1),\n docs: {\n category: 'functional',\n returns: { type: 'function' },\n args: { x: { type: 'any' } },\n variants: [{ argumentNames: ['x'] }],\n description: 'Returns a function that takes any number of arguments and always returns $x.',\n seeAlso: ['identity', 'functional.fnull'],\n examples: [\n `\nlet always-true = constantly(true);\nalways-true(9, 3)`,\n ],\n },\n },\n\n}\n","import { smartTrim } from '..'\nimport type { Argument, FunctionReference, TypedValue } from '../../../reference'\n\nexport function generateDocString(reference: FunctionReference): string {\n return smartTrim(`\n ${reference.title}\n\n ${reference.description\n .replace(/`(.+?)`/g, '$1')\n .replace(/\\$(\\w+)/g, '$1')\n .replace(/\\*\\*\\*(.+)\\*\\*\\*/g, '$1')\n .replace(/\\*\\*(.+)\\*\\*/g, '$1')\n }\n\n Signature:\n ${signature(reference).join('\\n ')}\n\n Arguments:\n ${argStrings(reference).join('\\n ')}\n\n Examples:\n${reference.examples.map(example => smartTrim(example, 4)).join('\\n\\n')}`)\n}\n\nfunction signature({ title, variants, args, returns, _isOperator }: FunctionReference): string[] {\n const functionForms = variants.map((variant) => {\n const form = ` ${title}(${variant.argumentNames.map((argName) => {\n let result = ''\n const arg = args[argName]!\n if (arg.rest) {\n result += '...'\n }\n result += argName\n return result\n }).join(', ')})`\n\n return `${form} -> ${type(returns)}`\n })\n\n const operatorForm = _isOperator ? ['', 'Operator:', ` a ${title} b -> ${type(returns)}`] : []\n\n return [\n ...functionForms,\n ...operatorForm,\n ]\n}\n\nfunction type(arg: Argument | TypedValue) {\n const argType = arg.type\n const types = Array.isArray(argType) ? argType : [argType]\n const typeString = types.join(' | ')\n return arg.array || arg.rest ? `Array<${typeString}>` : typeString\n}\n\nfunction argStrings(reference: FunctionReference): string[] {\n return Object.entries(reference.args).map(([argName, arg]) => `${argName}: ${type(arg)}`)\n}\n","import type { FunctionReference } from '../../../reference'\nimport { assertNonUndefined } from '../../typeGuards'\nimport { assertFunctionLike } from '../../typeGuards/dvala'\nimport { isDvalaFunction } from '../../typeGuards/dvalaFunction'\nimport { toFixedArity } from '../../utils/arity'\nimport { generateDocString } from '../../utils/docString/generateDocString'\nimport type { Arity, BuiltinNormalExpressions } from '../interface'\n\nexport function getMetaNormalExpression(normalExpressionReference: Record<string, FunctionReference>): BuiltinNormalExpressions {\n return {\n doc: {\n evaluate: ([fn], sourceCodeInfo): string => {\n assertNonUndefined(normalExpressionReference)\n assertFunctionLike(fn, sourceCodeInfo)\n if (!isDvalaFunction(fn)) {\n return ''\n }\n if (fn.functionType === 'Builtin') {\n const reference = normalExpressionReference[fn.name]\n return reference ? generateDocString(reference) : ''\n }\n if (fn.functionType === 'UserDefined' || fn.functionType === 'NativeJsFunction') {\n return fn.docString\n }\n return ''\n },\n arity: toFixedArity(1),\n docs: {\n category: 'meta',\n returns: { type: 'string' },\n args: { fun: { type: 'function' } },\n variants: [{ argumentNames: ['fun'] }],\n description: 'Returns documentation string of the $fun.',\n seeAlso: ['arity'],\n examples: [\n 'doc(+)',\n `\nlet add = (x, y) -> do\n \"\"\"\n Adds two numbers.\n Args:\n x: First number.\n y: Second number.\n Returns:\n Sum of x and y.\n \"\"\";\n x + y;\nend;\n\ndoc(add)`,\n ],\n },\n },\n arity: {\n evaluate: ([fn], sourceCodeInfo): Arity => {\n assertFunctionLike(fn, sourceCodeInfo)\n return isDvalaFunction(fn) ? fn.arity : toFixedArity(1)\n },\n arity: toFixedArity(1),\n docs: {\n category: 'meta',\n returns: { type: 'object' },\n args: { fun: { type: 'function' } },\n variants: [{ argumentNames: ['fun'] }],\n description: 'Returns arity of the $fun. The arity is an object with the properties: `min` and `max`. If the function has fixed arity, `min` and `max` are equal to the number of required parameters. If no restrictions apply, empty object is returned.',\n seeAlso: ['doc'],\n examples: [\n 'arity(+)',\n 'arity(defined?)',\n `\nlet add = (x, y = 0) -> do\n x + y;\nend;\n\narity(add)`,\n `\nlet foo = (k, ...x) -> do\n k + x;\nend;\n arity(foo)`,\n ],\n },\n },\n }\n}\n","import { assertNonEmptyVector, assertVector } from '../../typeGuards/annotatedArrays'\nimport { toFixedArity } from '../../utils/arity'\nimport type { BuiltinNormalExpressions } from '../interface'\n\nfunction calcMedian(vector: number[]): number {\n const sorted = [...vector].sort((a, b) => a - b)\n const mid = Math.floor(sorted.length / 2)\n return sorted.length % 2 === 0\n ? (sorted[mid - 1]! + sorted[mid]!) / 2\n : sorted[mid]!\n}\n\nexport const vectorNormalExpression: BuiltinNormalExpressions = {\n sum: {\n evaluate: ([vector], sourceCodeInfo): number => {\n assertVector(vector, sourceCodeInfo)\n return vector.reduce((acc, val) => acc + val, 0)\n },\n arity: toFixedArity(1),\n docs: {\n category: 'vector',\n returns: { type: 'number' },\n args: {\n vector: { type: 'vector', description: 'The vector to sum.' },\n },\n variants: [{ argumentNames: ['vector'] }],\n description: 'Returns the **sum** of all elements in the `vector`. Returns `0` for an empty vector.',\n seeAlso: ['prod', 'mean', 'median', 'vector.moving-sum', 'vector.centered-moving-sum', 'vector.running-sum', 'vector.cumsum'],\n examples: [\n 'sum([1, 2, 3, 4, 5])',\n 'sum([1, -2, 3])',\n 'sum([])',\n ],\n },\n },\n\n prod: {\n evaluate: ([vector], sourceCodeInfo): number => {\n assertVector(vector, sourceCodeInfo)\n return vector.reduce((acc, val) => acc * val, 1)\n },\n arity: toFixedArity(1),\n docs: {\n category: 'vector',\n returns: { type: 'number' },\n args: {\n vector: { type: 'vector', description: 'The vector to multiply.' },\n },\n variants: [{ argumentNames: ['vector'] }],\n description: 'Returns the **product** of all elements in the `vector`. Returns `1` for an empty vector.',\n seeAlso: ['sum', 'mean', 'median', 'vector.moving-prod', 'vector.centered-moving-prod', 'vector.running-prod', 'vector.cumprod'],\n examples: [\n 'prod([1, 2, 3, 4, 5])',\n 'prod([1, -2, 3])',\n 'prod([])',\n ],\n },\n },\n\n mean: {\n evaluate: ([vector], sourceCodeInfo): number => {\n assertNonEmptyVector(vector, sourceCodeInfo)\n return vector.reduce((acc, val) => acc + val, 0) / vector.length\n },\n arity: toFixedArity(1),\n docs: {\n category: 'vector',\n returns: { type: 'number' },\n args: {\n vector: { type: 'vector', description: 'The vector to calculate the mean of.' },\n },\n variants: [{ argumentNames: ['vector'] }],\n description: 'Returns the arithmetic **mean** of all elements in the `vector`. Throws for an empty vector.',\n seeAlso: ['median', 'sum', 'prod', 'vector.moving-mean', 'vector.centered-moving-mean', 'vector.running-mean', 'vector.geometric-mean', 'vector.harmonic-mean', 'vector.rms', 'vector.mode'],\n examples: [\n 'mean([1, 2, 3, 4, 5])',\n 'mean([1, -2, 3])',\n ],\n },\n },\n\n median: {\n evaluate: ([vector], sourceCodeInfo): number => {\n assertNonEmptyVector(vector, sourceCodeInfo)\n return calcMedian(vector)\n },\n arity: toFixedArity(1),\n docs: {\n category: 'vector',\n returns: { type: 'number' },\n args: {\n vector: { type: 'vector', description: 'The vector to calculate the median of.' },\n },\n variants: [{ argumentNames: ['vector'] }],\n description: 'Returns the **median** of all elements in the `vector`. For even-length vectors, returns the average of the two middle values. Throws for an empty vector.',\n seeAlso: ['mean', 'sum', 'prod', 'vector.moving-median', 'vector.centered-moving-median', 'vector.running-median', 'vector.mode', 'vector.quartiles', 'vector.percentile', 'vector.iqr', 'vector.medad'],\n examples: [\n 'median([1, 2, 3, 4, 5])',\n 'median([1, 2, 3, 4])',\n 'median([3, 1, 4, 1, 5])',\n ],\n },\n },\n}\n","import type { BuiltinNormalExpression, BuiltinNormalExpressions } from '../interface'\nimport type { Any } from '../../interface'\nimport type { FunctionReference } from '../../../reference'\nimport type { CoreNormalExpressionName } from '../../../reference/api'\n\n// Core categories - always available\nimport { assertionNormalExpression } from '../core/assertion'\nimport { bitwiseNormalExpression } from '../core/bitwise'\nimport { collectionNormalExpression } from '../core/collection'\nimport { arrayNormalExpression } from '../core/array'\nimport { sequenceNormalExpression } from '../core/sequence'\nimport { mathNormalExpression } from '../core/math'\nimport { miscNormalExpression } from '../core/misc'\nimport { objectNormalExpression } from '../core/object'\nimport { predicatesNormalExpression } from '../core/predicates'\nimport { regexpNormalExpression } from '../core/regexp'\nimport { stringNormalExpression } from '../core/string'\nimport { functionalNormalExpression } from '../core/functional'\nimport { getMetaNormalExpression } from '../core/meta'\nimport { vectorNormalExpression } from '../core/vector'\n\nconst normalExpressionReference: Record<string, FunctionReference> = {}\n\nexport function setNormalExpressionReference(reference: Record<CoreNormalExpressionName, FunctionReference>) {\n Object.assign(normalExpressionReference, reference)\n}\n\nconst expressions: BuiltinNormalExpressions = {\n // Core categories\n ...assertionNormalExpression,\n ...bitwiseNormalExpression,\n ...collectionNormalExpression,\n ...arrayNormalExpression,\n ...sequenceNormalExpression,\n ...mathNormalExpression,\n ...getMetaNormalExpression(normalExpressionReference),\n ...miscNormalExpression,\n ...objectNormalExpression,\n ...predicatesNormalExpression,\n ...regexpNormalExpression,\n ...stringNormalExpression,\n ...functionalNormalExpression,\n ...vectorNormalExpression,\n}\n\nObject.entries(expressions).forEach(([name, expression]) => {\n expression.name = name\n})\n\nexport const normalExpressions: BuiltinNormalExpressions = {\n ...expressions,\n}\n\nexport const normalExpressionTypes: Record<string, number> = {}\nexport const allNormalExpressions: BuiltinNormalExpression<Any>[] = []\n\nObject.entries(normalExpressions).forEach(([key, value], index) => {\n normalExpressionTypes[key] = index\n allNormalExpressions.push(value)\n})\n","import type { Any } from '../../interface'\nimport type { AstNode, SpecialExpressionNode } from '../../parser/types'\nimport { asAny } from '../../typeGuards/dvala'\nimport type { BuiltinSpecialExpression, FunctionDocs } from '../interface'\nimport type { specialExpressionTypes } from '../specialExpressionTypes'\n\nexport type AndNode = SpecialExpressionNode<[typeof specialExpressionTypes['&&'], AstNode[]]>\n\nconst docs: FunctionDocs = {\n category: 'special-expression',\n returns: {\n type: 'any',\n },\n args: {\n a: { type: 'any' },\n b: { type: 'any' },\n c: {\n type: 'any',\n rest: true,\n },\n },\n variants: [\n { argumentNames: ['a', 'b'] },\n { argumentNames: ['a', 'b', 'c'] },\n ],\n description: `\nComputes logical \\`and\\`. Evaluation of expressions starts from left.\nAs soon as an \\`expression\\` evaluates to a falsy value, the result is returned.\n\nIf all expressions evaluate to truthy values, the value of the last expression is returned.`,\n examples: [\n 'true && 1',\n '&&(1, 1)',\n '&&(3 > 2, \"string\")',\n '&&(3 < 2, \"string\")',\n '&&(true, true, true, true)',\n '&&(true, true, 0, true)',\n ],\n}\n\nexport const andSpecialExpression: BuiltinSpecialExpression<Any, AndNode> = {\n arity: {},\n docs,\n evaluateAsNormalExpression: (params, sourceCodeInfo) => {\n let value: Any = true\n for (const param of params) {\n value = asAny(param, sourceCodeInfo)\n if (!value)\n break\n }\n return value\n },\n\n getUndefinedSymbols: (node, contextStack, { getUndefinedSymbols, builtin, evaluateNode }) => getUndefinedSymbols(node[1][1], contextStack, builtin, evaluateNode),\n}\n","import type { Any } from '../../interface'\nimport type { AstNode, SpecialExpressionNode } from '../../parser/types'\nimport type { BuiltinSpecialExpression, CustomDocs } from '../interface'\nimport type { specialExpressionTypes } from '../specialExpressionTypes'\n\nexport type CondNode = SpecialExpressionNode<[typeof specialExpressionTypes['cond'], [AstNode, AstNode][]]>\n\nconst docs: CustomDocs = {\n category: 'special-expression',\n customVariants: ['cond cond-branch cond-branch ... end'],\n details: [\n ['cond-branch', 'case test then body', 'A branch of the cond expression.'],\n ['test', 'expression', 'The condition to test.'],\n ['body', 'expressions', 'The expressions to evaluate if the test is truthy.'],\n ],\n description: 'Used for branching. `cond-branches` are tested sequentially from the top. If no branch is tested truthy, `null` is returned.',\n examples: [\n `\ncond\n case false then write!(\"FALSE\")\n case true then write!(\"TRUE\")\nend`,\n `\ncond\n case false then write!(\"FALSE\")\n case null then write!(\"null\")\nend ?? write!(\"TRUE\")`,\n `\ncond\n case false then write!(\"FALSE\")\n case null then write!(\"null\")\nend ?? write!(\"TRUE\")`,\n ],\n}\n\nexport const condSpecialExpression: BuiltinSpecialExpression<Any, CondNode> = {\n arity: {},\n docs,\n getUndefinedSymbols: (node, contextStack, { getUndefinedSymbols, builtin, evaluateNode }) => getUndefinedSymbols(node[1][1].flat(), contextStack, builtin, evaluateNode),\n}\n","import type { JsFunction } from '../Dvala/Dvala'\nimport type { SpecialExpressionType } from '../builtin'\nimport type { Arity } from '../builtin/interface'\nimport type { specialExpressionTypes } from '../builtin/specialExpressionTypes'\nimport type { FunctionType, NodeType, NodeTypes } from '../constants/constants'\nimport type { Context } from '../evaluator/interface'\nimport type { Any, Arr, Coll } from '../interface'\nimport type { ReservedSymbol } from '../tokenizer/reservedNames'\nimport type { SourceCodeInfo } from '../tokenizer/token'\nimport type { EFFECT_SYMBOL, FUNCTION_SYMBOL, REGEXP_SYMBOL } from '../utils/symbols'\n\nexport type EvaluatedFunction = [BindingTarget[], AstNode[], Context]\n\ninterface GenericDvalaFunction {\n [FUNCTION_SYMBOL]: true\n sourceCodeInfo?: SourceCodeInfo\n functionType: FunctionType\n arity: Arity\n}\n\nexport interface RegularExpression {\n [REGEXP_SYMBOL]: true\n sourceCodeInfo?: SourceCodeInfo\n s: string\n f: string\n}\n\nexport interface EffectRef {\n [EFFECT_SYMBOL]: true\n name: string // e.g. 'llm.complete'\n}\n\nexport interface NativeJsFunction extends GenericDvalaFunction {\n functionType: 'NativeJsFunction'\n name: string | undefined // name\n nativeFn: JsFunction\n docString: string // documentation string\n}\n\nexport interface UserDefinedFunction extends GenericDvalaFunction {\n functionType: 'UserDefined'\n name: string | undefined // name\n evaluatedfunction: EvaluatedFunction\n docString: string // documentation string\n}\n\nexport interface PartialFunction extends GenericDvalaFunction {\n functionType: 'Partial'\n function: FunctionLike\n params: Arr\n placeholders: number[] // indexes of the placeholders\n}\n\nexport interface CompFunction extends GenericDvalaFunction {\n functionType: 'Comp'\n params: Arr\n}\n\nexport interface ConstantlyFunction extends GenericDvalaFunction {\n functionType: 'Constantly'\n value: Any\n}\n\nexport interface JuxtFunction extends GenericDvalaFunction {\n functionType: 'Juxt'\n params: Arr\n}\n\nexport interface ComplementFunction extends GenericDvalaFunction {\n functionType: 'Complement'\n function: FunctionLike\n}\n\nexport interface EveryPredFunction extends GenericDvalaFunction {\n functionType: 'EveryPred'\n params: Arr\n}\n\nexport interface SomePredFunction extends GenericDvalaFunction {\n functionType: 'SomePred'\n params: Arr\n}\n\nexport interface FNullFunction extends GenericDvalaFunction {\n functionType: 'Fnull'\n function: FunctionLike\n params: Arr\n}\n\nexport interface NormalBuiltinFunction extends GenericDvalaFunction {\n functionType: 'Builtin'\n normalBuiltinSymbolType: number\n name: string\n}\n\nexport interface SpecialBuiltinFunction extends GenericDvalaFunction {\n functionType: 'SpecialBuiltin'\n specialBuiltinSymbolType:\n | typeof specialExpressionTypes['&&']\n | typeof specialExpressionTypes['||']\n | typeof specialExpressionTypes['array']\n | typeof specialExpressionTypes['object']\n | typeof specialExpressionTypes['defined?']\n | typeof specialExpressionTypes['recur']\n | typeof specialExpressionTypes['throw']\n | typeof specialExpressionTypes['??']\n}\n\nexport interface ModuleFunction extends GenericDvalaFunction {\n functionType: 'Module'\n moduleName: string\n functionName: string\n}\n\nexport type DvalaFunction =\n | NativeJsFunction\n | UserDefinedFunction\n | NormalBuiltinFunction\n | SpecialBuiltinFunction\n | ModuleFunction\n | PartialFunction\n | CompFunction\n | ConstantlyFunction\n | JuxtFunction\n | ComplementFunction\n | EveryPredFunction\n | SomePredFunction\n | FNullFunction\n\nexport type DvalaFunctionType = DvalaFunction['functionType']\n\nexport type FunctionLike = DvalaFunction | Coll | number\n\nexport type AstNode<T extends NodeType = NodeType, Payload = unknown> = [T, Payload] | [T, Payload, SourceCodeInfo]\n\nexport type ExpressionNode = NormalExpressionNode | SpecialExpressionNode | NumberNode | StringNode\n\nexport type SpreadNode = AstNode<typeof NodeTypes.Spread, AstNode> // Payload should be array or object depending on context\nexport type NumberNode = AstNode<typeof NodeTypes.Number, number>\nexport type StringNode = AstNode<typeof NodeTypes.String, string>\nexport type UserDefinedSymbolNode = AstNode<typeof NodeTypes.UserDefinedSymbol, string>\nexport type NormalBuiltinSymbolNode = AstNode<typeof NodeTypes.NormalBuiltinSymbol, number>\nexport type SpecialBuiltinSymbolNode = AstNode<typeof NodeTypes.SpecialBuiltinSymbol, SpecialExpressionType>\nexport type SymbolNode = UserDefinedSymbolNode | NormalBuiltinSymbolNode | SpecialBuiltinSymbolNode\nexport type ReservedSymbolNode = AstNode<typeof NodeTypes.ReservedSymbol, ReservedSymbol>\nexport type SpecialExpressionNode<T extends [SpecialExpressionType, ...unknown[]] = [SpecialExpressionType, ...unknown[]]> = AstNode<typeof NodeTypes.SpecialExpression, T> // [name, params]\n\nexport type NormalExpressionNodeWithName = AstNode<typeof NodeTypes.NormalExpression, [NormalBuiltinSymbolNode | UserDefinedSymbolNode, AstNode[]]> // [params, name]\nexport type NormalExpressionNodeExpression = AstNode<typeof NodeTypes.NormalExpression, [AstNode, AstNode[]]> // [name, node as function] node can be string number object or array\nexport type NormalExpressionNode = NormalExpressionNodeWithName | NormalExpressionNodeExpression\nexport const bindingTargetTypes = {\n symbol: 11,\n rest: 12,\n object: 13,\n array: 14,\n literal: 15,\n wildcard: 16,\n} as const\n\nexport type BindingTargetType = typeof bindingTargetTypes[keyof typeof bindingTargetTypes]\n\ntype GenericTarget<T extends BindingTargetType, Payload extends unknown[]> = [T, Payload] | [T, Payload, SourceCodeInfo]\n\nexport type SymbolBindingTarget = GenericTarget<typeof bindingTargetTypes.symbol, [SymbolNode, AstNode | undefined /* default value */]>\nexport type RestBindingTarget = GenericTarget<typeof bindingTargetTypes.rest, [string, AstNode | undefined /* default value */]>\nexport type ObjectBindingTarget = GenericTarget<typeof bindingTargetTypes.object, [Record<string, BindingTarget>, AstNode | undefined /* default value */]>\nexport type ArrayBindingTarget = GenericTarget<typeof bindingTargetTypes.array, [(BindingTarget | null)[], AstNode | undefined /* default value */]>\nexport type LiteralBindingTarget = GenericTarget<typeof bindingTargetTypes.literal, [AstNode /* literal expression */]>\nexport type WildcardBindingTarget = GenericTarget<typeof bindingTargetTypes.wildcard, []>\n\nexport type BindingTarget = SymbolBindingTarget | RestBindingTarget | ObjectBindingTarget | ArrayBindingTarget | LiteralBindingTarget | WildcardBindingTarget\n\nexport type BindingNode = AstNode<typeof NodeTypes.Binding, [BindingTarget, AstNode]> // [target, value]\n\ntype AstBody = AstNode[]\nexport interface Ast {\n body: AstBody // body\n hasDebugData: boolean\n}\n","import { DvalaError } from '../errors'\nimport type { Any } from '../interface'\nimport { type ArrayBindingTarget, type AstNode, type BindingTarget, type RestBindingTarget, type UserDefinedSymbolNode, bindingTargetTypes } from '../parser/types'\nimport type { SourceCodeInfo } from '../tokenizer/token'\nimport { assertUnknownRecord, isUnknownRecord } from '../typeGuards'\nimport { assertArray } from '../typeGuards/array'\nimport { asAny, assertAny } from '../typeGuards/dvala'\nimport type { MaybePromise } from '../utils/maybePromise'\nimport { chain, forEachSequential } from '../utils/maybePromise'\nimport { deepEqual } from '../utils'\n\nexport function walkDefaults(\n bindingTarget: BindingTarget,\n onDefault: (Node: AstNode) => void,\n): void {\n if (bindingTarget[0] === bindingTargetTypes.object) {\n Object.values(bindingTarget[1][0]).forEach((element) => {\n if (element[1][1]) {\n onDefault(element[1][1])\n }\n walkDefaults(element, onDefault)\n })\n }\n else if (bindingTarget[0] === bindingTargetTypes.array) {\n for (let index = 0; index < bindingTarget[1][0].length; index += 1) {\n const element = bindingTarget[1][0][index] ?? null\n if (element === null) {\n continue\n }\n if (element[1][1]) {\n onDefault(element[1][1])\n }\n walkDefaults(element, onDefault)\n }\n }\n // literal and wildcard have no defaults - nothing to walk\n}\n\nexport function evaluateBindingNodeValues(\n target: BindingTarget,\n value: Any,\n evaluate: (Node: AstNode) => MaybePromise<Any>,\n): MaybePromise<Record<string, Any>> {\n const sourceCodeInfo = target[2]\n const record: Record<string, Any> = {}\n return chain(createRecord(target, value, evaluate, sourceCodeInfo, record), () => record)\n}\n\nfunction createRecord(\n bindingTarget: BindingTarget,\n value: Any,\n evaluate: (Node: AstNode) => MaybePromise<Any>,\n sourceCodeInfo: SourceCodeInfo | undefined,\n record: Record<string, Any>,\n): MaybePromise<void> {\n if (bindingTarget[0] === bindingTargetTypes.object) {\n assertUnknownRecord(value, sourceCodeInfo)\n const capturedKeys = new Set<string>()\n let restElement: RestBindingTarget | undefined\n const entries = Object.entries(bindingTarget[1][0])\n\n return chain(\n forEachSequential(entries, ([key, element]) => {\n if (element[0] === bindingTargetTypes.rest) {\n restElement = element\n return\n }\n capturedKeys.add(key)\n const existingVal = value[key]\n const maybeVal: MaybePromise<Any> = existingVal !== undefined\n ? existingVal as Any\n : element[1][1]\n ? evaluate(element[1][1])\n : null\n return chain(maybeVal, (resolvedVal) => {\n const val = resolvedVal ?? null\n assertAny(val, sourceCodeInfo)\n return createRecord(element, val, evaluate, sourceCodeInfo, record)\n })\n }),\n () => {\n if (restElement) {\n const restValues = Object.entries(value)\n .filter(([key]) => !capturedKeys.has(key))\n .reduce((acc: Record<string, Any>, [key, val]) => {\n acc[key] = asAny(val)\n return acc\n }, {})\n\n record[restElement[1][0]] = restValues\n }\n },\n )\n }\n else if (bindingTarget[0] === bindingTargetTypes.array) {\n let restIndex: number | null = null\n assertArray(value, sourceCodeInfo)\n\n const elements: Array<{ element: BindingTarget, index: number }> = []\n for (let index = 0; index < bindingTarget[1][0].length; index += 1) {\n const element = bindingTarget[1][0][index] ?? null\n if (element === null) {\n continue\n }\n if (element[0] === bindingTargetTypes.rest) {\n restIndex = index\n break\n }\n elements.push({ element, index })\n }\n\n return chain(\n forEachSequential(elements, ({ element, index }) => {\n const existingVal = value[index]\n const maybeVal: MaybePromise<Any> = existingVal !== undefined\n ? existingVal as Any\n : element[1][1]\n ? evaluate(element[1][1])\n : null\n return chain(maybeVal, (resolvedVal) => {\n const val = resolvedVal ?? null\n assertAny(val, sourceCodeInfo)\n return createRecord(element, val, evaluate, sourceCodeInfo, record)\n })\n }),\n () => {\n if (restIndex !== null) {\n const restValues = value.slice(restIndex)\n const restElement = bindingTarget[1][0][restIndex]! as RestBindingTarget\n record[restElement[1][0]] = restValues\n }\n },\n )\n }\n else if (bindingTarget[0] === bindingTargetTypes.rest) {\n record[bindingTarget[1][0]] = asAny(value)\n }\n else {\n record[(bindingTarget[1][0] as UserDefinedSymbolNode)[1]] = asAny(value)\n }\n}\n\nexport function getAllBindingTargetNames(bindingTarget: BindingTarget): Record<string, true> {\n const names: Record<string, true> = {}\n getNamesFromBindingTarget(bindingTarget, names)\n return names\n}\n\nfunction getNamesFromBindingTarget(target: BindingTarget | null, names: Record<string, true>): void {\n if (target === null) {\n return\n }\n if (target[0] === bindingTargetTypes.array) {\n for (const element of target[1][0]) {\n getNamesFromBindingTarget(element, names)\n }\n }\n else if (target[0] === bindingTargetTypes.object) {\n for (const element of Object.values(target[1][0])) {\n getNamesFromBindingTarget(element, names)\n }\n }\n else if (target[0] === bindingTargetTypes.rest) {\n if (names[target[1][0]]) {\n throw new DvalaError(`Duplicate binding name: ${target[1][0]}`, target[2])\n }\n names[target[1][0]] = true\n }\n else if (target[0] === bindingTargetTypes.symbol) {\n if (names[target[1][0][1]]) {\n throw new DvalaError(`Duplicate binding name: ${target[1][0]}`, target[2])\n }\n names[target[1][0][1]] = true\n }\n // literal and wildcard bind no names - skip\n}\n\n/**\n * Non-throwing pattern matching. Returns bindings on match, null on mismatch.\n * Used by `switch` pattern matching.\n */\nexport function tryMatch(\n target: BindingTarget,\n value: Any,\n evaluate: (Node: AstNode) => MaybePromise<Any>,\n): MaybePromise<Record<string, Any> | null> {\n const record: Record<string, Any> = {}\n return chain(tryMatchRecord(target, value, evaluate, record), (matched) => {\n if (!matched)\n return null\n return record\n })\n}\n\nfunction tryMatchRecord(\n bindingTarget: BindingTarget,\n value: Any,\n evaluate: (Node: AstNode) => MaybePromise<Any>,\n record: Record<string, Any>,\n): MaybePromise<boolean> {\n // Wildcard: always matches, binds nothing\n if (bindingTarget[0] === bindingTargetTypes.wildcard) {\n return true\n }\n\n // Literal: compare with deepEqual\n else if (bindingTarget[0] === bindingTargetTypes.literal) {\n const literalNode = bindingTarget[1][0]\n return chain(evaluate(literalNode), (literalValue) => {\n return deepEqual(value, literalValue)\n })\n }\n\n // Symbol: always matches, binds value\n else if (bindingTarget[0] === bindingTargetTypes.symbol) {\n const symbolNode = bindingTarget[1][0] as UserDefinedSymbolNode\n const defaultNode = bindingTarget[1][1]\n if (value === undefined || value === null) {\n if (defaultNode) {\n return chain(evaluate(defaultNode), (defaultValue) => {\n record[symbolNode[1]] = asAny(defaultValue)\n return true\n })\n }\n record[symbolNode[1]] = value ?? null\n }\n else {\n record[symbolNode[1]] = asAny(value)\n }\n return true\n }\n\n // Object pattern\n else if (bindingTarget[0] === bindingTargetTypes.object) {\n if (!isUnknownRecord(value))\n return false\n\n const capturedKeys = new Set<string>()\n let restElement: RestBindingTarget | undefined\n const entries = Object.entries(bindingTarget[1][0])\n\n let result: MaybePromise<boolean> = true\n for (const [key, element] of entries) {\n result = chain(result, (matched) => {\n if (!matched)\n return false\n\n if (element[0] === bindingTargetTypes.rest) {\n restElement = element\n return true\n }\n\n capturedKeys.add(key)\n const existingVal = value[key]\n\n // For literal sub-patterns, missing key means no match\n if (existingVal === undefined && element[0] === bindingTargetTypes.literal) {\n return chain(evaluate(element[1][0]), (literalValue) => {\n return deepEqual(undefined, literalValue)\n })\n }\n\n const maybeVal: MaybePromise<Any> = existingVal !== undefined\n ? existingVal as Any\n : element[1] && element[1][1]\n ? evaluate(element[1][1])\n : null\n\n return chain(maybeVal, (resolvedVal) => {\n const val = resolvedVal ?? null\n return tryMatchRecord(element, val, evaluate, record)\n })\n })\n }\n\n return chain(result, (matched) => {\n if (!matched)\n return false\n if (restElement) {\n const restValues = Object.entries(value)\n .filter(([key]) => !capturedKeys.has(key))\n .reduce((acc: Record<string, Any>, [key, val]) => {\n acc[key] = asAny(val)\n return acc\n }, {})\n record[restElement[1][0]] = restValues\n }\n return true\n })\n }\n\n // Array pattern\n else {\n const arrayTarget = bindingTarget as ArrayBindingTarget\n if (!Array.isArray(value))\n return false\n\n const elements = arrayTarget[1][0]\n let restIndex: number | null = null\n\n // Find rest element index and check length constraints\n for (let i = 0; i < elements.length; i += 1) {\n const element = elements[i]!\n if (element !== null && element[0] === bindingTargetTypes.rest) {\n restIndex = i\n break\n }\n }\n\n // Without rest: array length must match exactly\n if (restIndex === null && value.length !== elements.length) {\n return false\n }\n // With rest: array must have at least the non-rest elements\n if (restIndex !== null && value.length < restIndex) {\n return false\n }\n\n let result: MaybePromise<boolean> = true\n for (let i = 0; i < elements.length; i += 1) {\n const element = elements[i]!\n if (element === null)\n continue // skipped position\n\n if (element[0] === bindingTargetTypes.rest) {\n // Rest collects remaining elements\n record[element[1][0]] = value.slice(i)\n break\n }\n\n const el = element\n result = chain(result, (matched) => {\n if (!matched)\n return false\n\n return tryMatchRecord(el, asAny(value[i]), evaluate, record)\n })\n }\n return result\n }\n}\n","import type { Any, Obj } from '../../interface'\nimport type { AstNode, SpecialExpressionNode } from '../../parser/types'\nimport { assertString } from '../../typeGuards/string'\nimport type { BuiltinSpecialExpression, FunctionDocs } from '../interface'\nimport type { specialExpressionTypes } from '../specialExpressionTypes'\n\nexport type ObjectNode = SpecialExpressionNode<[typeof specialExpressionTypes['object'], AstNode[]]>\n\nconst docs: FunctionDocs = {\n category: 'special-expression',\n returns: {\n type: 'object',\n },\n args: {\n kvps: {\n type: 'any',\n rest: true,\n description: 'key - value pairs, where key is a string',\n },\n },\n variants: [\n { argumentNames: ['kvps'] },\n ],\n description: 'Constructs a new object. Object members are created from the $kvps key-value pairs. Requires an even number of arguments.',\n examples: [\n 'object()',\n `\nlet default = {\n type: \"Person\",\n name: \"John Doe\",\n age: 42\n};\n\n{\n ...default,\n name: \"Lisa\"\n}`,\n 'object(\"x\", 10, \"y\", true, \"z\", \"A string\")',\n '{}',\n '{ a: 1, b: 2 }',\n ],\n hideOperatorForm: true,\n}\n\nexport const objectSpecialExpression: BuiltinSpecialExpression<Any, ObjectNode> = {\n arity: {},\n docs,\n evaluateAsNormalExpression: (params, sourceCodeInfo) => {\n const result: Obj = {}\n\n for (let i = 0; i < params.length; i += 2) {\n const key = params[i]\n const value = params[i + 1]\n assertString(key, sourceCodeInfo)\n result[key] = value ?? null\n }\n\n return result\n },\n getUndefinedSymbols: (node, contextStack, { getUndefinedSymbols, builtin, evaluateNode }) => getUndefinedSymbols(node[1][1], contextStack, builtin, evaluateNode),\n}\n","import type { Any } from '../../interface'\nimport type { AstNode, BindingTarget, SpecialExpressionNode } from '../../parser/types'\nimport type { BuiltinSpecialExpression, CustomDocs } from '../interface'\nimport type { specialExpressionTypes } from '../specialExpressionTypes'\nimport { getAllBindingTargetNames } from '../bindingNode'\nimport type { Context } from '../../evaluator/interface'\n\n// Each case: [pattern, body, guard?]\nexport type MatchCase = [BindingTarget, AstNode, AstNode | undefined]\nexport type MatchNode = SpecialExpressionNode<[typeof specialExpressionTypes['match'], AstNode, MatchCase[]]>\n\nconst docs: CustomDocs = {\n category: 'special-expression',\n customVariants: ['match value match-branch match-branch ... end'],\n details: [\n ['value', 'any', 'The value to match against patterns.'],\n ['match-branch', 'case pattern [when guard] then body', 'A branch of the match expression.'],\n ['pattern', 'pattern', 'A pattern to match: literal, variable, array destructuring, object destructuring, or wildcard (_).'],\n ['guard', 'expression', 'An optional guard expression that must be truthy for the match to succeed.'],\n ['body', 'expressions', 'The expressions to evaluate if the pattern matches.'],\n ],\n description: 'Pattern matching expression. Matches `value` against each `pattern` sequentially. If a pattern matches (and the optional `when` guard is truthy), the corresponding `body` is evaluated and its result returned. Bound variables from the pattern are available in the guard and body. If no pattern matches, `null` is returned.',\n examples: [\n `\nmatch 1\n case 1 then \"One\"\n case 2 then \"Two\"\nend`,\n `\nmatch [1, 2, 3]\n case [x] then \"one element\"\n case [x, y] then \"two elements\"\n case [x, ...xs] then \"first: \" ++ str(x) ++ \" rest: \" ++ str(xs)\nend`,\n `\nmatch { type: \"click\", x: 10, y: 20 }\n case { type: \"click\", x, y } then \"Click at \" ++ str(x) ++ \", \" ++ str(y)\n case { type: \"keydown\", key } then \"Key: \" ++ key\n case _ then \"unknown event\"\nend`,\n `\nmatch { role: \"admin\", name: \"Alice\" }\n case { role: \"admin\", name } then \"Admin: \" ++ name\n case { role, name } when role == \"user\" then \"User: \" ++ name\n case _ then \"Unknown role\"\nend`,\n ],\n}\n\nexport const matchSpecialExpression: BuiltinSpecialExpression<Any, MatchNode> = {\n arity: {},\n docs,\n getUndefinedSymbols: (node, contextStack, { getUndefinedSymbols, builtin, evaluateNode }) => {\n const result = new Set<string>()\n\n // The match value expression\n getUndefinedSymbols([node[1][1]], contextStack, builtin, evaluateNode).forEach(s => result.add(s))\n\n // Each case\n for (const [pattern, body, guard] of node[1][2]) {\n const newContext: Context = {}\n Object.assign(newContext, getAllBindingTargetNames(pattern))\n const caseContextStack = contextStack.create(newContext)\n\n if (guard) {\n getUndefinedSymbols([guard], caseContextStack, builtin, evaluateNode).forEach(s => result.add(s))\n }\n getUndefinedSymbols([body], caseContextStack, builtin, evaluateNode).forEach(s => result.add(s))\n }\n\n return result\n },\n}\n","import type { SpecialExpressionNode, SymbolNode } from '../../parser/types'\nimport { toFixedArity } from '../../utils/arity'\nimport type { BuiltinSpecialExpression, FunctionDocs } from '../interface'\nimport type { specialExpressionTypes } from '../specialExpressionTypes'\n\nexport type DefinedNode = SpecialExpressionNode<[typeof specialExpressionTypes['defined?'], SymbolNode]>\n\nconst docs: FunctionDocs = {\n category: 'special-expression',\n returns: {\n type: 'boolean',\n },\n args: {\n symbol: { type: 'any' },\n },\n variants: [\n { argumentNames: ['symbol'] },\n ],\n description: `Returns \\`true\\` if \\`symbol\\` is defined, \\`false\\` otherwise.\n\nBuilt-in symbols are always considered defined. For user-defined symbols, checks if the symbol exists in the current scope.`,\n examples: [\n 'let x = 42; defined?(x)',\n 'defined?(x)',\n 'defined?(+)',\n ],\n}\n\nexport const definedSpecialExpression: BuiltinSpecialExpression<boolean, DefinedNode> = {\n arity: toFixedArity(1),\n docs,\n getUndefinedSymbols: (node, contextStack, { getUndefinedSymbols, builtin, evaluateNode }) => getUndefinedSymbols([node[1][1]], contextStack, builtin, evaluateNode),\n}\n","import type { Any } from '../../interface'\nimport type { AstNode, SpecialExpressionNode } from '../../parser/types'\nimport type { BuiltinSpecialExpression, CustomDocs } from '../interface'\nimport type { specialExpressionTypes } from '../specialExpressionTypes'\n\nexport type DoNode = SpecialExpressionNode<[typeof specialExpressionTypes['block'], AstNode[]]>\n\nconst docs: CustomDocs = {\n category: 'special-expression',\n customVariants: ['do body end'],\n details: [\n ['body', 'expressions', 'The expressions to evaluate.'],\n ],\n description: 'Evaluates `body`. Resulting value is the value of the last expression.',\n examples: [\n `\ndo\n let a = 1 + 2 + 3 + 4;\n let b = -> $ * ( $ + 1 );\n b(a)\nend`,\n ],\n}\n\nexport const doSpecialExpression: BuiltinSpecialExpression<Any, DoNode> = {\n arity: {},\n docs,\n getUndefinedSymbols: (node, contextStack, { getUndefinedSymbols, builtin, evaluateNode }) => {\n return getUndefinedSymbols(node[1][1], contextStack.create({}), builtin, evaluateNode)\n },\n}\n","import type { ContextStack } from '../../evaluator/ContextStack'\nimport type { Context, EvaluateNode } from '../../evaluator/interface'\nimport type { GetUndefinedSymbols, UndefinedSymbols } from '../../getUndefinedSymbols'\nimport type {\n DvalaFunction,\n SpecialExpressionNode,\n} from '../../parser/types'\nimport { addToSet } from '../../utils'\nimport { getAllBindingTargetNames, walkDefaults } from '../bindingNode'\nimport type { Builtin, BuiltinSpecialExpression } from '../interface'\nimport type { Function } from '../utils'\nimport type { specialExpressionTypes } from '../specialExpressionTypes'\n\nexport type LambdaNode = SpecialExpressionNode<[typeof specialExpressionTypes['0_lambda'], Function, string]>\n\nexport const lambdaSpecialExpression: BuiltinSpecialExpression<DvalaFunction, LambdaNode> = {\n arity: {},\n getUndefinedSymbols: (node, contextStack, { getUndefinedSymbols, builtin, evaluateNode }) => {\n const fn = node[1][1]\n return getFunctionUnresolvedSymbols(fn, contextStack, getUndefinedSymbols, builtin, evaluateNode)\n },\n\n}\n\nfunction getFunctionUnresolvedSymbols(\n fn: Function,\n contextStack: ContextStack,\n getUndefinedSymbols: GetUndefinedSymbols,\n builtin: Builtin,\n evaluateNode: EvaluateNode,\n): UndefinedSymbols {\n const result = new Set<string>()\n const newContext: Context = { self: { value: null } }\n\n fn[0].forEach((arg) => {\n Object.assign(newContext, getAllBindingTargetNames(arg))\n\n walkDefaults(arg, (defaultNode) => {\n addToSet(result, getUndefinedSymbols([defaultNode], contextStack, builtin, evaluateNode))\n })\n })\n\n const newContextStack = contextStack.create(newContext)\n const overloadResult = getUndefinedSymbols(fn[1], newContextStack, builtin, evaluateNode)\n addToSet(result, overloadResult)\n return result\n}\n","import type { Any } from '../../interface'\nimport type { AstNode, SpecialExpressionNode } from '../../parser/types'\nimport type { BuiltinSpecialExpression, CustomDocs } from '../interface'\nimport type { specialExpressionTypes } from '../specialExpressionTypes'\n\nexport type IfNode = SpecialExpressionNode<[typeof specialExpressionTypes['if'], [AstNode, AstNode, AstNode?]]>\n\nconst docs: CustomDocs = {\n category: 'special-expression',\n customVariants: ['if test then true-expr else false-expr', 'if test then true-expr'],\n details: [\n ['test', 'expression', 'The condition to test.'],\n ['true-expr', 'expression', 'The expression to evaluate if the test is truthy.'],\n ['false-expr', 'expression', 'The expression to evaluate if the test is falsy.'],\n ],\n description: 'Either `true-expr` or `false-expr` branch is taken. `true-expr` is selected when $test is truthy. If $test is falsy `false-expr` is executed, if no `false-expr` exists, `null` is returned.',\n examples: [\n `\nif true then\n write!(\"TRUE\")\nelse\n write!(\"FALSE\")\nend`,\n 'if false then write!(\"TRUE\") else write!(\"FALSE\") end',\n 'if true then write!(\"TRUE\") end',\n 'if false then write!(\"TRUE\") end',\n ],\n}\n\nexport const ifSpecialExpression: BuiltinSpecialExpression<Any, IfNode> = {\n arity: { min: 2, max: 3 },\n docs,\n getUndefinedSymbols: (node, contextStack, { getUndefinedSymbols, builtin, evaluateNode }) =>\n getUndefinedSymbols(node[1][1].filter(n => !!n), contextStack, builtin, evaluateNode),\n}\n","import type { Any } from '../../interface'\nimport type { AstNode, SpecialExpressionNode } from '../../parser/types'\nimport type { BuiltinSpecialExpression, CustomDocs } from '../interface'\nimport type { specialExpressionTypes } from '../specialExpressionTypes'\n\nexport type UnlessNode = SpecialExpressionNode<[typeof specialExpressionTypes['unless'], [AstNode, AstNode, AstNode?]]>\n\nconst docs: CustomDocs = {\n category: 'special-expression',\n customVariants: ['unless test then true-expr else false-expr end', 'unless test true-expr end'],\n details: [\n ['test', 'expression', 'The condition to test.'],\n ['true-expr', 'expression', 'The expressions to evaluate if the test is falsy.'],\n ['false-expr', 'expression', 'The expressions to evaluate if the test is truthy.'],\n ],\n description: 'Either `true-expr` or `false-expr` branch is taken. `true-expr` is selected when $test is falsy. If $test is truthy `false-expr` is executed, if no `false-expr` exists, `null` is returned.',\n examples: [\n `\nunless true then\n write!(\"TRUE\")\nelse\n write!(\"FALSE\")\nend`,\n 'unless false then write!(\"TRUE\") else write!(\"FALSE\") end',\n 'unless true then write!(\"TRUE\") end',\n 'unless false then write!(\"TRUE\") end',\n ],\n}\n\nexport const unlessSpecialExpression: BuiltinSpecialExpression<Any, UnlessNode> = {\n arity: {},\n docs,\n getUndefinedSymbols: (node, contextStack, { getUndefinedSymbols, builtin, evaluateNode }) =>\n getUndefinedSymbols(node[1][1].filter(n => !!n), contextStack, builtin, evaluateNode),\n}\n","import type { Any } from '../../interface'\nimport type { BindingNode, SpecialExpressionNode } from '../../parser/types'\nimport { addToSet } from '../../utils'\nimport { toFixedArity } from '../../utils/arity'\nimport { getAllBindingTargetNames, walkDefaults } from '../bindingNode'\nimport type { BuiltinSpecialExpression, CustomDocs } from '../interface'\nimport type { specialExpressionTypes } from '../specialExpressionTypes'\n\nexport type LetNode = SpecialExpressionNode<[typeof specialExpressionTypes['let'], BindingNode]>\n\nconst docs: CustomDocs = {\n category: 'special-expression',\n customVariants: ['let s = value;'],\n details: [\n ['s', 'symbol', 'The name of the variable to bind.'],\n ['value', 'any', 'The value to bind to the variable.'],\n ],\n description: `\n Binds local variables s to \\`value\\`. \\`value\\` can be any expression. The scope of the variables is the body of the let expression.`,\n examples: [`\nlet a = 1 + 2 + 3 + 4;\nlet b = -> $ * ( $ + 1 );\nwrite!(\"a\", a, \"b\", b)`],\n}\n\nexport const letSpecialExpression: BuiltinSpecialExpression<Any, LetNode> = {\n arity: toFixedArity(0),\n docs,\n getUndefinedSymbols: (node, contextStack, { getUndefinedSymbols, builtin, evaluateNode }) => {\n const bindingNode = node[1][1]\n const target = bindingNode[1][0]\n const value = bindingNode[1][1]\n const bindingResult = getUndefinedSymbols([value], contextStack, builtin, evaluateNode)\n walkDefaults(target, (defaultNode) => {\n addToSet(bindingResult, getUndefinedSymbols([defaultNode], contextStack, builtin, evaluateNode))\n })\n contextStack.addValues(getAllBindingTargetNames(target), target[2])\n return bindingResult\n },\n}\n","import type { Context } from '../../evaluator/interface'\nimport type { Any } from '../../interface'\nimport type { AstNode, BindingNode, SpecialExpressionNode } from '../../parser/types'\nimport { joinSets } from '../../utils'\nimport { getAllBindingTargetNames } from '../bindingNode'\nimport type { BuiltinSpecialExpression, CustomDocs } from '../interface'\nimport type { specialExpressionTypes } from '../specialExpressionTypes'\n\nexport type LoopNode = SpecialExpressionNode<[typeof specialExpressionTypes['loop'], BindingNode[], AstNode]> // bindings, body\n\nconst docs: CustomDocs = {\n category: 'special-expression',\n customVariants: ['loop (bindings) -> body'],\n details: [\n ['bindings', 'binding pairs', 'Comma-separated bindings with initial values, e.g. `n = 10, acc = 0`.'],\n ['body', 'expression', 'The expression to evaluate repeatedly. Use `recur` to loop back with new values.'],\n ],\n description: `Creates a loop with initial bindings. Use \\`recur\\` inside the body to jump back to the loop head with new binding values.\n\nIf \\`recur\\` is not called, the loop terminates and returns the value of the body expression.`,\n examples: [\n `loop (n = 10, acc = 0) -> do\n if n == 0 then\n acc\n else\n recur(n - 1, acc + n)\n end\nend`,\n `loop (n = 5, acc = 1) -> do\n if n <= 1 then\n acc\n else\n recur(n - 1, acc * n)\n end\nend`,\n ],\n}\n\nexport const loopSpecialExpression: BuiltinSpecialExpression<Any, LoopNode> = {\n arity: {},\n docs,\n getUndefinedSymbols: (node, contextStack, { getUndefinedSymbols, builtin, evaluateNode }) => {\n const bindingNodes = node[1][1]\n\n const newContext = bindingNodes\n .reduce((context: Context, bindingNode) => {\n const names = getAllBindingTargetNames(bindingNode[1][0])\n\n Object.keys(names).forEach((name) => {\n context[name] = { value: true }\n })\n return context\n }, {})\n\n const bindingValueNodes = bindingNodes.map(bindingNode => bindingNode[1][1])\n const bindingsResult = getUndefinedSymbols(bindingValueNodes, contextStack, builtin, evaluateNode)\n const paramsResult = getUndefinedSymbols([node[1][2]], contextStack.create(newContext), builtin, evaluateNode)\n return joinSets(bindingsResult, paramsResult)\n },\n}\n","import type { GetUndefinedSymbols, UndefinedSymbols } from '../../getUndefinedSymbols'\nimport type { ContextStack } from '../../evaluator/ContextStack'\nimport type { Context, EvaluateNode } from '../../evaluator/interface'\nimport type { Any } from '../../interface'\nimport type { AstNode, BindingNode, SpecialExpressionNode } from '../../parser/types'\nimport type { Builtin, BuiltinSpecialExpression, CustomDocs } from '../interface'\nimport { getAllBindingTargetNames } from '../bindingNode'\nimport type { specialExpressionTypes } from '../specialExpressionTypes'\nimport { toFixedArity } from '../../utils/arity'\n\nexport type LoopBindingNode = [BindingNode, BindingNode[], AstNode?, AstNode?] // Binding, Let-Bindings, When, While\n\nexport type ForNode = SpecialExpressionNode<[typeof specialExpressionTypes['for'], LoopBindingNode[], AstNode]> // LoopBindings, body\nexport type DoSeqNode = SpecialExpressionNode<[typeof specialExpressionTypes['doseq'], LoopBindingNode[], AstNode]> // LoopBindings, body\n\ntype LoopNode = ForNode | DoSeqNode\n\nfunction analyze(\n loopNode: LoopNode,\n contextStack: ContextStack,\n getUndefinedSymbols: GetUndefinedSymbols,\n builtin: Builtin,\n evaluateNode: EvaluateNode,\n): UndefinedSymbols {\n const result = new Set<string>()\n const newContext: Context = {}\n const [, loopBindings, body] = loopNode[1]\n loopBindings.forEach((loopBindingNode) => {\n const [bindingNode, letBindings, whenNode, whileNode] = loopBindingNode\n const [target, value] = bindingNode[1]\n getUndefinedSymbols([value], contextStack.create(newContext), builtin, evaluateNode).forEach(symbol =>\n result.add(symbol),\n )\n Object.assign(newContext, getAllBindingTargetNames(target))\n if (letBindings) {\n letBindings.forEach((letBindingNode) => {\n const [letTarget, letValue] = letBindingNode[1]\n\n getUndefinedSymbols([letValue], contextStack.create(newContext), builtin, evaluateNode).forEach(symbol =>\n result.add(symbol),\n )\n Object.assign(newContext, getAllBindingTargetNames(letTarget))\n })\n }\n if (whenNode) {\n getUndefinedSymbols([whenNode], contextStack.create(newContext), builtin, evaluateNode).forEach(symbol =>\n result.add(symbol),\n )\n }\n if (whileNode) {\n getUndefinedSymbols([whileNode], contextStack.create(newContext), builtin, evaluateNode).forEach(symbol =>\n result.add(symbol),\n )\n }\n })\n getUndefinedSymbols([body], contextStack.create(newContext), builtin, evaluateNode).forEach(symbol =>\n result.add(symbol),\n )\n return result\n}\n\nconst forDocs: CustomDocs = {\n category: 'special-expression',\n customVariants: ['for (...binding) -> body'],\n details: [\n ['binding', 'loop-var in collection [...let-binding] [where whereExpr] [while whileExp]', 'A for loop binding'],\n ['loop-var', 'symbol', 'The name of the loop variable.'],\n ['collection', 'any', 'The collection to iterate over.'],\n ['let-binding', 'let binding', 'A let binding to create a local variable.'],\n ['whereExpr', 'expression', 'An expression that must evaluate to truthy for the loop body to be executed.'],\n ['whileExp', 'expression', 'An expression that must evaluate to truthy for the loop to continue.'],\n ['body', 'expressions', 'The expressions to evaluate for each iteration of the loop.'],\n ],\n returns: {\n type: 'any',\n array: true,\n },\n description: 'Iterates over `bindings`, evaluates `body` for each `binding` and returns an `array` of results.',\n examples: [\n `\nfor (i in [1, 2, 3]) -> i * 2\n `,\n `\nfor (\n i in range(10) let ii = i ^ 2 while ii < 40 when ii % 3 == 0,\n j in range(10) when j % 2 == 1\n) -> ii + j\n `,\n ],\n}\n\nexport const forSpecialExpression: BuiltinSpecialExpression<Any, ForNode> = {\n arity: toFixedArity(1),\n docs: forDocs,\n getUndefinedSymbols: (node, contextStack, { getUndefinedSymbols, builtin, evaluateNode }) => analyze(node, contextStack, getUndefinedSymbols, builtin, evaluateNode),\n}\n\nconst doseqDocs: CustomDocs = {\n category: 'special-expression',\n customVariants: ['doseq (...binding) -> body'],\n details: [\n ['binding', 'loop-var in collection [...let-binding] [where whereExpr] [while whileExp]', 'A doseq loop binding'],\n ['loop-var', 'symbol', 'The name of the loop variable.'],\n ['collection', 'any', 'The collection to iterate over.'],\n ['let-binding', 'let binding', 'A let binding to create a local variable.'],\n ['whereExpr', 'expression', 'An expression that must evaluate to truthy for the loop body to be executed.'],\n ['whileExp', 'expression', 'An expression that must evaluate to truthy for the loop to continue.'],\n ['body', 'expressions', 'The expressions to evaluate for each iteration of the loop.'],\n ],\n returns: {\n type: 'null',\n },\n description: 'Iterates over `bindings`, evaluates `body` for each `binding` and returns `null`. This is useful for side effects.',\n examples: [\n `\ndoseq (i in [1, 2, 3]) -> write!(i * 2)\n `,\n ],\n}\n\nexport const doseqSpecialExpression: BuiltinSpecialExpression<null, DoSeqNode> = {\n arity: toFixedArity(1),\n docs: doseqDocs,\n getUndefinedSymbols: (node, contextStack, { getUndefinedSymbols, builtin, evaluateNode }) => analyze(node, contextStack, getUndefinedSymbols, builtin, evaluateNode),\n}\n","import type { Any } from '../../interface'\nimport type { AstNode, SpecialExpressionNode } from '../../parser/types'\nimport { asAny } from '../../typeGuards/dvala'\nimport type { BuiltinSpecialExpression, FunctionDocs } from '../interface'\nimport type { specialExpressionTypes } from '../specialExpressionTypes'\n\nexport type OrNode = SpecialExpressionNode<[typeof specialExpressionTypes['||'], AstNode[]]>\n\nconst docs: FunctionDocs = {\n category: 'special-expression',\n returns: {\n type: 'boolean',\n },\n args: {\n a: { type: 'any' },\n b: { type: 'any' },\n c: {\n type: 'any',\n rest: true,\n },\n },\n variants: [\n { argumentNames: ['a', 'b'] },\n { argumentNames: ['a', 'b', 'c'] },\n ],\n description: `\n Computes logical \\`or\\`. Evaluation of expressions evaluation starts from left.\n As soon as a \\`expression\\` evaluates to a truthy value, the result is returned.\n\n If all expressions evaluate to falsy values, the value of the last expression is returned.`,\n examples: [\n 'false || 1',\n '||(1, 1)',\n '||(3 > 2, \"string\")',\n '||(3 < 2, \"string\")',\n '||(false, false, false, true)',\n '||(1, 2, 3, 4)',\n ],\n}\n\nexport const orSpecialExpression: BuiltinSpecialExpression<Any, OrNode> = {\n arity: {},\n docs,\n evaluateAsNormalExpression: (params, sourceCodeInfo) => {\n let value: Any = false\n for (const param of params) {\n value = asAny(param, sourceCodeInfo)\n if (value)\n break\n }\n return value\n },\n getUndefinedSymbols: (node, contextStack, { getUndefinedSymbols, builtin, evaluateNode }) => getUndefinedSymbols(node[1][1], contextStack, builtin, evaluateNode),\n}\n","import type { Any } from '../../interface'\nimport type { AstNode, SpecialExpressionNode } from '../../parser/types'\nimport { asAny } from '../../typeGuards/dvala'\nimport type { BuiltinSpecialExpression, FunctionDocs } from '../interface'\nimport type { specialExpressionTypes } from '../specialExpressionTypes'\n\nexport type QqNode = SpecialExpressionNode<[typeof specialExpressionTypes['??'], AstNode[]]>\n\nconst docs: FunctionDocs = {\n category: 'special-expression',\n returns: {\n type: 'any',\n },\n args: {\n a: { type: 'any' },\n b: { type: 'any' },\n c: {\n type: 'any',\n rest: true,\n },\n },\n variants: [\n { argumentNames: ['a'] },\n { argumentNames: ['a', 'b'] },\n { argumentNames: ['a', 'b', 'c'] },\n ],\n description: `Nullish coalescing operator. Returns the first non-\\`null\\` value.\n\nEvaluation is short-circuited — as soon as a non-\\`null\\` value is found, the remaining expressions are not evaluated.\n\nIf all values are \\`null\\`, returns \\`null\\`.\n\nAlso works with undefined symbols — if a symbol is undefined, it is treated as \\`null\\`.`,\n examples: [\n '1 ?? 2',\n 'null ?? 2',\n '??(null)',\n '??(null, \"default\")',\n '??(1, \"default\")',\n 'false ?? \"default\"',\n '??(null, null, 3)',\n ],\n}\n\nexport const qqSpecialExpression: BuiltinSpecialExpression<Any, QqNode> = {\n arity: { min: 1 },\n docs,\n evaluateAsNormalExpression: (params, sourceCodeInfo) => {\n for (const param of params) {\n const value = asAny(param, sourceCodeInfo)\n if (value !== null) {\n return value\n }\n }\n return null\n },\n getUndefinedSymbols: (node, contextStack, { getUndefinedSymbols, builtin, evaluateNode }) => getUndefinedSymbols(node[1][1], contextStack, builtin, evaluateNode),\n}\n","import { RecurSignal } from '../../errors'\nimport type { AstNode, SpecialExpressionNode } from '../../parser/types'\nimport type { BuiltinSpecialExpression, CustomDocs } from '../interface'\nimport type { specialExpressionTypes } from '../specialExpressionTypes'\n\nexport type RecurNode = SpecialExpressionNode<[typeof specialExpressionTypes['recur'], AstNode[]]>\n\nconst docs: CustomDocs = {\n category: 'special-expression',\n customVariants: ['recur(...recur-args)'],\n description: 'Recursevly calls enclosing function or loop with its evaluated `recur-args`.',\n examples: [\n `\nlet foo = (n) -> do\n write!(n);\n if not(zero?(n)) then\n recur(n - 1)\n end\nend;\nfoo(3)`,\n `\n(n -> do\n write!(n);\n if not(zero?(n)) then\n recur(n - 1)\n end\nend)(3)`,\n `\nloop (n = 3) -> do\n write!(n);\n if not(zero?(n)) then\n recur(n - 1)\n end\nend`,\n ],\n}\n\nexport const recurSpecialExpression: BuiltinSpecialExpression<null, RecurNode> = {\n arity: {},\n docs,\n evaluateAsNormalExpression: (params) => {\n throw new RecurSignal(params)\n },\n getUndefinedSymbols: (node, contextStack, { getUndefinedSymbols, builtin, evaluateNode }) =>\n getUndefinedSymbols(node[1][1], contextStack, builtin, evaluateNode),\n}\n","import { UserDefinedError } from '../../errors'\nimport type { AstNode, SpecialExpressionNode } from '../../parser/types'\nimport { asString } from '../../typeGuards/string'\nimport { toFixedArity } from '../../utils/arity'\nimport type { BuiltinSpecialExpression, FunctionDocs } from '../interface'\nimport type { specialExpressionTypes } from '../specialExpressionTypes'\n\nexport type ThrowNode = SpecialExpressionNode<[typeof specialExpressionTypes['throw'], AstNode]>\n\nconst docs: FunctionDocs = {\n category: 'special-expression',\n returns: {\n type: 'never',\n },\n args: {\n expr: {\n type: 'any',\n },\n },\n variants: [\n { argumentNames: ['expr'] },\n ],\n description: 'Throws `UserDefinedError` with message set to $expr evaluated. $expr must evaluate to a string.',\n examples: [\n 'try throw(\"You shall not pass!\") catch(error) \"Error: \" ++ error.message end',\n 'try throw(slice(\"You shall not pass!\", 0, 3)) catch(error) \"Error: \" ++ error.message end',\n ],\n}\n\nexport const throwSpecialExpression: BuiltinSpecialExpression<null, ThrowNode> = {\n arity: toFixedArity(1),\n docs,\n evaluateAsNormalExpression: (params, sourceCodeInfo) => {\n const message = asString(params[0], sourceCodeInfo, {\n nonEmpty: true,\n })\n throw new UserDefinedError(message, undefined)\n },\n getUndefinedSymbols: (node, contextStack, { getUndefinedSymbols, builtin, evaluateNode }) => getUndefinedSymbols([node[1][1]], contextStack, builtin, evaluateNode),\n}\n","import type { Context } from '../../evaluator/interface'\nimport type { Any } from '../../interface'\nimport type { AstNode, SpecialExpressionNode, SymbolNode } from '../../parser/types'\nimport { joinSets } from '../../utils'\nimport type { BuiltinSpecialExpression, CustomDocs } from '../interface'\nimport type { specialExpressionTypes } from '../specialExpressionTypes'\n\nexport type WithHandler = [AstNode, AstNode] // [effectExpr, handlerFn]\n\nexport type TryNode = SpecialExpressionNode<[typeof specialExpressionTypes['try'], AstNode, SymbolNode | undefined, AstNode | undefined, WithHandler[]]>\n\nconst docs: CustomDocs = {\n category: 'special-expression',\n customVariants: [\n 'try { try-body } catch { catch-body }',\n 'try { try-body } catch(error) { catch-body }',\n 'try { try-body } with { case effect then handler ... } end',\n 'try { try-body } with { case effect then handler ... } catch { catch-body }',\n 'try { try-body } with { case effect then handler ... } catch(error) { catch-body }',\n ],\n details: [\n ['try-body', 'expressions', 'The expressions to try.'],\n ['error', 'symbol', 'The error variable to bind.'],\n ['catch-body', 'expression', 'The expressions to evaluate if the try-body throws an error.'],\n ['effect', 'expression', 'An expression evaluating to an effect value.'],\n ['handler', 'expression', 'A function that handles the effect. Its return value resumes the perform call.'],\n ],\n description: 'Executes `try-body`. If that throws, the `catch-body` gets executed. '\n + 'Effect handlers can be installed via `with` to intercept `perform` calls. See examples for details.',\n examples: [\n `\ntry\n 2 / 4\ncatch\n \"Oops!\"\nend`,\n `\ntry\n foo()\ncatch(error)\n \"Error: \" ++ error.message\nend`,\n `\ntry\n foo()\ncatch\n 42\nend`,\n ],\n}\n\nexport const trySpecialExpression: BuiltinSpecialExpression<Any, TryNode> = {\n arity: {},\n docs,\n getUndefinedSymbols: (node, contextStack, { getUndefinedSymbols, builtin, evaluateNode }) => {\n const [, tryExpression, errorSymbol, catchExpression, withHandlers] = node[1]\n const tryResult = getUndefinedSymbols([tryExpression], contextStack, builtin, evaluateNode)\n\n let catchResult = new Set<string>()\n if (catchExpression) {\n const newContext: Context = errorSymbol\n ? {\n [errorSymbol[1]]: { value: true },\n }\n : {}\n catchResult = getUndefinedSymbols([catchExpression], contextStack.create(newContext), builtin, evaluateNode)\n }\n\n // Collect undefined symbols from with-handler expressions\n let withResult = new Set<string>()\n for (const [effectExpr, handlerFn] of withHandlers) {\n const effectResult = getUndefinedSymbols([effectExpr], contextStack, builtin, evaluateNode)\n const handlerResult = getUndefinedSymbols([handlerFn], contextStack, builtin, evaluateNode)\n withResult = joinSets(withResult, effectResult, handlerResult)\n }\n\n return joinSets(tryResult, catchResult, withResult)\n },\n}\n","import type { Any, Arr } from '../../interface'\nimport type { AstNode, SpecialExpressionNode } from '../../parser/types'\nimport { asAny } from '../../typeGuards/dvala'\nimport type { BuiltinSpecialExpression, FunctionDocs } from '../interface'\nimport type { specialExpressionTypes } from '../specialExpressionTypes'\n\nexport type ArrayNode = SpecialExpressionNode<[typeof specialExpressionTypes['array'], AstNode[]]>\n\nconst docs: FunctionDocs = {\n category: 'special-expression',\n returns: {\n type: 'any',\n array: true,\n },\n args: {\n values: {\n type: 'any',\n rest: true,\n },\n },\n variants: [\n { argumentNames: ['values'] },\n ],\n description: 'Makes new array from $values.',\n examples: [\n 'array(1, 2, 3)',\n 'array(array(null, false, true))',\n '[]',\n '[1, 2, 3]',\n '[1, 2, ...[3, 4, 5], 6]',\n '[[null, false, true]]',\n '[1, 2, 3][1]',\n ],\n hideOperatorForm: true,\n}\n\nexport const arraySpecialExpression: BuiltinSpecialExpression<Any, ArrayNode> = {\n arity: {},\n docs,\n evaluateAsNormalExpression: (params, sourceCodeInfo) => {\n const result: Arr = []\n\n for (const param of params) {\n result.push(asAny(param, sourceCodeInfo))\n }\n\n return result\n },\n\n getUndefinedSymbols: (node, contextStack, { getUndefinedSymbols, builtin, evaluateNode }) => getUndefinedSymbols(node[1][1], contextStack, builtin, evaluateNode),\n}\n","import type { EffectRef, SpecialExpressionNode } from '../../parser/types'\nimport type { BuiltinSpecialExpression, CustomDocs } from '../interface'\nimport type { specialExpressionTypes } from '../specialExpressionTypes'\n\nexport type EffectNode = SpecialExpressionNode<[typeof specialExpressionTypes['effect'], string]>\n\nconst docs: CustomDocs = {\n category: 'special-expression',\n customVariants: [\n 'effect(name)',\n ],\n details: [\n ['name', 'dotted identifier', 'The effect name, e.g. `llm.complete` or `dvala.log`.'],\n ],\n description: 'Returns the unique effect reference for the given name. '\n + 'Calling `effect` with the same name always returns the same reference. '\n + 'Effect references are first-class values that can be stored, passed, and compared with `==`.',\n examples: [\n 'effect(dvala.log)',\n '==(effect(llm.complete), effect(llm.complete))',\n ],\n}\n\nexport const effectSpecialExpression: BuiltinSpecialExpression<EffectRef, EffectNode> = {\n arity: {},\n docs,\n getUndefinedSymbols: () => new Set<string>(),\n}\n","import type { Any } from '../../interface'\nimport type { SpecialExpressionNode } from '../../parser/types'\nimport { toFixedArity } from '../../utils/arity'\nimport type { BuiltinSpecialExpression, CustomDocs } from '../interface'\nimport type { specialExpressionTypes } from '../specialExpressionTypes'\n\nexport type ImportNode = SpecialExpressionNode<[typeof specialExpressionTypes['import'], string]>\n\nconst docs: CustomDocs = {\n category: 'special-expression',\n description: 'Imports all functions from a module as an object. Use destructuring to pick specific functions.',\n customVariants: [\n 'import(module-name)',\n ],\n returns: { type: 'object' },\n examples: [\n 'let v = import(vector); v.stdev([1, 2, 3, 4])',\n 'let { linspace } = import(vector); linspace(0, 10, 5)',\n 'let g = import(grid); g.row([[1, 2], [3, 4]], 0)',\n ],\n}\n\nexport const importSpecialExpression: BuiltinSpecialExpression<Any, ImportNode> = {\n arity: toFixedArity(1),\n docs,\n getUndefinedSymbols: () => new Set(),\n}\n","import type { Arr } from '../../interface'\nimport type { AstNode, SpecialExpressionNode } from '../../parser/types'\nimport { joinSets } from '../../utils'\nimport type { BuiltinSpecialExpression, CustomDocs } from '../interface'\nimport type { specialExpressionTypes } from '../specialExpressionTypes'\n\nexport type ParallelNode = SpecialExpressionNode<[typeof specialExpressionTypes['parallel'], AstNode[]]>\n\nconst docs: CustomDocs = {\n category: 'special-expression',\n customVariants: [\n 'parallel(expr1, expr2, ...)',\n ],\n details: [\n ['expr1, expr2, ...', 'expressions', 'Expressions to evaluate concurrently. Typically `perform(...)` calls.'],\n ],\n description: 'Evaluates all branch expressions concurrently and returns an array of results in order. '\n + 'Each branch runs as an independent trampoline invocation. If any branch suspends, '\n + 'the entire `parallel` suspends with a composite blob. On resume, branches are resumed '\n + 'one at a time. Only available in async mode (`run()`). Requires at least one branch.',\n examples: [],\n}\n\nexport const parallelSpecialExpression: BuiltinSpecialExpression<Arr, ParallelNode> = {\n arity: { min: 1 },\n docs,\n getUndefinedSymbols: (node, contextStack, { getUndefinedSymbols, builtin, evaluateNode }) => {\n const branches = node[1][1] as AstNode[]\n const sets = branches.map(branch => getUndefinedSymbols([branch], contextStack, builtin, evaluateNode))\n return joinSets(...sets)\n },\n}\n","import type { Any } from '../../interface'\nimport type { AstNode, SpecialExpressionNode } from '../../parser/types'\nimport { joinSets } from '../../utils'\nimport type { BuiltinSpecialExpression, CustomDocs } from '../interface'\nimport type { specialExpressionTypes } from '../specialExpressionTypes'\n\nexport type PerformNode = SpecialExpressionNode<[typeof specialExpressionTypes['perform'], AstNode, AstNode[]]>\n\nconst docs: CustomDocs = {\n category: 'special-expression',\n customVariants: [\n 'perform(eff)',\n 'perform(eff, arg1)',\n 'perform(eff, arg1, arg2, ...)',\n ],\n details: [\n ['eff', 'expression', 'An expression evaluating to an effect value (from `effect(name)`).'],\n ['arg1, arg2, ...', 'expressions', 'Arguments passed to the effect handler.'],\n ],\n description: 'Invokes an effect. The nearest enclosing `try/with` handler matching the effect '\n + 'intercepts the call. The handler receives the arguments as an array and its return value '\n + 'becomes the result of `perform`. If no local handler matches, the effect is dispatched '\n + 'to the host.',\n examples: [\n `\ntry\n perform(effect(dvala.log), \"hello\")\nwith\n case effect(dvala.log) then ([msg]) -> msg\nend\n`,\n ],\n}\n\nexport const performSpecialExpression: BuiltinSpecialExpression<Any, PerformNode> = {\n arity: { min: 1 },\n docs,\n getUndefinedSymbols: (node, contextStack, { getUndefinedSymbols, builtin, evaluateNode }) => {\n const [, effectExpr, argExprs] = node[1]\n const effectResult = getUndefinedSymbols([effectExpr], contextStack, builtin, evaluateNode)\n const argsResult = getUndefinedSymbols(argExprs, contextStack, builtin, evaluateNode)\n return joinSets(effectResult, argsResult)\n },\n}\n","import type { Any } from '../../interface'\nimport type { AstNode, SpecialExpressionNode } from '../../parser/types'\nimport { joinSets } from '../../utils'\nimport type { BuiltinSpecialExpression, CustomDocs } from '../interface'\nimport type { specialExpressionTypes } from '../specialExpressionTypes'\n\nexport type RaceNode = SpecialExpressionNode<[typeof specialExpressionTypes['race'], AstNode[]]>\n\nconst docs: CustomDocs = {\n category: 'special-expression',\n customVariants: [\n 'race(expr1, expr2, ...)',\n ],\n details: [\n ['expr1, expr2, ...', 'expressions', 'Expressions to race concurrently. Typically `perform(...)` calls.'],\n ],\n description: 'Races all branch expressions concurrently. The first branch to complete wins — '\n + 'its value becomes the result. Losing branches are cancelled via AbortSignal. '\n + 'Errored branches are silently dropped. If all branches error, throws an aggregate error. '\n + 'If no branch completes but some suspend, the race suspends. On resume, the host provides '\n + 'the winner value directly. Only available in async mode (`run()`). Requires at least one branch.',\n examples: [],\n}\n\nexport const raceSpecialExpression: BuiltinSpecialExpression<Any, RaceNode> = {\n arity: { min: 1 },\n docs,\n getUndefinedSymbols: (node, contextStack, { getUndefinedSymbols, builtin, evaluateNode }) => {\n const branches = node[1][1] as AstNode[]\n const sets = branches.map(branch => getUndefinedSymbols([branch], contextStack, builtin, evaluateNode))\n return joinSets(...sets)\n },\n}\n","/**\n * Continuation stack serialization and deserialization.\n *\n * When a host handler calls `suspend(meta?)`, the trampoline captures the\n * continuation stack (an array of Frame objects). This module converts that\n * stack to/from a JSON string (the \"suspension blob\") that can be stored,\n * transferred, and later resumed in a new process.\n *\n * The main challenge is that Frame objects contain `ContextStack` class\n * instances (which hold lexical scope chains). These are not plain data\n * and may form circular references (e.g., a global context containing a\n * UserDefinedFunction whose captured env references the same global context).\n *\n * The serialization approach:\n * 1. Walk the frame tree and collect all unique ContextStack instances (by identity)\n * 2. Assign each a numeric ID\n * 3. Serialize ContextStacks separately as plain objects\n * 4. In the frame tree, replace ContextStack references with `{ __csRef: id }`\n * 5. First occurrence of each ContextStack gets `{ __csDef: id, ... }` in the\n * contextStacks array — circular refs just become `{ __csRef: id }`\n *\n * Deserialization reverses this:\n * 1. Parse the blob and create placeholder ContextStack instances\n * 2. Deep-resolve all `__csRef` markers back to real instances\n * 3. Fill in host bindings (values, nativeJsFunctions, modules) on each instance\n */\n\nimport { DvalaError } from '../errors'\nimport type { Any } from '../interface'\nimport type { NativeJsFunction } from '../parser/types'\nimport { isDvalaFunction } from '../typeGuards/dvalaFunction'\nimport type { DvalaModule } from '../builtin/modules/interface'\nimport { ContextStackImpl } from './ContextStack'\nimport type { Context } from './interface'\nimport type { ContinuationStack } from './frames'\nimport { describeSerializationIssue } from './serialization'\n\n// ---------------------------------------------------------------------------\n// Constants\n// ---------------------------------------------------------------------------\n\nconst SUSPENSION_VERSION = 1\n\n// ---------------------------------------------------------------------------\n// Internal blob structure (what gets JSON-stringified)\n// ---------------------------------------------------------------------------\n\ninterface SerializedContextStack {\n id: number\n contexts: unknown[] // Context[] with nested ContextStacks replaced by refs\n globalContextIndex: number\n pure: boolean\n}\n\ninterface SuspensionBlobData {\n version: number\n contextStacks: SerializedContextStack[]\n k: unknown // ContinuationStack with ContextStacks replaced by refs\n meta?: Any\n}\n\n// Marker objects embedded in the serialized data\ninterface CSRef { __csRef: number }\n\nfunction isCSRef(value: unknown): value is CSRef {\n return value !== null\n && typeof value === 'object'\n && '__csRef' in value\n && typeof (value as CSRef).__csRef === 'number'\n}\n\n// ---------------------------------------------------------------------------\n// Serialize\n// ---------------------------------------------------------------------------\n\n/**\n * Serialize a continuation stack and optional metadata into an opaque JSON blob.\n *\n * Validates that all values are serializable (no NativeJsFunctions in frames).\n * Throws a descriptive `DvalaError` if non-serializable values are found.\n */\nexport function serializeSuspension(k: ContinuationStack, meta?: Any): string {\n // Phase 1: Collect all unique ContextStack instances\n const csMap = new Map<ContextStackImpl, number>()\n let nextId = 0\n\n function collectContextStacks(value: unknown): void {\n if (value instanceof ContextStackImpl) {\n if (csMap.has(value)) {\n return // Already visited — handles circular refs\n }\n csMap.set(value, nextId++)\n // Recurse into contexts to find nested ContextStacks (e.g., in UserDefinedFunction captured envs)\n for (const ctx of value.getContextsRaw()) {\n for (const entry of Object.values(ctx)) {\n collectContextStacks(entry.value)\n }\n }\n return\n }\n if (Array.isArray(value)) {\n for (const item of value) {\n collectContextStacks(item)\n }\n return\n }\n if (value !== null && typeof value === 'object') {\n for (const v of Object.values(value)) {\n collectContextStacks(v)\n }\n }\n }\n\n collectContextStacks(k)\n if (meta !== undefined) {\n collectContextStacks(meta)\n }\n\n // Phase 2: Serialize values, replacing ContextStacks with refs\n function serializeValue(value: unknown, path: string): unknown {\n if (value instanceof ContextStackImpl) {\n return { __csRef: csMap.get(value)! } satisfies CSRef\n }\n\n // Check for non-serializable function types\n if (isDvalaFunction(value as Any) && (value as { functionType: string }).functionType === 'NativeJsFunction') {\n const issue = describeSerializationIssue(value as Any, path)\n throw new DvalaError(\n `Cannot serialize continuation: ${issue ?? 'NativeJsFunction found in continuation stack'}`,\n undefined,\n )\n }\n\n if (Array.isArray(value)) {\n return value.map((item, i) => serializeValue(item, `${path}[${i}]`))\n }\n if (value !== null && typeof value === 'object') {\n const result: Record<string, unknown> = {}\n for (const [key, v] of Object.entries(value)) {\n result[key] = serializeValue(v, `${path}.${key}`)\n }\n return result\n }\n return value\n }\n\n // Serialize all collected ContextStacks\n const serializedContextStacks: SerializedContextStack[] = Array.from(csMap.entries()).map(\n ([cs, id]) => ({\n id,\n contexts: cs.getContextsRaw().map((ctx, ctxIdx) => {\n const serialized: Record<string, unknown> = {}\n for (const [name, entry] of Object.entries(ctx)) {\n serialized[name] = { value: serializeValue(entry.value, `cs[${id}].contexts[${ctxIdx}].${name}`) }\n }\n return serialized\n }),\n globalContextIndex: cs.getGlobalContextIndex(),\n pure: cs.pure,\n }),\n )\n\n // Serialize the continuation stack\n const serializedK = serializeValue(k, 'k')\n\n // Serialize meta\n const serializedMeta = meta !== undefined ? serializeValue(meta, 'meta') : undefined\n\n const blobData: SuspensionBlobData = {\n version: SUSPENSION_VERSION,\n contextStacks: serializedContextStacks,\n k: serializedK,\n ...(serializedMeta !== undefined ? { meta: serializedMeta as Any } : {}),\n }\n\n return JSON.stringify(blobData)\n}\n\n// ---------------------------------------------------------------------------\n// Deserialize\n// ---------------------------------------------------------------------------\n\n/** Options for re-injecting host bindings on resume. */\nexport interface DeserializeOptions {\n values?: Record<string, unknown>\n nativeJsFunctions?: Record<string, NativeJsFunction>\n modules?: Map<string, DvalaModule>\n}\n\n/**\n * Deserialize a suspension blob back into a continuation stack and metadata.\n *\n * Reconstructs `ContextStack` instances with fresh host bindings from `options`.\n * Handles circular references between ContextStacks and their contained values.\n */\nexport function deserializeSuspension(\n blob: string,\n options?: DeserializeOptions,\n): { k: ContinuationStack, meta?: Any } {\n let blobData: SuspensionBlobData\n try {\n blobData = JSON.parse(blob) as SuspensionBlobData\n }\n catch {\n throw new DvalaError('Invalid suspension blob: not valid JSON', undefined)\n }\n\n if (blobData.version !== SUSPENSION_VERSION) {\n throw new DvalaError(\n `Unsupported suspension blob version: ${blobData.version} (expected ${SUSPENSION_VERSION})`,\n undefined,\n )\n }\n\n // Phase 1: Create placeholder ContextStack instances for each serialized one.\n // Contexts are empty initially — filled in Phase 2 after all instances exist.\n const csMap = new Map<number, ContextStackImpl>()\n\n for (const scs of blobData.contextStacks) {\n const placeholderContexts = scs.contexts.map(() => {\n const ctx: Context = {}\n return ctx\n })\n const cs = ContextStackImpl.fromDeserialized({\n contexts: placeholderContexts,\n globalContextIndex: scs.globalContextIndex,\n values: options?.values,\n nativeJsFunctions: options?.nativeJsFunctions,\n modules: options?.modules,\n pure: scs.pure,\n })\n csMap.set(scs.id, cs)\n }\n\n // Phase 2: Deep-resolve all values, replacing __csRef markers with real instances\n function resolveValue(value: unknown): unknown {\n if (isCSRef(value)) {\n const cs = csMap.get(value.__csRef)\n if (!cs) {\n throw new DvalaError(`Invalid suspension blob: unknown context stack ref ${value.__csRef}`, undefined)\n }\n return cs\n }\n if (Array.isArray(value)) {\n return value.map(resolveValue)\n }\n if (value !== null && typeof value === 'object') {\n const result: Record<string, unknown> = {}\n for (const [key, v] of Object.entries(value)) {\n result[key] = resolveValue(v)\n }\n return result\n }\n return value\n }\n\n // Fill in contexts on each ContextStack\n for (const scs of blobData.contextStacks) {\n const cs = csMap.get(scs.id)!\n const resolvedContexts: Context[] = scs.contexts.map((serializedCtx) => {\n const ctx = serializedCtx as Record<string, { value: unknown }>\n const resolved: Context = {}\n for (const [name, entry] of Object.entries(ctx)) {\n resolved[name] = { value: resolveValue(entry.value) as Any }\n }\n return resolved\n })\n cs.setContextsFromDeserialized(resolvedContexts, scs.globalContextIndex)\n }\n\n // Resolve the continuation stack\n const resolvedK = resolveValue(blobData.k) as ContinuationStack\n\n // Resolve meta\n const resolvedMeta = blobData.meta !== undefined ? resolveValue(blobData.meta) as Any : undefined\n\n return { k: resolvedK, meta: resolvedMeta }\n}\n","export const specialExpressionTypes = {\n '??': 0,\n '&&': 1,\n '||': 2,\n 'array': 3,\n 'cond': 4,\n 'defined?': 5,\n 'block': 6,\n 'doseq': 7,\n '0_lambda': 8,\n 'for': 9,\n 'if': 10,\n 'let': 11,\n 'loop': 12,\n 'object': 13,\n 'recur': 14,\n 'match': 15,\n 'throw': 16,\n 'try': 17,\n 'unless': 18,\n 'import': 19,\n 'effect': 20,\n 'perform': 21,\n 'parallel': 22,\n 'race': 23,\n} as const\n","import type { Builtin } from './interface'\nimport { allNormalExpressions, normalExpressions } from './normalExpressions'\nimport { andSpecialExpression } from './specialExpressions/and'\nimport { condSpecialExpression } from './specialExpressions/cond'\nimport { matchSpecialExpression } from './specialExpressions/match'\nimport { definedSpecialExpression } from './specialExpressions/defined'\nimport { doSpecialExpression } from './specialExpressions/block'\nimport { lambdaSpecialExpression } from './specialExpressions/functions'\nimport { ifSpecialExpression } from './specialExpressions/if'\nimport { unlessSpecialExpression } from './specialExpressions/unless'\nimport { letSpecialExpression } from './specialExpressions/let'\nimport { loopSpecialExpression } from './specialExpressions/loop'\nimport { doseqSpecialExpression, forSpecialExpression } from './specialExpressions/loops'\nimport { orSpecialExpression } from './specialExpressions/or'\nimport { qqSpecialExpression } from './specialExpressions/qq'\nimport { recurSpecialExpression } from './specialExpressions/recur'\nimport { throwSpecialExpression } from './specialExpressions/throw'\nimport { trySpecialExpression } from './specialExpressions/try'\nimport { arraySpecialExpression } from './specialExpressions/array'\nimport { effectSpecialExpression } from './specialExpressions/effect'\nimport { objectSpecialExpression } from './specialExpressions/object'\nimport { importSpecialExpression } from './specialExpressions/import'\nimport { parallelSpecialExpression } from './specialExpressions/parallel'\nimport { performSpecialExpression } from './specialExpressions/perform'\nimport { raceSpecialExpression } from './specialExpressions/race'\nimport { specialExpressionTypes } from './specialExpressionTypes'\n\nexport const specialExpressions = [\n qqSpecialExpression,\n andSpecialExpression,\n orSpecialExpression,\n arraySpecialExpression,\n condSpecialExpression,\n definedSpecialExpression,\n doSpecialExpression,\n doseqSpecialExpression,\n lambdaSpecialExpression,\n forSpecialExpression,\n ifSpecialExpression,\n letSpecialExpression,\n loopSpecialExpression,\n objectSpecialExpression,\n recurSpecialExpression,\n matchSpecialExpression,\n throwSpecialExpression,\n trySpecialExpression,\n unlessSpecialExpression,\n importSpecialExpression,\n effectSpecialExpression,\n performSpecialExpression,\n parallelSpecialExpression,\n raceSpecialExpression,\n] as const\n\nexport type SpecialExpressions = typeof specialExpressions\nexport type SpecialExpression = SpecialExpressions[number]\nexport type SpecialExpressionName = keyof typeof specialExpressionTypes\nexport type CommonSpecialExpressionType = [\n | typeof specialExpressionTypes['??']\n | typeof specialExpressionTypes['&&']\n | typeof specialExpressionTypes['cond']\n | typeof specialExpressionTypes['match']\n | typeof specialExpressionTypes['defined?']\n | typeof specialExpressionTypes['block']\n | typeof specialExpressionTypes['if']\n | typeof specialExpressionTypes['unless']\n | typeof specialExpressionTypes['||']\n | typeof specialExpressionTypes['throw']\n | typeof specialExpressionTypes['array']\n | typeof specialExpressionTypes['object']\n | typeof specialExpressionTypes['effect']\n | typeof specialExpressionTypes['perform']\n | typeof specialExpressionTypes['parallel']\n | typeof specialExpressionTypes['race'],\n]\n\nexport type SpecialExpressionType = typeof specialExpressionTypes[SpecialExpressionName]\n\nexport const builtin: Builtin = {\n normalExpressions,\n specialExpressions,\n allNormalExpressions,\n}\n\nexport const normalExpressionKeys = Object.keys(normalExpressions)\nexport const specialExpressionKeys = Object.keys(specialExpressionTypes)\n","import type { Any } from '../interface'\n\nconst nonNumberReservedSymbolRecord = {\n true: true,\n false: false,\n null: null,\n do: null,\n else: null,\n case: null,\n each: null,\n in: null,\n when: null,\n while: null,\n catch: null,\n function: null,\n as: null,\n then: null,\n end: null,\n with: null,\n _: null,\n} as const satisfies Record<string, Any>\n\nconst phi = (1 + Math.sqrt(5)) / 2\nexport const numberReservedSymbolRecord = {\n 'E': Math.E,\n '-E': -Math.E,\n 'ε': Math.E,\n '-ε': -Math.E,\n 'PI': Math.PI,\n '-PI': -Math.PI,\n 'π': Math.PI,\n '-π': -Math.PI,\n 'PHI': phi,\n '-PHI': -phi,\n 'φ': phi,\n '-φ': -phi,\n 'POSITIVE_INFINITY': Number.POSITIVE_INFINITY,\n '∞': Number.POSITIVE_INFINITY,\n 'NEGATIVE_INFINITY': Number.NEGATIVE_INFINITY,\n '-∞': Number.NEGATIVE_INFINITY,\n 'MAX_SAFE_INTEGER': Number.MAX_SAFE_INTEGER,\n 'MIN_SAFE_INTEGER': Number.MIN_SAFE_INTEGER,\n 'MAX_VALUE': Number.MAX_VALUE,\n 'MIN_VALUE': Number.MIN_VALUE,\n 'NaN': Number.NaN,\n} as const satisfies Record<string, number>\n\nexport const reservedSymbolRecord = {\n ...nonNumberReservedSymbolRecord,\n ...numberReservedSymbolRecord,\n} as const\n\nexport type ReservedSymbol = keyof typeof reservedSymbolRecord\n\nexport function isReservedSymbol(symbol: string): symbol is keyof typeof reservedSymbolRecord {\n return symbol in reservedSymbolRecord\n}\n\nexport function isNumberReservedSymbol(symbol: string): symbol is keyof typeof numberReservedSymbolRecord {\n return symbol in numberReservedSymbolRecord\n}\n","import type { Any, Arr } from '../interface'\nimport type { AstNode, FunctionLike } from '../parser/types'\nimport type { SourceCodeInfo } from '../tokenizer/token'\nimport { isUnknownRecord } from '../typeGuards'\nimport type { MaybePromise } from '../utils/maybePromise'\nimport type { ContextStack } from './ContextStack'\n\ninterface ContextEntry { value: Any }\nexport type Context = Record<string, ContextEntry>\n\nexport type EvaluateNode = (node: AstNode, contextStack: ContextStack) => MaybePromise<Any>\nexport type ExecuteFunction = (fn: FunctionLike, params: Arr, contextStack: ContextStack, sourceCodeInfo?: SourceCodeInfo) => MaybePromise<Any>\n\nexport type LookUpResult = ContextEntry | null\n\nexport function isContextEntry(value: unknown): value is ContextEntry {\n return isUnknownRecord(value) && value.value !== undefined\n}\n","import type { SpecialExpression } from '../builtin'\nimport { builtin, normalExpressionKeys, specialExpressionKeys } from '../builtin'\nimport { allNormalExpressions } from '../builtin/normalExpressions'\nimport { specialExpressionTypes } from '../builtin/specialExpressionTypes'\nimport { DvalaError, UndefinedSymbolError } from '../errors'\nimport type { Any } from '../interface'\nimport type { ContextParams, JsFunction } from '../Dvala/Dvala'\nimport type { DvalaModule } from '../builtin/modules/interface'\nimport type { NativeJsFunction, NormalBuiltinFunction, SpecialBuiltinFunction, SymbolNode, UserDefinedSymbolNode } from '../parser/types'\nimport type { SourceCodeInfo } from '../tokenizer/token'\nimport { asNonUndefined } from '../typeGuards'\nimport { isNormalBuiltinSymbolNode, isSpecialBuiltinSymbolNode } from '../typeGuards/astNode'\nimport { toAny } from '../utils'\nimport { FUNCTION_SYMBOL } from '../utils/symbols'\nimport type { Context, LookUpResult } from './interface'\nimport { isContextEntry } from './interface'\n\nexport type ContextStack = ContextStackImpl\n\nexport class ContextStackImpl {\n private _contexts: Context[]\n public globalContext: Context\n private values?: Record<string, unknown>\n private nativeJsFunctions?: Record<string, NativeJsFunction>\n private modules: Map<string, DvalaModule>\n private valueModules: Map<string, unknown>\n public pure: boolean\n constructor({\n contexts,\n values: hostValues,\n nativeJsFunctions,\n modules,\n valueModules,\n pure,\n }: {\n contexts: Context[]\n values?: Record<string, unknown>\n nativeJsFunctions?: Record<string, NativeJsFunction>\n modules?: Map<string, DvalaModule>\n valueModules?: Map<string, unknown>\n pure?: boolean\n }) {\n this.globalContext = asNonUndefined(contexts[0])\n this._contexts = contexts\n this.values = hostValues\n this.nativeJsFunctions = nativeJsFunctions\n this.modules = modules ?? new Map<string, DvalaModule>()\n this.valueModules = valueModules ?? new Map<string, unknown>()\n this.pure = pure ?? false\n }\n\n // -- Serialization support (Phase 4) --\n\n /** Get the raw context chain for serialization. */\n public getContextsRaw(): Context[] {\n return this._contexts\n }\n\n /** Get host values (plain bindings passed at creation). */\n public getHostValues(): Record<string, unknown> | undefined {\n return this.values\n }\n\n /**\n * Find the index of globalContext in the _contexts array.\n * Returns -1 if not found (should not happen in valid state).\n */\n public getGlobalContextIndex(): number {\n return this._contexts.indexOf(this.globalContext)\n }\n\n /**\n * Create a ContextStack from deserialized data.\n * `contexts` is the restored context chain (already resolved).\n * `globalContextIndex` identifies which element is the globalContext.\n * Host bindings (`values`, `nativeJsFunctions`, `modules`) come from resume options.\n */\n public static fromDeserialized(params: {\n contexts: Context[]\n globalContextIndex: number\n values?: Record<string, unknown>\n nativeJsFunctions?: Record<string, NativeJsFunction>\n modules?: Map<string, DvalaModule>\n pure: boolean\n }): ContextStackImpl {\n const cs = new ContextStackImpl({\n contexts: params.contexts,\n values: params.values,\n nativeJsFunctions: params.nativeJsFunctions,\n modules: params.modules,\n pure: params.pure,\n })\n if (params.globalContextIndex >= 0 && params.globalContextIndex < params.contexts.length) {\n cs.globalContext = params.contexts[params.globalContextIndex]!\n }\n return cs\n }\n\n /**\n * Replace the contexts array and globalContext. Used during deserialization\n * to fill in resolved context data after circular references are handled.\n */\n public setContextsFromDeserialized(contexts: Context[], globalContextIndex: number): void {\n this._contexts = contexts\n if (globalContextIndex >= 0 && globalContextIndex < contexts.length) {\n this.globalContext = contexts[globalContextIndex]!\n }\n }\n\n public getModule(name: string): DvalaModule | undefined {\n return this.modules.get(name)\n }\n\n public getValueModule(name: string): { value: unknown, found: boolean } {\n if (this.valueModules.has(name)) {\n return { value: this.valueModules.get(name), found: true }\n }\n return { value: undefined, found: false }\n }\n\n public registerValueModule(name: string, value: unknown): void {\n this.valueModules.set(name, value)\n }\n\n public create(context: Context): ContextStack {\n const globalContext = this.globalContext\n const contextStack = new ContextStackImpl({\n contexts: [context, ...this._contexts],\n values: this.values,\n nativeJsFunctions: this.nativeJsFunctions,\n modules: this.modules,\n valueModules: this.valueModules,\n pure: this.pure,\n })\n contextStack.globalContext = globalContext\n return contextStack\n }\n\n public new(context: Context): ContextStack {\n const contexts = [{}, context]\n\n return new ContextStackImpl({ contexts, modules: this.modules, valueModules: this.valueModules, pure: this.pure })\n }\n\n public addValues(values: Record<string, Any>, sourceCodeInfo: SourceCodeInfo | undefined) {\n const currentContext = this._contexts[0]!\n for (const [name, value] of Object.entries(values)) {\n if (currentContext[name]) {\n throw new DvalaError(`Cannot redefine value \"${name}\"`, sourceCodeInfo)\n }\n const shadowedName = getShadowedBuiltinName(name)\n if (shadowedName) {\n throw new DvalaError(`Cannot shadow ${shadowedName}`, sourceCodeInfo)\n }\n currentContext[name] = { value: toAny(value) }\n }\n }\n\n public getValue(name: string): unknown {\n for (const context of this._contexts) {\n const contextEntry = context[name]\n if (contextEntry)\n return contextEntry.value\n }\n\n const nativeJsFunction = this.nativeJsFunctions?.[name]\n if (nativeJsFunction)\n return nativeJsFunction\n\n return this.values?.[name]\n }\n\n public lookUp(node: UserDefinedSymbolNode): LookUpResult {\n const value = node[1]\n\n for (const context of this._contexts) {\n const contextEntry = context[value]\n if (contextEntry)\n return contextEntry\n }\n const hostValue = this.values?.[value]\n if (hostValue !== undefined) {\n return {\n value: toAny(hostValue),\n }\n }\n\n const nativeJsFunction = this.nativeJsFunctions?.[value]\n if (nativeJsFunction) {\n return {\n value: nativeJsFunction,\n }\n }\n\n return null\n }\n\n public evaluateSymbol(node: SymbolNode): Any {\n if (isSpecialBuiltinSymbolNode(node)) {\n const functionType = node[1]\n switch (functionType) {\n case specialExpressionTypes['&&']:\n case specialExpressionTypes['||']:\n case specialExpressionTypes.array:\n case specialExpressionTypes.object:\n case specialExpressionTypes['defined?']:\n case specialExpressionTypes.recur:\n case specialExpressionTypes.throw:\n case specialExpressionTypes['??']: {\n const specialExpression: SpecialExpression = asNonUndefined(builtin.specialExpressions[functionType], node[2])\n return {\n [FUNCTION_SYMBOL]: true,\n functionType: 'SpecialBuiltin',\n specialBuiltinSymbolType: functionType,\n sourceCodeInfo: node[2],\n arity: specialExpression.arity,\n } satisfies SpecialBuiltinFunction\n }\n default:\n throw new DvalaError(`Unknown special builtin symbol type: ${functionType}`, node[2])\n }\n }\n if (isNormalBuiltinSymbolNode(node)) {\n const type = node[1]\n const normalExpression = allNormalExpressions[type]!\n const name = normalExpression.name!\n return {\n [FUNCTION_SYMBOL]: true,\n functionType: 'Builtin',\n normalBuiltinSymbolType: type,\n sourceCodeInfo: node[2],\n arity: normalExpression.arity,\n name,\n } satisfies NormalBuiltinFunction\n }\n const lookUpResult = this.lookUp(node)\n\n if (isContextEntry(lookUpResult))\n return lookUpResult.value\n\n throw new UndefinedSymbolError(node[1], node[2])\n }\n}\n\nfunction getShadowedBuiltinName(name: string): string | null {\n if (specialExpressionKeys.includes(name))\n return `special expression \"${name}\"`\n if (normalExpressionKeys.includes(name))\n return `builtin function \"${name}\"`\n if (name === 'self')\n return `builtin value \"${name}\"`\n return null\n}\n\nfunction assertNotShadowingBuiltin(name: string): void {\n const shadowedName = getShadowedBuiltinName(name)\n if (shadowedName) {\n throw new DvalaError(`Cannot shadow ${shadowedName}`, undefined)\n }\n}\n\nexport function createContextStack(params: ContextParams = {}, modules?: Map<string, DvalaModule>, pure?: boolean): ContextStack {\n const globalContext = params.globalContext ?? {}\n // Contexts are checked from left to right\n const contexts = params.contexts ? [globalContext, ...params.contexts] : [globalContext]\n\n // Process bindings: separate plain values from JS functions\n let hostValues: Record<string, unknown> | undefined\n let nativeJsFunctions: Record<string, NativeJsFunction> | undefined\n\n if (params.bindings) {\n for (const [identifier, entry] of Object.entries(params.bindings)) {\n if (identifier.includes('.')) {\n throw new DvalaError(`Dots are not allowed in binding keys: \"${identifier}\"`, undefined)\n }\n\n const isFunction = typeof entry === 'function'\n\n if (isFunction) {\n const jsFunction: JsFunction = { fn: entry as (...args: any[]) => unknown }\n\n assertNotShadowingBuiltin(identifier)\n if (!nativeJsFunctions) {\n nativeJsFunctions = {}\n }\n nativeJsFunctions[identifier] = {\n functionType: 'NativeJsFunction',\n nativeFn: jsFunction,\n name: identifier,\n [FUNCTION_SYMBOL]: true,\n arity: jsFunction.arity ?? {},\n docString: jsFunction.docString ?? '',\n } satisfies NativeJsFunction\n }\n else {\n // Plain value binding\n assertNotShadowingBuiltin(identifier)\n if (!hostValues) {\n hostValues = {}\n }\n hostValues[identifier] = entry\n }\n }\n }\n\n const contextStack = new ContextStackImpl({\n contexts,\n values: hostValues,\n modules,\n nativeJsFunctions,\n pure,\n })\n return params.globalModuleScope ? contextStack : contextStack.create({})\n}\n","/**\n * EffectRef Interning\n *\n * Maintains a module-level intern map so that `getEffectRef('llm.complete')`\n * always returns the exact same `EffectRef` object. This guarantees reference\n * equality (`===`) for effect values created with the same name, which is\n * important for handler matching in `try/with` blocks.\n *\n * EffectRef values are serializable — they are stored as just their name string.\n * When a continuation is restored, the name is used to look up (or recreate)\n * the unique EffectRef in the new runtime.\n */\n\nimport type { EffectRef } from '../parser/types'\nimport { EFFECT_SYMBOL } from '../utils/symbols'\n\nconst internMap = new Map<string, EffectRef>()\n\n/**\n * Returns the unique EffectRef for the given name.\n * Calling with the same name always returns the same reference.\n *\n * @example\n * const a = getEffectRef('llm.complete')\n * const b = getEffectRef('llm.complete')\n * a === b // true\n */\nexport function getEffectRef(name: string): EffectRef {\n let ref = internMap.get(name)\n if (!ref) {\n ref = {\n [EFFECT_SYMBOL]: true,\n name,\n }\n internMap.set(name, ref)\n }\n return ref\n}\n\n/**\n * Clears the intern map. Primarily for testing.\n */\nexport function clearEffectRefInternMap(): void {\n internMap.clear()\n}\n","import { NodeTypes } from '../constants/constants'\nimport type {\n AstNode,\n ExpressionNode,\n NormalBuiltinSymbolNode,\n NormalExpressionNode,\n NormalExpressionNodeWithName,\n SpecialBuiltinSymbolNode,\n SpreadNode,\n SymbolNode,\n UserDefinedSymbolNode,\n} from '../parser/types'\nimport type { SourceCodeInfo } from '../tokenizer/token'\nimport { getAssertionError } from '../utils/getAssertionError'\n\nexport function isSymbolNode(node: AstNode): node is SymbolNode {\n const nodeType = node[0]\n return NodeTypes.UserDefinedSymbol === nodeType\n || NodeTypes.NormalBuiltinSymbol === nodeType\n || NodeTypes.SpecialBuiltinSymbol === nodeType\n}\nexport function asSymbolNode(node: AstNode, sourceCodeInfo?: SourceCodeInfo): SymbolNode {\n assertSymbolNode(node, sourceCodeInfo)\n return node\n}\nexport function assertSymbolNode(node: AstNode, sourceCodeInfo?: SourceCodeInfo): asserts node is SymbolNode {\n if (!isSymbolNode(node))\n throw getAssertionError('SymbolNode', node, sourceCodeInfo)\n}\n\nexport function isUserDefinedSymbolNode(node: AstNode): node is UserDefinedSymbolNode {\n return NodeTypes.UserDefinedSymbol === node[0]\n}\nexport function asUserDefinedSymbolNode(node: AstNode, sourceCodeInfo?: SourceCodeInfo): UserDefinedSymbolNode {\n assertUserDefinedSymbolNode(node, sourceCodeInfo)\n return node\n}\nfunction assertUserDefinedSymbolNode(node: AstNode, sourceCodeInfo?: SourceCodeInfo): asserts node is UserDefinedSymbolNode {\n if (!isUserDefinedSymbolNode(node))\n throw getAssertionError('UserDefinedSymbolNode', node, sourceCodeInfo)\n}\n\nexport function isNormalBuiltinSymbolNode(node: AstNode): node is NormalBuiltinSymbolNode {\n return NodeTypes.NormalBuiltinSymbol === node[0]\n}\n\nexport function isSpecialBuiltinSymbolNode(node: AstNode): node is SpecialBuiltinSymbolNode {\n return NodeTypes.SpecialBuiltinSymbol === node[0]\n}\n\nexport function isNormalExpressionNode(node: AstNode): node is NormalExpressionNode {\n return node[0] === NodeTypes.NormalExpression\n}\nexport function asNormalExpressionNode(node: AstNode, sourceCodeInfo?: SourceCodeInfo): NormalExpressionNode {\n assertNormalExpressionNode(node, sourceCodeInfo)\n return node\n}\nexport function assertNormalExpressionNode(\n node: AstNode,\n sourceCodeInfo?: SourceCodeInfo,\n): asserts node is NormalExpressionNode {\n if (!isNormalExpressionNode(node))\n throw getAssertionError('NormalExpressionNode', node, sourceCodeInfo)\n}\n\nexport function isNormalExpressionNodeWithName(node: AstNode): node is NormalExpressionNodeWithName {\n if (!isNormalExpressionNode(node)) {\n return false\n }\n return isSymbolNode(node[1][0])\n}\nexport function asNormalExpressionNodeWithName(\n node: AstNode,\n sourceCodeInfo?: SourceCodeInfo,\n): NormalExpressionNodeWithName {\n assertNormalExpressionNodeWithName(node, sourceCodeInfo)\n return node\n}\nexport function assertNormalExpressionNodeWithName(\n node: AstNode,\n sourceCodeInfo?: SourceCodeInfo,\n): asserts node is NormalExpressionNodeWithName {\n if (!isNormalExpressionNodeWithName(node))\n throw getAssertionError('NormalExpressionNodeWithName', node, sourceCodeInfo)\n}\n\nexport function isExpressionNode(node: AstNode): node is ExpressionNode {\n return isNormalExpressionNode(node)\n || node[0] === NodeTypes.SpecialExpression\n || node[0] === NodeTypes.Number\n || node[0] === NodeTypes.String\n}\nexport function asExpressionNode(node: AstNode, sourceCodeInfo?: SourceCodeInfo): ExpressionNode {\n assertExpressionNode(node, sourceCodeInfo)\n return node\n}\nexport function assertExpressionNode(node: AstNode, sourceCodeInfo?: SourceCodeInfo): asserts node is ExpressionNode {\n if (!isExpressionNode(node))\n throw getAssertionError('ExpressionNode', node, sourceCodeInfo)\n}\n\nexport function isSpreadNode(node: AstNode): node is SpreadNode {\n return node[0] === NodeTypes.Spread\n}\n","import type { Builtin } from '../builtin/interface'\nimport type { DoNode } from '../builtin/specialExpressions/block'\nimport { specialExpressionTypes } from '../builtin/specialExpressionTypes'\nimport { NodeTypes } from '../constants/constants'\nimport { DvalaError } from '../errors'\nimport type { ContextStack } from '../evaluator/ContextStack'\nimport type { EvaluateNode } from '../evaluator/interface'\nimport type { Ast, AstNode, NormalExpressionNode, SpecialExpressionNode, SpreadNode, UserDefinedSymbolNode } from '../parser/types'\nimport { isNormalExpressionNodeWithName, isUserDefinedSymbolNode } from '../typeGuards/astNode'\n\nexport type UndefinedSymbols = Set<string>\n\nexport const getUndefinedSymbols: GetUndefinedSymbols = (ast, contextStack, builtin, evaluateNode) => {\n const nodes: AstNode[] = Array.isArray(ast)\n ? ast\n : [[NodeTypes.SpecialExpression, [specialExpressionTypes.block, ast.body]] satisfies DoNode]\n\n const unresolvedSymbols = new Set<string>()\n\n for (const subNode of nodes) {\n findUnresolvedSymbolsInNode(subNode, contextStack, builtin, evaluateNode)\n ?.forEach(symbol => unresolvedSymbols.add(symbol))\n }\n return unresolvedSymbols\n}\n\nexport type GetUndefinedSymbols = (ast: Ast | AstNode[], contextStack: ContextStack, builtin: Builtin, evaluateNode: EvaluateNode) => UndefinedSymbols\n\nfunction findUnresolvedSymbolsInNode(node: AstNode, contextStack: ContextStack, builtin: Builtin, evaluateNode: EvaluateNode): UndefinedSymbols | null {\n const nodeType = node[0]\n switch (nodeType) {\n case NodeTypes.UserDefinedSymbol: {\n const symbolNode = node as UserDefinedSymbolNode\n const lookUpResult = contextStack.lookUp(symbolNode)\n if (lookUpResult === null)\n return new Set([symbolNode[1]])\n\n return null\n }\n case NodeTypes.NormalBuiltinSymbol:\n case NodeTypes.SpecialBuiltinSymbol:\n case NodeTypes.String:\n case NodeTypes.Number:\n case NodeTypes.ReservedSymbol:\n case NodeTypes.Binding:\n return null\n case NodeTypes.NormalExpression: {\n const normalExpressionNode = node as NormalExpressionNode\n const unresolvedSymbols = new Set<string>()\n if (isNormalExpressionNodeWithName(normalExpressionNode)) {\n const [, [symbolNode]] = normalExpressionNode\n if (isUserDefinedSymbolNode(symbolNode)) {\n const lookUpResult = contextStack.lookUp(symbolNode)\n if (lookUpResult === null)\n unresolvedSymbols.add(symbolNode[1])\n }\n }\n else {\n const [, [expressionNode]] = normalExpressionNode\n findUnresolvedSymbolsInNode(expressionNode, contextStack, builtin, evaluateNode)?.forEach(symbol => unresolvedSymbols.add(symbol))\n }\n for (const subNode of normalExpressionNode[1][1]) {\n findUnresolvedSymbolsInNode(subNode, contextStack, builtin, evaluateNode)?.forEach(symbol => unresolvedSymbols.add(symbol))\n }\n return unresolvedSymbols\n }\n case NodeTypes.SpecialExpression: {\n const specialExpressionNode = node as SpecialExpressionNode\n const specialExpressionType = specialExpressionNode[1][0]\n const specialExpression = builtin.specialExpressions[specialExpressionType]\n\n const castedGetUndefinedSymbols = specialExpression.getUndefinedSymbols as Function\n\n return castedGetUndefinedSymbols(specialExpressionNode, contextStack, {\n getUndefinedSymbols,\n builtin,\n evaluateNode,\n }) as UndefinedSymbols\n }\n case NodeTypes.Spread:\n return findUnresolvedSymbolsInNode((node as SpreadNode)[1], contextStack, builtin, evaluateNode)\n\n /* v8 ignore next 2 */\n default:\n throw new DvalaError(`Unhandled node type: ${nodeType satisfies never}`, node[2])\n }\n}\n","/**\n * Shared types for the algebraic effects system.\n *\n * This module exists to break the circular dependency between `effects.ts`\n * (standalone functions) and `evaluator/trampoline.ts` (trampoline loop).\n * Both modules import types from here without creating a cycle.\n */\n\nimport type { Any } from '../interface'\nimport type { DvalaError } from '../errors'\nimport type { ContinuationStack } from './frames'\n\n// ---------------------------------------------------------------------------\n// Suspension blob — opaque serialized continuation\n// ---------------------------------------------------------------------------\n\n/**\n * Opaque string containing the serialized continuation stack.\n * Created by `suspend()`, consumed by `resume()`.\n * Internally it's JSON, but hosts should treat it as opaque.\n */\nexport type SuspensionBlob = string\n\n// ---------------------------------------------------------------------------\n// Effect handler types\n// ---------------------------------------------------------------------------\n\n/**\n * Context passed to a host effect handler.\n *\n * The handler must call exactly one of `resume` or `suspend`, exactly once.\n * Calling both, or calling either more than once, is a programming error.\n */\nexport interface EffectContext {\n /** Arguments from the Dvala `perform(eff, arg1, arg2, ...)` call. */\n args: Any[]\n\n /**\n * Aborted when: `race()` branch loses, runtime is disposed, or host cancels.\n * Combine with timeout: `AbortSignal.any([signal, AbortSignal.timeout(ms)])`\n */\n signal: AbortSignal\n\n /**\n * Resume the program with the given value (or a Promise that resolves to one).\n * The value becomes the result of the `perform(...)` expression in Dvala.\n */\n resume: (value: Any | Promise<Any>) => void\n\n /**\n * Suspend the program. The entire execution state is captured and returned\n * in `RunResult` as `{ type: 'suspended', continuation, meta }`.\n * `meta` is passed through to `RunResult.meta` for domain context\n * (e.g., assignee, deadline, priority).\n */\n suspend: (meta?: Any) => void\n}\n\n/** An async function that handles an effect by calling `resume` or `suspend`. */\nexport type EffectHandler = (ctx: EffectContext) => Promise<void>\n\n/** Map from effect name (e.g. `'llm.complete'`) to its handler. */\nexport type Handlers = Record<string, EffectHandler>\n\n// ---------------------------------------------------------------------------\n// Run result types\n// ---------------------------------------------------------------------------\n\n/**\n * The result of `run()` — always resolves, never rejects.\n * Errors are captured in the `error` variant.\n */\nexport type RunResult =\n | { type: 'completed', value: Any }\n | { type: 'suspended', blob: SuspensionBlob, meta?: Any }\n | { type: 'error', error: DvalaError }\n\n// ---------------------------------------------------------------------------\n// Suspension signal — used internally by the trampoline\n// ---------------------------------------------------------------------------\n\n/**\n * Thrown (as a promise rejection) by `suspend()` inside a host handler.\n * Caught by the effect trampoline loop — NOT by Dvala-level try/catch.\n */\nexport class SuspensionSignal {\n public readonly _brand = 'SuspensionSignal' as const\n constructor(\n /** The captured continuation stack at the point of suspension. */\n public readonly k: ContinuationStack,\n /** Optional domain metadata passed through to RunResult. */\n public readonly meta?: Any,\n ) {}\n}\n\nexport function isSuspensionSignal(value: unknown): value is SuspensionSignal {\n return value instanceof SuspensionSignal\n}\n","/**\n * Standard effects — built-in effects with default implementations.\n *\n * These effects are always available without requiring explicit host handlers.\n * Host handlers can override them (host handlers take priority in the lookup order).\n *\n * Lookup order: local try/with → host handlers → standard effects → unhandled error\n *\n * Standard effects:\n * - `dvala.log` — sync: console.log(...args), resumes with null\n * - `dvala.now` — sync: Date.now()\n * - `dvala.random` — sync: Math.random()\n * - `dvala.sleep` — async: setTimeout(resolve, ms), resumes with null\n *\n * Sync effects work in both `runSync` and `run`.\n * Async effects (`dvala.sleep`) only work in `run` — `runSync` will throw\n * when a Promise surfaces.\n */\n\nimport type { Any, Arr } from '../interface'\nimport { DvalaError } from '../errors'\nimport type { SourceCodeInfo } from '../tokenizer/token'\nimport type { ContinuationStack } from './frames'\nimport type { Step } from './step'\n\n// ---------------------------------------------------------------------------\n// Standard effect handler type\n// ---------------------------------------------------------------------------\n\n/**\n * A standard effect handler returns the next step directly.\n * Sync effects return `Step`, async effects return `Promise<Step>`.\n */\ntype StandardEffectHandler = (args: Arr, k: ContinuationStack, sourceCodeInfo?: SourceCodeInfo) => Step | Promise<Step>\n\n// ---------------------------------------------------------------------------\n// Standard effect implementations\n// ---------------------------------------------------------------------------\n\nconst standardEffectHandlers: Record<string, StandardEffectHandler> = {\n /**\n * `dvala.log` — Log arguments to console.\n * Resumes with null (logging is a side effect with no meaningful return value).\n */\n 'dvala.log': (args: Arr, k: ContinuationStack): Step => {\n // eslint-disable-next-line no-console\n console.log(...args)\n return { type: 'Value', value: null, k }\n },\n\n /**\n * `dvala.now` — Current timestamp in milliseconds since epoch.\n * Equivalent to `Date.now()`.\n */\n 'dvala.now': (_args: Arr, k: ContinuationStack): Step => {\n return { type: 'Value', value: Date.now(), k }\n },\n\n /**\n * `dvala.random` — Random float in [0, 1).\n * Equivalent to `Math.random()`.\n */\n 'dvala.random': (_args: Arr, k: ContinuationStack): Step => {\n return { type: 'Value', value: Math.random(), k }\n },\n\n /**\n * `dvala.sleep` — Wait for a specified number of milliseconds.\n * Resumes with null after the delay.\n * Only works in `run()` (async) — `runSync()` will throw.\n */\n 'dvala.sleep': (args: Arr, k: ContinuationStack, sourceCodeInfo?: SourceCodeInfo): Promise<Step> => {\n const ms = args[0] as Any\n if (typeof ms !== 'number' || ms < 0) {\n throw new DvalaError(`dvala.sleep requires a non-negative number argument, got ${typeof ms === 'number' ? ms : typeof ms}`, sourceCodeInfo)\n }\n return new Promise<Step>((resolve) => {\n setTimeout(() => resolve({ type: 'Value', value: null, k }), ms)\n })\n },\n}\n\n// ---------------------------------------------------------------------------\n// Public API\n// ---------------------------------------------------------------------------\n\n/** All standard effect names. */\nexport const standardEffectNames: ReadonlySet<string> = new Set(Object.keys(standardEffectHandlers))\n\n/**\n * Look up a standard effect handler by name.\n * Returns undefined if the effect is not a standard effect.\n */\nexport function getStandardEffectHandler(effectName: string): StandardEffectHandler | undefined {\n return standardEffectHandlers[effectName]\n}\n","/**\n * DvalaValue Serialization Contract\n *\n * Defines which runtime value types can be serialized to JSON and restored.\n * Used at suspension time to produce clear errors when non-serializable\n * values (e.g. NativeJsFunction) are found in the continuation stack.\n *\n * Serializable value types:\n * - Primitives: number, string, boolean, null\n * - Containers: array, object (if all contents are serializable)\n * - RegularExpression: stored as {s, f} string data\n * - UserDefinedFunction: {params, body, capturedEnv} — all plain data\n * - NormalBuiltinFunction: identified by normalBuiltinSymbolType (number)\n * - SpecialBuiltinFunction: identified by specialBuiltinSymbolType (number)\n * - ModuleFunction: identified by {moduleName, functionName}\n * - PartialFunction, CompFunction, ConstantlyFunction, JuxtFunction,\n * ComplementFunction, EveryPredFunction, SomePredFunction, FNullFunction:\n * serializable only if all inner values/functions are serializable\n * - EffectRef: stored as just the name string\n *\n * Non-serializable value types:\n * - NativeJsFunction: contains a live JS function reference.\n * These live in the global context and are re-injected from `bindings`\n * on resume — they must never appear in serialized continuation frames.\n */\n\nimport type { Any } from '../interface'\nimport { isDvalaFunction } from '../typeGuards/dvalaFunction'\nimport { isEffectRef, isRegularExpression } from '../typeGuards/dvala'\nimport type {\n DvalaFunction,\n} from '../parser/types'\n\n/**\n * Checks whether a Dvala runtime value is fully JSON-serializable.\n *\n * Returns `true` if the value can be serialized and later restored.\n * Returns `false` if any part of the value contains a NativeJsFunction\n * or other non-serializable reference.\n *\n * Uses a `Set` to track visited objects and avoid infinite loops from\n * circular references (which are themselves not serializable, but we\n * want to report NativeJsFunction as the problem, not stack overflow).\n */\nexport function isSerializable(value: Any, visited = new Set<object>()): boolean {\n // Primitives are always serializable\n if (value === null || typeof value === 'string' || typeof value === 'number' || typeof value === 'boolean') {\n return true\n }\n\n // Guard against circular references\n if (typeof value === 'object') {\n if (visited.has(value)) {\n return false\n }\n visited.add(value)\n }\n\n // RegularExpression — just string data {s, f}\n if (isRegularExpression(value)) {\n return true\n }\n\n // EffectRef — just a name string\n if (isEffectRef(value)) {\n return true\n }\n\n // DvalaFunction — check by functionType\n if (isDvalaFunction(value)) {\n return isDvalaFunctionSerializable(value, visited)\n }\n\n // Array — serializable if all elements are\n if (Array.isArray(value)) {\n return value.every(item => isSerializable(item as Any, visited))\n }\n\n // Plain object — serializable if all values are\n if (typeof value === 'object') {\n return Object.values(value).every(v => isSerializable(v as Any, visited))\n }\n\n // Anything else (shouldn't happen in well-typed code) is not serializable\n return false\n}\n\nfunction isDvalaFunctionSerializable(fn: DvalaFunction, visited: Set<object>): boolean {\n switch (fn.functionType) {\n // Always serializable — contain only primitive/index data\n case 'UserDefined':\n case 'Builtin':\n case 'SpecialBuiltin':\n case 'Module':\n return true\n\n // NativeJsFunction — never serializable\n case 'NativeJsFunction':\n return false\n\n // Conditionally serializable — check inner values/functions\n case 'Partial': {\n const partial = fn\n return isSerializable(partial.function as Any, visited)\n && partial.params.every(p => isSerializable(p as Any, visited))\n }\n\n case 'Comp': {\n const comp = fn\n return comp.params.every(p => isSerializable(p as Any, visited))\n }\n\n case 'Constantly': {\n const constantly = fn\n return isSerializable(constantly.value, visited)\n }\n\n case 'Juxt': {\n const juxt = fn\n return juxt.params.every(p => isSerializable(p as Any, visited))\n }\n\n case 'Complement': {\n const complement = fn\n return isSerializable(complement.function as Any, visited)\n }\n\n case 'EveryPred': {\n const everyPred = fn\n return everyPred.params.every(p => isSerializable(p as Any, visited))\n }\n\n case 'SomePred': {\n const somePred = fn\n return somePred.params.every(p => isSerializable(p as Any, visited))\n }\n\n case 'Fnull': {\n const fnull = fn\n return isSerializable(fnull.function as Any, visited)\n && fnull.params.every(p => isSerializable(p as Any, visited))\n }\n\n /* v8 ignore next 2 */\n default:\n return false\n }\n}\n\n/**\n * Describes why a value is not serializable.\n * Returns `null` if the value is serializable.\n * Returns a human-readable string describing the first non-serializable\n * component found.\n */\nexport function describeSerializationIssue(value: Any, path: string = 'value'): string | null {\n if (value === null || typeof value === 'string' || typeof value === 'number' || typeof value === 'boolean') {\n return null\n }\n\n if (isRegularExpression(value)) {\n return null\n }\n\n if (isEffectRef(value)) {\n return null\n }\n\n if (isDvalaFunction(value)) {\n if (value.functionType === 'NativeJsFunction') {\n return `${path} is a NativeJsFunction (${value.name ?? 'anonymous'}). NativeJsFunctions are not serializable — they are re-injected from bindings on resume.`\n }\n\n if (value.functionType === 'UserDefined' || value.functionType === 'Builtin' || value.functionType === 'SpecialBuiltin' || value.functionType === 'Module') {\n return null\n }\n\n // Check inner functions for compound function types\n if (value.functionType === 'Partial') {\n const partial = value\n const fnIssue = describeSerializationIssue(partial.function as Any, `${path}.function`)\n if (fnIssue)\n return fnIssue\n for (let i = 0; i < partial.params.length; i++) {\n const paramIssue = describeSerializationIssue(partial.params[i] as Any, `${path}.params[${i}]`)\n if (paramIssue)\n return paramIssue\n }\n return null\n }\n\n if (value.functionType === 'Comp') {\n const comp = value\n for (let i = 0; i < comp.params.length; i++) {\n const paramIssue = describeSerializationIssue(comp.params[i] as Any, `${path}.params[${i}]`)\n if (paramIssue)\n return paramIssue\n }\n return null\n }\n\n if (value.functionType === 'Complement') {\n const complement = value\n return describeSerializationIssue(complement.function as Any, `${path}.function`)\n }\n\n if (value.functionType === 'Constantly') {\n const constantly = value\n return describeSerializationIssue(constantly.value, `${path}.value`)\n }\n\n if (value.functionType === 'Juxt') {\n const juxt = value\n for (let i = 0; i < juxt.params.length; i++) {\n const paramIssue = describeSerializationIssue(juxt.params[i] as Any, `${path}.params[${i}]`)\n if (paramIssue)\n return paramIssue\n }\n return null\n }\n\n if (value.functionType === 'EveryPred') {\n const everyPred = value\n for (let i = 0; i < everyPred.params.length; i++) {\n const paramIssue = describeSerializationIssue(everyPred.params[i] as Any, `${path}.params[${i}]`)\n if (paramIssue)\n return paramIssue\n }\n return null\n }\n\n if (value.functionType === 'SomePred') {\n const somePred = value\n for (let i = 0; i < somePred.params.length; i++) {\n const paramIssue = describeSerializationIssue(somePred.params[i] as Any, `${path}.params[${i}]`)\n if (paramIssue)\n return paramIssue\n }\n return null\n }\n\n if (value.functionType === 'Fnull') {\n const fnull = value\n const fnIssue = describeSerializationIssue(fnull.function as Any, `${path}.function`)\n if (fnIssue)\n return fnIssue\n for (let i = 0; i < fnull.params.length; i++) {\n const paramIssue = describeSerializationIssue(fnull.params[i] as Any, `${path}.params[${i}]`)\n if (paramIssue)\n return paramIssue\n }\n return null\n }\n\n return `${path} has unknown function type ${value}`\n }\n\n if (Array.isArray(value)) {\n for (let i = 0; i < value.length; i++) {\n const issue = describeSerializationIssue(value[i] as Any, `${path}[${i}]`)\n if (issue)\n return issue\n }\n return null\n }\n\n if (typeof value === 'object') {\n for (const [key, v] of Object.entries(value)) {\n const issue = describeSerializationIssue(v as Any, `${path}.${key}`)\n if (issue)\n return issue\n }\n return null\n }\n\n return `${path} has unexpected type ${typeof value}`\n}\n","/**\n * Trampoline evaluator — explicit-stack evaluation engine.\n *\n * `stepNode(node, env, k)` maps an AST node to the next `Step`.\n * `applyFrame(frame, value, k)` processes a completed sub-result against a frame.\n * `tick(step)` processes one step and returns the next (or a Promise<Step> for async).\n * `runSyncTrampoline(step)` runs the trampoline synchronously to completion.\n * `runAsyncTrampoline(step)` runs the trampoline asynchronously to completion.\n *\n * Entry points:\n * - `evaluate(ast, contextStack)` — evaluate an AST (sync or async)\n * - `evaluateNode(node, contextStack)` — evaluate a single node (sync or async)\n *\n * Design principles:\n * - `stepNode` is always synchronous and returns `Step`.\n * - `applyFrame` may return `Step | Promise<Step>` when normal expressions\n * or compound function types produce async results.\n * - Normal built-in expressions are called directly with pre-evaluated args\n * (they may still use the old recursive `evaluateNode` internally for\n * higher-order callbacks — suspension through them is deferred).\n * - Binding utilities (`evaluateBindingNodeValues`, `tryMatch`) are called\n * with a recursive `evaluateNode` helper. This is acceptable for Phase 1.\n * - All state lives in frames (no JS closures) — enabling serialization later.\n */\n\nimport { builtin } from '../builtin'\nimport { evaluateBindingNodeValues, getAllBindingTargetNames, tryMatch } from '../builtin/bindingNode'\nimport type { LoopBindingNode } from '../builtin/specialExpressions/loops'\nimport type { MatchCase } from '../builtin/specialExpressions/match'\nimport { specialExpressionTypes } from '../builtin/specialExpressionTypes'\nimport { NodeTypes, getNodeTypeName } from '../constants/constants'\nimport { DvalaError, RecurSignal, UndefinedSymbolError, UserDefinedError } from '../errors'\nimport { getUndefinedSymbols } from '../getUndefinedSymbols'\nimport type { Any, Arr, Obj } from '../interface'\nimport type {\n Ast,\n AstNode,\n BindingNode,\n BindingTarget,\n CompFunction,\n DvalaFunction,\n EffectRef,\n EvaluatedFunction,\n EveryPredFunction,\n FNullFunction,\n FunctionLike,\n JuxtFunction,\n ModuleFunction,\n NativeJsFunction,\n NormalBuiltinFunction,\n NormalExpressionNode,\n NumberNode,\n PartialFunction,\n ReservedSymbolNode,\n SomePredFunction,\n SpecialBuiltinFunction,\n SpecialExpressionNode,\n StringNode,\n SymbolNode,\n UserDefinedFunction,\n UserDefinedSymbolNode,\n} from '../parser/types'\nimport { bindingTargetTypes } from '../parser/types'\nimport { reservedSymbolRecord } from '../tokenizer/reservedNames'\nimport type { SourceCodeInfo } from '../tokenizer/token'\nimport { asNonUndefined, isUnknownRecord } from '../typeGuards'\nimport { annotate } from '../typeGuards/annotatedArrays'\nimport { isNormalBuiltinSymbolNode, isNormalExpressionNodeWithName, isSpreadNode, isUserDefinedSymbolNode } from '../typeGuards/astNode'\nimport { asAny, asFunctionLike, assertEffectRef, assertSeq, isAny, isEffectRef, isObj } from '../typeGuards/dvala'\nimport { isDvalaFunction } from '../typeGuards/dvalaFunction'\nimport { assertNumber, isNumber } from '../typeGuards/number'\nimport { assertString } from '../typeGuards/string'\nimport { toAny } from '../utils'\nimport { arityAcceptsMin, assertNumberOfParams, toFixedArity } from '../utils/arity'\nimport { valueToString } from '../utils/debug/debugTools'\nimport type { MaybePromise } from '../utils/maybePromise'\nimport { chain, forEachSequential, mapSequential, reduceSequential } from '../utils/maybePromise'\nimport { FUNCTION_SYMBOL } from '../utils/symbols'\nimport type { EffectHandler, Handlers, RunResult } from './effectTypes'\nimport { SuspensionSignal, isSuspensionSignal } from './effectTypes'\nimport type { ContextStack } from './ContextStack'\nimport { getEffectRef } from './effectRef'\nimport { serializeSuspension } from './suspension'\nimport { getStandardEffectHandler } from './standardEffects'\nimport type {\n AndFrame,\n ArrayBuildFrame,\n BindingDefaultFrame,\n CallFnFrame,\n CondFrame,\n ContinuationStack,\n DebugStepFrame,\n EffectResumeFrame,\n EvalArgsFrame,\n EvaluatedWithHandler,\n FnBodyFrame,\n ForLoopFrame,\n Frame,\n IfBranchFrame,\n LetBindFrame,\n LoopBindFrame,\n LoopIterateFrame,\n MatchFrame,\n NanCheckFrame,\n ObjectBuildFrame,\n OrFrame,\n ParallelResumeFrame,\n PerformArgsFrame,\n QqFrame,\n RecurFrame,\n SequenceFrame,\n ThrowFrame,\n TryCatchFrame,\n TryWithFrame,\n} from './frames'\nimport type { Context } from './interface'\nimport type { Step } from './step'\n\n// Re-export for external use\nexport type { Step }\n\n// ---------------------------------------------------------------------------\n// Recursive evaluateNode — used as a helper for normal expressions and\n// binding utilities until the full trampoline migration is complete.\n// ---------------------------------------------------------------------------\n\nfunction evaluateNodeRecursive(node: AstNode, contextStack: ContextStack): MaybePromise<Any> {\n switch (node[0]) {\n case NodeTypes.Number:\n return (node as NumberNode)[1]\n case NodeTypes.String:\n return (node as StringNode)[1]\n case NodeTypes.NormalBuiltinSymbol:\n case NodeTypes.SpecialBuiltinSymbol:\n case NodeTypes.UserDefinedSymbol:\n return contextStack.evaluateSymbol(node as SymbolNode)\n case NodeTypes.ReservedSymbol:\n return evaluateReservedSymbol(node as ReservedSymbolNode)\n case NodeTypes.NormalExpression: {\n const result = evaluateNormalExpressionRecursive(node as NormalExpressionNode, contextStack)\n return chain(result, (resolved) => {\n if (typeof resolved === 'number' && Number.isNaN(resolved)) {\n throw new DvalaError('Number is NaN', node[2])\n }\n return annotate(resolved)\n })\n }\n case NodeTypes.SpecialExpression: {\n // Route through the trampoline — special expressions are fully handled\n // by stepSpecialExpression and their corresponding frame types.\n // This replaces the old `.evaluate()` call on special expression objects.\n const initial: Step = { type: 'Eval', node, env: contextStack, k: [] }\n try {\n return annotate(runSyncTrampoline(initial))\n }\n catch (error) {\n if (error instanceof DvalaError && error.message.includes('Unexpected async operation')) {\n const freshInitial: Step = { type: 'Eval', node, env: contextStack, k: [] }\n return runAsyncTrampoline(freshInitial).then(r => annotate(r))\n }\n throw error\n }\n }\n /* v8 ignore next 2 */\n default:\n throw new DvalaError(`${getNodeTypeName(node[0])}-node cannot be evaluated`, node[2])\n }\n}\n\nfunction evaluateParamsRecursive(\n paramNodes: AstNode[],\n contextStack: ContextStack,\n): MaybePromise<{ params: Arr, placeholders: number[] }> {\n const params: Arr = []\n const placeholders: number[] = []\n const result = forEachSequential(paramNodes, (paramNode, index) => {\n if (isSpreadNode(paramNode)) {\n return chain(evaluateNodeRecursive(paramNode[1], contextStack), (spreadValue) => {\n if (Array.isArray(spreadValue)) {\n params.push(...spreadValue)\n }\n else {\n throw new DvalaError(`Spread operator requires an array, got ${valueToString(paramNode)}`, paramNode[2])\n }\n })\n }\n else if (paramNode[0] === NodeTypes.ReservedSymbol && paramNode[1] === '_') {\n placeholders.push(index)\n }\n else {\n return chain(evaluateNodeRecursive(paramNode, contextStack), (value) => {\n params.push(value)\n })\n }\n })\n return chain(result, () => ({ params, placeholders }))\n}\n\nfunction evaluateNormalExpressionRecursive(node: NormalExpressionNode, contextStack: ContextStack): MaybePromise<Any> {\n const sourceCodeInfo = node[2]\n return chain(evaluateParamsRecursive(node[1][1], contextStack), ({ params, placeholders }) => {\n if (isNormalExpressionNodeWithName(node)) {\n const nameSymbol = node[1][0]\n if (placeholders.length > 0) {\n const fn = evaluateNodeRecursive(nameSymbol, contextStack)\n return chain(fn, (resolvedFn) => {\n const partialFunction: PartialFunction = {\n [FUNCTION_SYMBOL]: true,\n function: asFunctionLike(resolvedFn, sourceCodeInfo),\n functionType: 'Partial',\n params,\n placeholders,\n sourceCodeInfo,\n arity: toFixedArity(placeholders.length),\n }\n return partialFunction\n })\n }\n if (isNormalBuiltinSymbolNode(nameSymbol)) {\n const type = nameSymbol[1]\n const normalExpression = builtin.allNormalExpressions[type]!\n if (contextStack.pure && normalExpression.pure === false) {\n throw new DvalaError(`Cannot call impure function '${normalExpression.name}' in pure mode`, node[2])\n }\n return normalExpression.evaluate(params, node[2], contextStack, { executeFunction: executeFunctionRecursive })\n }\n else {\n const fn = contextStack.getValue(nameSymbol[1])\n if (fn !== undefined) {\n return executeFunctionRecursive(asFunctionLike(fn, sourceCodeInfo), params, contextStack, sourceCodeInfo)\n }\n throw new UndefinedSymbolError(nameSymbol[1], node[2])\n }\n }\n else {\n const fnNode: AstNode = node[1][0]\n return chain(evaluateNodeRecursive(fnNode, contextStack), (resolvedFn) => {\n const fn = asFunctionLike(resolvedFn, sourceCodeInfo)\n if (placeholders.length > 0) {\n const partialFunction: PartialFunction = {\n [FUNCTION_SYMBOL]: true,\n function: fn,\n functionType: 'Partial',\n params,\n placeholders,\n sourceCodeInfo,\n arity: toFixedArity(placeholders.length),\n }\n return partialFunction\n }\n return executeFunctionRecursive(fn, params, contextStack, sourceCodeInfo)\n })\n }\n })\n}\n\nfunction executeFunctionRecursive(fn: FunctionLike, params: Arr, contextStack: ContextStack, sourceCodeInfo?: SourceCodeInfo): MaybePromise<Any> {\n if (isDvalaFunction(fn)) {\n return executeDvalaFunctionRecursive(fn, params, contextStack, sourceCodeInfo)\n }\n if (Array.isArray(fn)) {\n return evaluateArrayAsFunction(fn, params, sourceCodeInfo)\n }\n if (isObj(fn)) {\n return evaluateObjectAsFunction(fn, params, sourceCodeInfo)\n }\n if (typeof fn === 'string') {\n return evaluateStringAsFunction(fn, params, sourceCodeInfo)\n }\n if (isNumber(fn)) {\n return evaluateNumberAsFunction(fn, params, sourceCodeInfo)\n }\n /* v8 ignore next 1 */\n throw new DvalaError('Unexpected function type', sourceCodeInfo)\n}\n\n/**\n * Execute a DvalaFunction recursively. This is the old-style executor\n * used as a fallback for normal expression callbacks.\n */\nfunction executeDvalaFunctionRecursive(fn: DvalaFunction, params: Arr, contextStack: ContextStack, sourceCodeInfo?: SourceCodeInfo): MaybePromise<Any> {\n switch (fn.functionType) {\n case 'UserDefined':\n return executeUserDefinedRecursive(fn, params, contextStack, sourceCodeInfo)\n case 'Partial':\n return executePartialRecursive(fn, params, contextStack, sourceCodeInfo)\n case 'Comp':\n return executeCompRecursive(fn, params, contextStack, sourceCodeInfo)\n case 'Constantly':\n return fn.value\n case 'Juxt':\n return executeJuxtRecursive(fn, params, contextStack, sourceCodeInfo)\n case 'Complement':\n return chain(executeFunctionRecursive(fn.function, params, contextStack, sourceCodeInfo), result => !result)\n case 'EveryPred':\n return executeEveryPredRecursive(fn, params, contextStack, sourceCodeInfo)\n case 'SomePred':\n return executeSomePredRecursive(fn, params, contextStack, sourceCodeInfo)\n case 'Fnull':\n return executeFnullRecursive(fn, params, contextStack, sourceCodeInfo)\n case 'Builtin':\n return executeBuiltinRecursive(fn, params, contextStack, sourceCodeInfo)\n case 'SpecialBuiltin':\n return executeSpecialBuiltinRecursive(fn, params, contextStack, sourceCodeInfo)\n case 'Module':\n return executeModuleRecursive(fn, params, contextStack, sourceCodeInfo)\n case 'NativeJsFunction':\n return executeNativeJsFunctionRecursive(fn, params, contextStack, sourceCodeInfo)\n }\n}\n\nfunction executeUserDefinedRecursive(fn: UserDefinedFunction, params: Arr, contextStack: ContextStack, sourceCodeInfo?: SourceCodeInfo): MaybePromise<Any> {\n function setupAndExecute(currentParams: Arr): MaybePromise<Any> {\n if (!arityAcceptsMin(fn.arity, currentParams.length)) {\n throw new DvalaError(`Expected ${fn.arity} arguments, got ${currentParams.length}.`, sourceCodeInfo)\n }\n const evaluatedFunction = fn.evaluatedfunction\n const args = evaluatedFunction[0]\n const nbrOfNonRestArgs = args.filter(arg => arg[0] !== bindingTargetTypes.rest).length\n const newContextStack = contextStack.create(fn.evaluatedfunction[2])\n const newContext: Context = { self: { value: fn } }\n const rest: Arr = []\n let paramSetup: MaybePromise<void> = undefined as unknown as void\n for (let i = 0; i < currentParams.length; i += 1) {\n if (i < nbrOfNonRestArgs) {\n const paramIndex = i\n paramSetup = chain(paramSetup, () => {\n const param = toAny(currentParams[paramIndex])\n return chain(evaluateBindingNodeValues(args[paramIndex]!, param, node =>\n evaluateNodeRecursive(node, newContextStack.create(newContext))), (valueRecord) => {\n Object.entries(valueRecord).forEach(([key, value]) => {\n newContext[key] = { value }\n })\n })\n })\n }\n else {\n rest.push(toAny(currentParams[i]))\n }\n }\n let defaultSetup: MaybePromise<void> = undefined as unknown as void\n for (let i = currentParams.length; i < nbrOfNonRestArgs; i++) {\n const argIndex = i\n defaultSetup = chain(defaultSetup, () => {\n const arg = args[argIndex]!\n return chain(evaluateNodeRecursive(arg[1][1]!, contextStack.create(newContext)), (defaultValue) => {\n return chain(evaluateBindingNodeValues(arg, defaultValue, node =>\n evaluateNodeRecursive(node, contextStack.create(newContext))), (valueRecord) => {\n Object.entries(valueRecord).forEach(([key, value]) => {\n newContext[key] = { value }\n })\n })\n })\n })\n }\n return chain(paramSetup, () => chain(defaultSetup, () => {\n const restArgument = args.find(arg => arg[0] === bindingTargetTypes.rest)\n const restSetup: MaybePromise<void> = restArgument !== undefined\n ? chain(evaluateBindingNodeValues(restArgument, rest, node =>\n evaluateNodeRecursive(node, contextStack.create(newContext))), (valueRecord) => {\n Object.entries(valueRecord).forEach(([key, value]) => {\n newContext[key] = { value }\n })\n })\n : undefined as unknown as void\n return chain(restSetup, () => {\n const newContextStack2 = newContextStack.create(newContext)\n const bodyResult = reduceSequential(\n evaluatedFunction[1],\n (_acc, node) => evaluateNodeRecursive(node, newContextStack2),\n null as Any,\n )\n if (bodyResult instanceof Promise) {\n return bodyResult.catch((error: unknown) => {\n if (error instanceof RecurSignal) {\n return setupAndExecute(error.params)\n }\n throw error\n })\n }\n return bodyResult\n })\n }))\n }\n for (;;) {\n try {\n const result = setupAndExecute(params)\n return result\n }\n catch (error) {\n if (error instanceof RecurSignal) {\n params = error.params\n continue\n }\n throw error\n }\n }\n}\n\nfunction executePartialRecursive(fn: PartialFunction, params: Arr, contextStack: ContextStack, sourceCodeInfo?: SourceCodeInfo): MaybePromise<Any> {\n const actualParams = [...fn.params]\n if (params.length !== fn.placeholders.length) {\n throw new DvalaError(`(partial) expects ${fn.placeholders.length} arguments, got ${params.length}.`, sourceCodeInfo)\n }\n const paramsCopy = [...params]\n for (const placeholderIndex of fn.placeholders) {\n actualParams.splice(placeholderIndex, 0, paramsCopy.shift())\n }\n return executeFunctionRecursive(fn.function, actualParams, contextStack, sourceCodeInfo)\n}\n\nfunction executeCompRecursive(fn: CompFunction, params: Arr, contextStack: ContextStack, sourceCodeInfo?: SourceCodeInfo): MaybePromise<Any> {\n const { params: f } = fn\n if (f.length === 0) {\n if (params.length !== 1)\n throw new DvalaError(`(comp) expects one argument, got ${valueToString(params.length)}.`, sourceCodeInfo)\n return asAny(params[0], sourceCodeInfo)\n }\n let result: MaybePromise<Arr> = params\n for (let i = f.length - 1; i >= 0; i--) {\n const fun = f[i]!\n result = chain(result, currentParams =>\n chain(executeFunctionRecursive(asFunctionLike(fun, sourceCodeInfo), currentParams, contextStack, sourceCodeInfo), r => [r]))\n }\n return chain(result, finalArr => asAny(finalArr[0], sourceCodeInfo))\n}\n\nfunction executeJuxtRecursive(fn: JuxtFunction, params: Arr, contextStack: ContextStack, sourceCodeInfo?: SourceCodeInfo): MaybePromise<Any> {\n return mapSequential(fn.params, fun =>\n executeFunctionRecursive(asFunctionLike(fun, sourceCodeInfo), params, contextStack, sourceCodeInfo))\n}\n\nfunction executeEveryPredRecursive(fn: EveryPredFunction, params: Arr, contextStack: ContextStack, sourceCodeInfo?: SourceCodeInfo): MaybePromise<Any> {\n const checks: Array<() => MaybePromise<Any>> = []\n for (const f of fn.params) {\n for (const param of params) {\n checks.push(() => executeFunctionRecursive(asFunctionLike(f, sourceCodeInfo), [param], contextStack, sourceCodeInfo))\n }\n }\n return reduceSequential(checks, (acc, check) => {\n if (!acc)\n return false\n return chain(check(), result => !!result)\n }, true as Any)\n}\n\nfunction executeSomePredRecursive(fn: SomePredFunction, params: Arr, contextStack: ContextStack, sourceCodeInfo?: SourceCodeInfo): MaybePromise<Any> {\n const checks: Array<() => MaybePromise<Any>> = []\n for (const f of fn.params) {\n for (const param of params) {\n checks.push(() => executeFunctionRecursive(asFunctionLike(f, sourceCodeInfo), [param], contextStack, sourceCodeInfo))\n }\n }\n return reduceSequential(checks, (acc, check) => {\n if (acc)\n return true\n return chain(check(), result => !!result)\n }, false as Any)\n}\n\nfunction executeFnullRecursive(fn: FNullFunction, params: Arr, contextStack: ContextStack, sourceCodeInfo?: SourceCodeInfo): MaybePromise<Any> {\n const fnulledParams = params.map((param, index) => (param === null ? toAny(fn.params[index]) : param))\n return executeFunctionRecursive(asFunctionLike(fn.function, sourceCodeInfo), fnulledParams, contextStack, sourceCodeInfo)\n}\n\nfunction executeBuiltinRecursive(fn: NormalBuiltinFunction, params: Arr, contextStack: ContextStack, sourceCodeInfo?: SourceCodeInfo): MaybePromise<Any> {\n const normalExpression = asNonUndefined(builtin.allNormalExpressions[fn.normalBuiltinSymbolType], sourceCodeInfo)\n if (contextStack.pure && normalExpression.pure === false) {\n throw new DvalaError(`Cannot call impure function '${fn.name}' in pure mode`, sourceCodeInfo)\n }\n return normalExpression.evaluate(params, sourceCodeInfo, contextStack, { executeFunction: executeFunctionRecursive })\n}\n\nfunction executeSpecialBuiltinRecursive(fn: SpecialBuiltinFunction, params: Arr, contextStack: ContextStack, sourceCodeInfo?: SourceCodeInfo): MaybePromise<Any> {\n const specialExpression = asNonUndefined(builtin.specialExpressions[fn.specialBuiltinSymbolType], sourceCodeInfo)\n if (specialExpression.evaluateAsNormalExpression) {\n return specialExpression.evaluateAsNormalExpression(params, sourceCodeInfo, contextStack, { executeFunction: executeFunctionRecursive })\n }\n throw new DvalaError(`Special builtin function ${fn.specialBuiltinSymbolType} is not supported as normal expression.`, sourceCodeInfo)\n}\n\nfunction executeModuleRecursive(fn: ModuleFunction, params: Arr, contextStack: ContextStack, sourceCodeInfo?: SourceCodeInfo): MaybePromise<Any> {\n const dvalaModule = contextStack.getModule(fn.moduleName)\n if (!dvalaModule) {\n throw new DvalaError(`Module '${fn.moduleName}' not found.`, sourceCodeInfo)\n }\n const expression = dvalaModule.functions[fn.functionName]\n if (!expression) {\n throw new DvalaError(`Function '${fn.functionName}' not found in module '${fn.moduleName}'.`, sourceCodeInfo)\n }\n if (contextStack.pure && expression.pure === false) {\n throw new DvalaError(`Cannot call impure function '${fn.functionName}' in pure mode`, sourceCodeInfo)\n }\n assertNumberOfParams(expression.arity, params.length, sourceCodeInfo)\n return expression.evaluate(params, sourceCodeInfo, contextStack, { executeFunction: executeFunctionRecursive })\n}\n\nfunction executeNativeJsFunctionRecursive(fn: NativeJsFunction, params: Arr, contextStack: ContextStack, sourceCodeInfo?: SourceCodeInfo): MaybePromise<Any> {\n if (contextStack.pure && !fn.nativeFn.pure) {\n throw new DvalaError(`Cannot call impure native function '${fn.name}' in pure mode`, sourceCodeInfo)\n }\n try {\n const result = fn.nativeFn.fn(...params)\n if (result instanceof Promise) {\n return result.then(\n resolved => toAny(resolved),\n (error: unknown) => {\n const message = typeof error === 'string'\n ? error\n : isUnknownRecord(error) && typeof error.message === 'string'\n ? error.message\n : '<no message>'\n throw new DvalaError(`Native function threw: \"${message}\"`, sourceCodeInfo)\n },\n )\n }\n return toAny(result)\n }\n catch (error) {\n const message = typeof error === 'string'\n ? error\n : isUnknownRecord(error) && typeof error.message === 'string'\n ? error.message\n : '<no message>'\n throw new DvalaError(`Native function threw: \"${message}\"`, sourceCodeInfo)\n }\n}\n\n// ---------------------------------------------------------------------------\n// Value-as-function helpers (shared between trampoline and recursive paths)\n// ---------------------------------------------------------------------------\n\nfunction evaluateObjectAsFunction(fn: Obj, params: Arr, sourceCodeInfo?: SourceCodeInfo): Any {\n if (params.length !== 1)\n throw new DvalaError('Object as function requires one string parameter.', sourceCodeInfo)\n const key = params[0]\n assertString(key, sourceCodeInfo)\n return toAny(fn[key])\n}\n\nfunction evaluateArrayAsFunction(fn: Arr, params: Arr, sourceCodeInfo?: SourceCodeInfo): Any {\n if (params.length !== 1)\n throw new DvalaError('Array as function requires one non negative integer parameter.', sourceCodeInfo)\n const index = params[0]\n assertNumber(index, sourceCodeInfo, { integer: true, nonNegative: true })\n return toAny(fn[index])\n}\n\nfunction evaluateStringAsFunction(fn: string, params: Arr, sourceCodeInfo?: SourceCodeInfo): Any {\n if (params.length !== 1)\n throw new DvalaError('String as function requires one Obj parameter.', sourceCodeInfo)\n const param = toAny(params[0])\n if (isObj(param))\n return toAny((param)[fn])\n if (isNumber(param, { integer: true }))\n return toAny(fn[param])\n throw new DvalaError(\n `string as function expects Obj or integer parameter, got ${valueToString(param)}`,\n sourceCodeInfo,\n )\n}\n\nfunction evaluateNumberAsFunction(fn: number, params: Arr, sourceCodeInfo?: SourceCodeInfo): Any {\n assertNumber(fn, undefined, { integer: true })\n if (params.length !== 1)\n throw new DvalaError('Number as function requires one Arr parameter.', sourceCodeInfo)\n const param = params[0]\n assertSeq(param, sourceCodeInfo)\n return toAny(param[fn])\n}\n\n// ---------------------------------------------------------------------------\n// Reserved symbol evaluation\n// ---------------------------------------------------------------------------\n\nfunction evaluateReservedSymbol(node: ReservedSymbolNode): Any {\n const reservedName = node[1]\n if (!['true', 'false', 'null'].includes(reservedName)) {\n throw new DvalaError(`Reserved symbol ${reservedName} cannot be evaluated`, node[2])\n }\n const value = reservedSymbolRecord[reservedName]\n return asNonUndefined(value, node[2])\n}\n\n// ---------------------------------------------------------------------------\n// Lambda helper (closure capture) — used by stepSpecialExpression for lambda\n// ---------------------------------------------------------------------------\n\nfunction evaluateFunction(\n fn: [BindingTarget[], AstNode[], ...unknown[]],\n contextStack: ContextStack,\n): EvaluatedFunction {\n const functionContext: Context = {}\n const context = fn[0].reduce((ctx: Context, arg) => {\n Object.keys(getAllBindingTargetNames(arg)).forEach((name) => {\n ctx[name] = { value: null }\n })\n return ctx\n }, {})\n const undefinedSymbols = getUndefinedSymbols(fn[1], contextStack.new(context), builtin, evaluateNodeRecursive)\n undefinedSymbols.forEach((name) => {\n const value = contextStack.getValue(name)\n if (isAny(value)) {\n functionContext[name] = { value }\n }\n })\n return [fn[0], fn[1], functionContext]\n}\n\n// ---------------------------------------------------------------------------\n// stepNode — map an AST node to the next Step\n// ---------------------------------------------------------------------------\n\n/**\n * Given an AST node, its environment, and a continuation stack, return\n * the next Step for the trampoline to process.\n *\n * Leaf nodes (numbers, strings, symbols) immediately produce values.\n * Compound nodes (expressions) push frames and return sub-evaluations.\n */\nexport function stepNode(node: AstNode, env: ContextStack, k: ContinuationStack): Step | Promise<Step> {\n switch (node[0]) {\n case NodeTypes.Number:\n return { type: 'Value', value: (node as NumberNode)[1], k }\n case NodeTypes.String:\n return { type: 'Value', value: (node as StringNode)[1], k }\n case NodeTypes.NormalBuiltinSymbol:\n case NodeTypes.SpecialBuiltinSymbol:\n case NodeTypes.UserDefinedSymbol:\n return { type: 'Value', value: env.evaluateSymbol(node as SymbolNode), k }\n case NodeTypes.ReservedSymbol:\n return { type: 'Value', value: evaluateReservedSymbol(node as ReservedSymbolNode), k }\n case NodeTypes.NormalExpression:\n return stepNormalExpression(node as NormalExpressionNode, env, k)\n case NodeTypes.SpecialExpression:\n return stepSpecialExpression(node as SpecialExpressionNode, env, k)\n /* v8 ignore next 2 */\n default:\n throw new DvalaError(`${getNodeTypeName(node[0])}-node cannot be evaluated`, node[2])\n }\n}\n\n// ---------------------------------------------------------------------------\n// stepNormalExpression — start evaluating a function call's arguments\n// ---------------------------------------------------------------------------\n\n/**\n * Normal expressions: evaluate arguments left-to-right, then dispatch.\n * Push EvalArgsFrame + NanCheckFrame, then start evaluating the first arg.\n */\nfunction stepNormalExpression(node: NormalExpressionNode, env: ContextStack, k: ContinuationStack): Step | Promise<Step> {\n const argNodes = node[1][1]\n const sourceCodeInfo = node[2]\n\n // NaN guard wraps the final result\n const nanFrame: NanCheckFrame = { type: 'NanCheck', sourceCodeInfo }\n\n // Argument evaluator frame\n const evalArgsFrame: EvalArgsFrame = {\n type: 'EvalArgs',\n node,\n index: 0,\n params: [],\n placeholders: [],\n env,\n sourceCodeInfo,\n }\n\n // Find the first real argument to evaluate (skip leading placeholders)\n let startIndex = 0\n while (startIndex < argNodes.length) {\n const arg = argNodes[startIndex]!\n if (arg[0] === NodeTypes.ReservedSymbol && arg[1] === '_') {\n evalArgsFrame.placeholders.push(evalArgsFrame.params.length)\n startIndex++\n }\n else {\n break\n }\n }\n evalArgsFrame.index = startIndex\n\n if (startIndex >= argNodes.length) {\n // No real args to evaluate — dispatch immediately\n return dispatchCall(evalArgsFrame, [nanFrame, ...k])\n }\n\n // Start evaluating the first real argument\n const firstArg = argNodes[startIndex]!\n const newK: ContinuationStack = [evalArgsFrame, nanFrame, ...k]\n if (isSpreadNode(firstArg)) {\n return { type: 'Eval', node: firstArg[1], env, k: newK }\n }\n return { type: 'Eval', node: firstArg, env, k: newK }\n}\n\n// ---------------------------------------------------------------------------\n// stepSpecialExpression — push frame for a special expression\n// ---------------------------------------------------------------------------\n\n/**\n * Special expressions: push a frame appropriate to the expression type\n * and return an EvalStep for the first sub-expression.\n */\nfunction stepSpecialExpression(node: SpecialExpressionNode, env: ContextStack, k: ContinuationStack): Step | Promise<Step> {\n const sourceCodeInfo = node[2]\n const type = node[1][0]\n\n switch (type) {\n // --- if / unless ---\n case specialExpressionTypes.if:\n case specialExpressionTypes.unless: {\n const [conditionNode, thenNode, elseNode] = node[1][1] as [AstNode, AstNode, AstNode?]\n const frame: IfBranchFrame = {\n type: 'IfBranch',\n thenNode,\n elseNode,\n inverted: type === specialExpressionTypes.unless,\n env,\n sourceCodeInfo,\n }\n return { type: 'Eval', node: conditionNode, env, k: [frame, ...k] }\n }\n\n // --- && (and) ---\n case specialExpressionTypes['&&']: {\n const nodes = node[1][1] as AstNode[]\n if (nodes.length === 0) {\n return { type: 'Value', value: true, k }\n }\n const frame: AndFrame = {\n type: 'And',\n nodes,\n index: 1,\n env,\n sourceCodeInfo,\n }\n if (nodes.length === 1) {\n return { type: 'Eval', node: nodes[0]!, env, k }\n }\n return { type: 'Eval', node: nodes[0]!, env, k: [frame, ...k] }\n }\n\n // --- || (or) ---\n case specialExpressionTypes['||']: {\n const nodes = node[1][1] as AstNode[]\n if (nodes.length === 0) {\n return { type: 'Value', value: false, k }\n }\n const frame: OrFrame = {\n type: 'Or',\n nodes,\n index: 1,\n env,\n sourceCodeInfo,\n }\n if (nodes.length === 1) {\n return { type: 'Eval', node: nodes[0]!, env, k }\n }\n return { type: 'Eval', node: nodes[0]!, env, k: [frame, ...k] }\n }\n\n // --- ?? (nullish coalescing) ---\n case specialExpressionTypes['??']: {\n const nodes = node[1][1] as AstNode[]\n if (nodes.length === 0) {\n return { type: 'Value', value: null, k }\n }\n // Check if the first node is an undefined user symbol\n const firstNode = nodes[0]!\n if (isUserDefinedSymbolNode(firstNode) && env.lookUp(firstNode) === null) {\n // Undefined symbol — treat as null, skip to next\n if (nodes.length === 1) {\n return { type: 'Value', value: null, k }\n }\n const frame: QqFrame = {\n type: 'Qq',\n nodes,\n index: 2,\n env,\n sourceCodeInfo,\n }\n const nextNode = nodes[1]!\n if (isUserDefinedSymbolNode(nextNode) && env.lookUp(nextNode) === null) {\n // Also undefined — continue skipping\n return skipUndefinedQq(frame, k)\n }\n if (nodes.length === 2) {\n return { type: 'Eval', node: nextNode, env, k }\n }\n return { type: 'Eval', node: nextNode, env, k: [frame, ...k] }\n }\n const frame: QqFrame = {\n type: 'Qq',\n nodes,\n index: 1,\n env,\n sourceCodeInfo,\n }\n if (nodes.length === 1) {\n return { type: 'Eval', node: firstNode, env, k }\n }\n return { type: 'Eval', node: firstNode, env, k: [frame, ...k] }\n }\n\n // --- cond ---\n case specialExpressionTypes.cond: {\n const cases = node[1][1] as [AstNode, AstNode][]\n if (cases.length === 0) {\n return { type: 'Value', value: null, k }\n }\n const frame: CondFrame = {\n type: 'Cond',\n phase: 'test',\n cases,\n index: 0,\n env,\n sourceCodeInfo,\n }\n return { type: 'Eval', node: cases[0]![0], env, k: [frame, ...k] }\n }\n\n // --- match ---\n case specialExpressionTypes.match: {\n const matchValueNode = node[1][1] as AstNode\n const cases = node[1][2] as MatchCase[]\n const frame: MatchFrame = {\n type: 'Match',\n phase: 'matchValue',\n matchValue: null,\n cases,\n index: 0,\n bindings: {},\n env,\n sourceCodeInfo,\n }\n return { type: 'Eval', node: matchValueNode, env, k: [frame, ...k] }\n }\n\n // --- block (do...end) ---\n case specialExpressionTypes.block: {\n const nodes = node[1][1] as AstNode[]\n const newContext: Context = {}\n const newEnv = env.create(newContext)\n if (nodes.length === 0) {\n return { type: 'Value', value: null, k }\n }\n if (nodes.length === 1) {\n return { type: 'Eval', node: nodes[0]!, env: newEnv, k }\n }\n const frame: SequenceFrame = {\n type: 'Sequence',\n nodes,\n index: 1,\n env: newEnv,\n sourceCodeInfo,\n }\n return { type: 'Eval', node: nodes[0]!, env: newEnv, k: [frame, ...k] }\n }\n\n // --- let ---\n case specialExpressionTypes.let: {\n const bindingNode = node[1][1] as BindingNode\n const target = bindingNode[1][0]\n const valueNode = bindingNode[1][1]\n const frame: LetBindFrame = {\n type: 'LetBind',\n target,\n env,\n sourceCodeInfo,\n }\n return { type: 'Eval', node: valueNode, env, k: [frame, ...k] }\n }\n\n // --- loop ---\n case specialExpressionTypes.loop: {\n const bindingNodes = node[1][1] as BindingNode[]\n const body = node[1][2] as AstNode\n if (bindingNodes.length === 0) {\n // No bindings — just evaluate the body with an empty context\n const newContext: Context = {}\n const frame: LoopIterateFrame = {\n type: 'LoopIterate',\n bindingNodes,\n bindingContext: newContext,\n body,\n env: env.create(newContext),\n sourceCodeInfo,\n }\n return { type: 'Eval', node: body, env: env.create(newContext), k: [frame, ...k] }\n }\n // Start evaluating the first binding's value\n const frame: LoopBindFrame = {\n type: 'LoopBind',\n phase: 'value',\n bindingNodes,\n index: 0,\n context: {},\n body,\n env,\n sourceCodeInfo,\n }\n return { type: 'Eval', node: bindingNodes[0]![1][1], env, k: [frame, ...k] }\n }\n\n // --- for / doseq ---\n case specialExpressionTypes.for:\n case specialExpressionTypes.doseq: {\n const loopBindings = node[1][1] as LoopBindingNode[]\n const body = node[1][2] as AstNode\n const returnResult = type === specialExpressionTypes.for\n if (loopBindings.length === 0) {\n return { type: 'Value', value: returnResult ? [] : null, k }\n }\n const context: Context = {}\n const newEnv = env.create(context)\n const frame: ForLoopFrame = {\n type: 'ForLoop',\n returnResult,\n bindingNodes: loopBindings,\n body,\n result: [],\n phase: 'evalCollection',\n bindingLevel: 0,\n levelStates: [],\n context,\n env: newEnv,\n sourceCodeInfo,\n }\n // Evaluate the first binding's collection expression\n const firstBinding = loopBindings[0]!\n const collectionNode = firstBinding[0][1][1] // bindingNode → [target, valueNode]\n return { type: 'Eval', node: collectionNode, env: newEnv, k: [frame, ...k] }\n }\n\n // --- try ---\n case specialExpressionTypes.try: {\n const tryExpression = node[1][1] as AstNode\n const errorSymbol = node[1][2] as SymbolNode | undefined\n const catchExpression = node[1][3] as AstNode | undefined\n const withHandlerNodes = node[1][4] as [AstNode, AstNode][] | undefined\n\n // Push effect handler frame if with-handlers exist\n if (withHandlerNodes && withHandlerNodes.length > 0) {\n // Eagerly evaluate effect expressions using recursive evaluator.\n // Effect expressions are always simple (effect(name) or variable refs),\n // so synchronous evaluation is safe.\n const evaluatedHandlers: EvaluatedWithHandler[] = withHandlerNodes.map(([effectExpr, handlerNode]) => ({\n effectRef: evaluateNodeRecursive(effectExpr, env) as Any,\n handlerNode,\n }))\n const withFrame: TryWithFrame = {\n type: 'TryWith',\n handlers: evaluatedHandlers,\n env,\n sourceCodeInfo,\n }\n if (catchExpression) {\n const catchFrame: TryCatchFrame = {\n type: 'TryCatch',\n errorSymbol: errorSymbol ? (errorSymbol as UserDefinedSymbolNode)[1] : null,\n catchNode: catchExpression,\n env,\n sourceCodeInfo,\n }\n return { type: 'Eval', node: tryExpression, env, k: [withFrame, catchFrame, ...k] }\n }\n return { type: 'Eval', node: tryExpression, env, k: [withFrame, ...k] }\n }\n\n // No with-handlers — just try/catch\n if (catchExpression) {\n const frame: TryCatchFrame = {\n type: 'TryCatch',\n errorSymbol: errorSymbol ? (errorSymbol as UserDefinedSymbolNode)[1] : null,\n catchNode: catchExpression,\n env,\n sourceCodeInfo,\n }\n return { type: 'Eval', node: tryExpression, env, k: [frame, ...k] }\n }\n // No catch, no with — just evaluate the body\n return { type: 'Eval', node: tryExpression, env, k }\n }\n\n // --- throw ---\n case specialExpressionTypes.throw: {\n const throwExpr = node[1][1] as AstNode\n const frame: ThrowFrame = {\n type: 'Throw',\n sourceCodeInfo,\n }\n return { type: 'Eval', node: throwExpr, env, k: [frame, ...k] }\n }\n\n // --- recur ---\n case specialExpressionTypes.recur: {\n const nodes = node[1][1] as AstNode[]\n if (nodes.length === 0) {\n return handleRecur([], k, sourceCodeInfo)\n }\n const frame: RecurFrame = {\n type: 'Recur',\n nodes,\n index: 1,\n params: [],\n env,\n sourceCodeInfo,\n }\n if (nodes.length === 1) {\n // Only one param — evaluate it, then recur\n const singleFrame: RecurFrame = { ...frame, index: 1 }\n return { type: 'Eval', node: nodes[0]!, env, k: [singleFrame, ...k] }\n }\n return { type: 'Eval', node: nodes[0]!, env, k: [frame, ...k] }\n }\n\n // --- array ---\n case specialExpressionTypes.array: {\n const nodes = node[1][1] as AstNode[]\n if (nodes.length === 0) {\n return { type: 'Value', value: [], k }\n }\n const firstNode = nodes[0]!\n const isFirstSpread = isSpreadNode(firstNode)\n const frame: ArrayBuildFrame = {\n type: 'ArrayBuild',\n nodes,\n index: 0,\n result: [],\n isSpread: isFirstSpread,\n env,\n sourceCodeInfo,\n }\n return {\n type: 'Eval',\n node: isFirstSpread ? firstNode[1] : firstNode,\n env,\n k: [frame, ...k],\n }\n }\n\n // --- object ---\n case specialExpressionTypes.object: {\n const nodes = node[1][1] as AstNode[]\n if (nodes.length === 0) {\n return { type: 'Value', value: {}, k }\n }\n const firstNode = nodes[0]!\n const isFirstSpread = isSpreadNode(firstNode)\n const frame: ObjectBuildFrame = {\n type: 'ObjectBuild',\n nodes,\n index: 0,\n result: {},\n currentKey: null,\n isSpread: isFirstSpread,\n env,\n sourceCodeInfo,\n }\n return {\n type: 'Eval',\n node: isFirstSpread ? firstNode[1] : firstNode,\n env,\n k: [frame, ...k],\n }\n }\n\n // --- lambda (fn / ->) ---\n case specialExpressionTypes['0_lambda']: {\n const fn = node[1][1] as [BindingTarget[], AstNode[], ...unknown[]]\n const docString = (node[1][2] ?? '') as string\n const evaluatedFunc = evaluateFunction(fn, env)\n const min = evaluatedFunc[0].filter(arg => arg[0] !== bindingTargetTypes.rest && arg[1][1] === undefined).length\n const max = evaluatedFunc[0].some(arg => arg[0] === bindingTargetTypes.rest) ? undefined : evaluatedFunc[0].length\n const arity = { min: min > 0 ? min : undefined, max }\n const dvalaFunction: DvalaFunction = {\n [FUNCTION_SYMBOL]: true,\n sourceCodeInfo: node[2],\n functionType: 'UserDefined',\n name: undefined,\n evaluatedfunction: evaluatedFunc,\n arity,\n docString,\n }\n return { type: 'Value', value: dvalaFunction, k }\n }\n\n // --- defined? ---\n case specialExpressionTypes['defined?']: {\n const symbolNode = node[1][1] as SymbolNode\n if (!isUserDefinedSymbolNode(symbolNode)) {\n return { type: 'Value', value: true, k }\n }\n const lookUpResult = env.lookUp(symbolNode)\n return { type: 'Value', value: lookUpResult !== null, k }\n }\n\n // --- import ---\n case specialExpressionTypes.import: {\n const moduleName = node[1][1] as string\n // Check for value modules first (file modules from bundles)\n const valueModule = env.getValueModule(moduleName)\n if (valueModule.found) {\n return { type: 'Value', value: valueModule.value as Any, k }\n }\n // Fall back to builtin modules\n const dvalaModule = env.getModule(moduleName)\n if (!dvalaModule) {\n throw new DvalaError(`Unknown module: '${moduleName}'`, sourceCodeInfo)\n }\n const result: Record<string, ModuleFunction> = {}\n for (const [functionName, expression] of Object.entries(dvalaModule.functions)) {\n result[functionName] = {\n [FUNCTION_SYMBOL]: true,\n sourceCodeInfo,\n functionType: 'Module',\n moduleName,\n functionName,\n arity: expression.arity,\n }\n }\n return { type: 'Value', value: result, k }\n }\n\n // --- effect ---\n case specialExpressionTypes.effect: {\n const effectName = node[1][1] as string\n return { type: 'Value', value: getEffectRef(effectName), k }\n }\n\n // --- perform ---\n case specialExpressionTypes.perform: {\n const effectExpr = node[1][1] as AstNode\n const argExprs = node[1][2] as AstNode[]\n const allNodes = [effectExpr, ...argExprs]\n if (allNodes.length === 1) {\n // Only the effect expression, no args — evaluate effect then dispatch\n const frame: PerformArgsFrame = {\n type: 'PerformArgs',\n argNodes: allNodes,\n index: 1,\n params: [],\n env,\n sourceCodeInfo,\n }\n return { type: 'Eval', node: allNodes[0]!, env, k: [frame, ...k] }\n }\n const frame: PerformArgsFrame = {\n type: 'PerformArgs',\n argNodes: allNodes,\n index: 1,\n params: [],\n env,\n sourceCodeInfo,\n }\n return { type: 'Eval', node: allNodes[0]!, env, k: [frame, ...k] }\n }\n\n // --- parallel ---\n case specialExpressionTypes.parallel: {\n const branches = node[1][1] as AstNode[]\n return { type: 'Parallel', branches, env, k }\n }\n\n // --- race ---\n case specialExpressionTypes.race: {\n const branches = node[1][1] as AstNode[]\n return { type: 'Race', branches, env, k }\n }\n\n /* v8 ignore next 2 */\n default:\n throw new DvalaError(`Unknown special expression type: ${type}`, sourceCodeInfo)\n }\n}\n\n// ---------------------------------------------------------------------------\n// dispatchCall — dispatch a function call after args are evaluated\n// ---------------------------------------------------------------------------\n\n/**\n * After all arguments are collected in an EvalArgsFrame, determine what\n * to call and return the next Step.\n */\nfunction dispatchCall(frame: EvalArgsFrame, k: ContinuationStack): Step | Promise<Step> {\n const { node, params, placeholders, env, sourceCodeInfo } = frame\n\n if (isNormalExpressionNodeWithName(node)) {\n const nameSymbol = node[1][0]\n\n // --- Partial application ---\n if (placeholders.length > 0) {\n const fn = env.evaluateSymbol(nameSymbol)\n const partialFunction: PartialFunction = {\n [FUNCTION_SYMBOL]: true,\n function: asFunctionLike(fn, sourceCodeInfo),\n functionType: 'Partial',\n params,\n placeholders,\n sourceCodeInfo,\n arity: toFixedArity(placeholders.length),\n }\n return { type: 'Value', value: partialFunction, k }\n }\n\n // --- Named builtin ---\n if (isNormalBuiltinSymbolNode(nameSymbol)) {\n const builtinType = nameSymbol[1]\n const normalExpression = builtin.allNormalExpressions[builtinType]!\n if (env.pure && normalExpression.pure === false) {\n throw new DvalaError(`Cannot call impure function '${normalExpression.name}' in pure mode`, sourceCodeInfo)\n }\n // Call the normal expression directly — it may use executeFunction internally\n const result = normalExpression.evaluate(params, sourceCodeInfo, env, { executeFunction: executeFunctionRecursive })\n return wrapMaybePromiseAsStep(result, k)\n }\n\n // --- Named user-defined ---\n const fn = env.getValue(nameSymbol[1])\n if (fn !== undefined) {\n return dispatchFunction(asFunctionLike(fn, sourceCodeInfo), params, placeholders, env, sourceCodeInfo, k)\n }\n throw new UndefinedSymbolError(nameSymbol[1], sourceCodeInfo)\n }\n else {\n // --- Anonymous function expression ---\n // The function expression is the first payload element; need to evaluate it\n const fnNode: AstNode = node[1][0]\n const callFrame: CallFnFrame = {\n type: 'CallFn',\n params,\n placeholders,\n env,\n sourceCodeInfo,\n }\n return { type: 'Eval', node: fnNode, env, k: [callFrame, ...k] }\n }\n}\n\n/**\n * Dispatch a resolved function value with pre-evaluated parameters.\n */\nfunction dispatchFunction(fn: FunctionLike, params: Arr, placeholders: number[], env: ContextStack, sourceCodeInfo: SourceCodeInfo | undefined, k: ContinuationStack): Step | Promise<Step> {\n if (placeholders.length > 0) {\n const partialFunction: PartialFunction = {\n [FUNCTION_SYMBOL]: true,\n function: fn,\n functionType: 'Partial',\n params,\n placeholders,\n sourceCodeInfo,\n arity: toFixedArity(placeholders.length),\n }\n return { type: 'Value', value: partialFunction, k }\n }\n\n if (isDvalaFunction(fn)) {\n return dispatchDvalaFunction(fn, params, env, sourceCodeInfo, k)\n }\n\n // Non-function callables: arrays, objects, strings, numbers\n if (Array.isArray(fn)) {\n return { type: 'Value', value: evaluateArrayAsFunction(fn, params, sourceCodeInfo), k }\n }\n if (isObj(fn)) {\n return { type: 'Value', value: evaluateObjectAsFunction(fn, params, sourceCodeInfo), k }\n }\n if (typeof fn === 'string') {\n return { type: 'Value', value: evaluateStringAsFunction(fn, params, sourceCodeInfo), k }\n }\n if (isNumber(fn)) {\n return { type: 'Value', value: evaluateNumberAsFunction(fn, params, sourceCodeInfo), k }\n }\n /* v8 ignore next 1 */\n throw new DvalaError('Unexpected function type', sourceCodeInfo)\n}\n\n/**\n * Dispatch a DvalaFunction. User-defined functions are set up with frames;\n * compound function types (Comp, Juxt, etc.) use the recursive executor.\n */\nfunction dispatchDvalaFunction(fn: DvalaFunction, params: Arr, env: ContextStack, sourceCodeInfo: SourceCodeInfo | undefined, k: ContinuationStack): Step | Promise<Step> {\n switch (fn.functionType) {\n case 'UserDefined': {\n return setupUserDefinedCall(fn, params, env, sourceCodeInfo, k)\n }\n // Compound function types: use recursive execution for now\n // (they involve internal iteration that would need its own frame types)\n case 'Partial':\n case 'Comp':\n case 'Constantly':\n case 'Juxt':\n case 'Complement':\n case 'EveryPred':\n case 'SomePred':\n case 'Fnull':\n case 'Builtin':\n case 'SpecialBuiltin':\n case 'Module':\n case 'NativeJsFunction': {\n const result = executeDvalaFunctionRecursive(fn, params, env, sourceCodeInfo)\n return wrapMaybePromiseAsStep(result, k)\n }\n }\n}\n\n/**\n * Set up a user-defined function call: bind params, push FnBodyFrame.\n *\n * For Phase 1, parameter binding (including destructuring defaults) is done\n * synchronously via evaluateBindingNodeValues with the recursive evaluator.\n * This will be converted to use frames in a later phase.\n */\nfunction setupUserDefinedCall(fn: UserDefinedFunction, params: Arr, env: ContextStack, sourceCodeInfo: SourceCodeInfo | undefined, k: ContinuationStack): Step | Promise<Step> {\n if (!arityAcceptsMin(fn.arity, params.length)) {\n throw new DvalaError(`Expected ${fn.arity} arguments, got ${params.length}.`, sourceCodeInfo)\n }\n const evaluatedFunc = fn.evaluatedfunction\n const args = evaluatedFunc[0]\n const nbrOfNonRestArgs = args.filter(arg => arg[0] !== bindingTargetTypes.rest).length\n const newContextStack = env.create(fn.evaluatedfunction[2])\n const newContext: Context = { self: { value: fn } }\n const rest: Arr = []\n\n // Bind non-rest params synchronously\n for (let i = 0; i < params.length; i += 1) {\n if (i < nbrOfNonRestArgs) {\n const param = toAny(params[i])\n const valueRecord = evaluateBindingNodeValues(args[i]!, param, n =>\n evaluateNodeRecursive(n, newContextStack.create(newContext)))\n if (valueRecord instanceof Promise) {\n // Fall back to recursive execution for async binding\n const result = executeUserDefinedRecursive(fn, params, env, sourceCodeInfo)\n return wrapMaybePromiseAsStep(result, k)\n }\n Object.entries(valueRecord).forEach(([key, value]) => {\n newContext[key] = { value }\n })\n }\n else {\n rest.push(toAny(params[i]))\n }\n }\n\n // Handle default values for optional params\n for (let i = params.length; i < nbrOfNonRestArgs; i++) {\n const arg = args[i]!\n const defaultValue = evaluateNodeRecursive(arg[1][1]!, newContextStack.create(newContext))\n if (defaultValue instanceof Promise) {\n const result = executeUserDefinedRecursive(fn, params, env, sourceCodeInfo)\n return wrapMaybePromiseAsStep(result, k)\n }\n const valueRecord = evaluateBindingNodeValues(arg, defaultValue, n =>\n evaluateNodeRecursive(n, newContextStack.create(newContext)))\n if (valueRecord instanceof Promise) {\n const result = executeUserDefinedRecursive(fn, params, env, sourceCodeInfo)\n return wrapMaybePromiseAsStep(result, k)\n }\n Object.entries(valueRecord).forEach(([key, value]) => {\n newContext[key] = { value }\n })\n }\n\n // Handle rest argument\n const restArgument = args.find(arg => arg[0] === bindingTargetTypes.rest)\n if (restArgument) {\n const valueRecord = evaluateBindingNodeValues(restArgument, rest, n =>\n evaluateNodeRecursive(n, newContextStack.create(newContext)))\n if (valueRecord instanceof Promise) {\n const result = executeUserDefinedRecursive(fn, params, env, sourceCodeInfo)\n return wrapMaybePromiseAsStep(result, k)\n }\n Object.entries(valueRecord).forEach(([key, value]) => {\n newContext[key] = { value }\n })\n }\n\n // Evaluate the body as a sequence\n const bodyNodes = evaluatedFunc[1]\n const bodyEnv = newContextStack.create(newContext)\n\n if (bodyNodes.length === 0) {\n return { type: 'Value', value: null, k }\n }\n\n const fnBodyFrame: FnBodyFrame = {\n type: 'FnBody',\n fn,\n bodyIndex: 1,\n env: bodyEnv,\n outerEnv: env,\n sourceCodeInfo,\n }\n\n if (bodyNodes.length === 1) {\n return { type: 'Eval', node: bodyNodes[0]!, env: bodyEnv, k: [fnBodyFrame, ...k] }\n }\n\n return { type: 'Eval', node: bodyNodes[0]!, env: bodyEnv, k: [fnBodyFrame, ...k] }\n}\n\n// ---------------------------------------------------------------------------\n// applyFrame — process a completed sub-result against a frame\n// ---------------------------------------------------------------------------\n\n/**\n * Given a completed sub-expression value and the top frame from the\n * continuation stack, determine the next Step.\n */\nexport function applyFrame(frame: Frame, value: Any, k: ContinuationStack): Step | Promise<Step> {\n switch (frame.type) {\n case 'Sequence':\n return applySequence(frame, value, k)\n case 'IfBranch':\n return applyIfBranch(frame, value, k)\n case 'Cond':\n return applyCond(frame, value, k)\n case 'Match':\n return applyMatch(frame, value, k)\n case 'And':\n return applyAnd(frame, value, k)\n case 'Or':\n return applyOr(frame, value, k)\n case 'Qq':\n return applyQq(frame, value, k)\n case 'ArrayBuild':\n return applyArrayBuild(frame, value, k)\n case 'ObjectBuild':\n return applyObjectBuild(frame, value, k)\n case 'LetBind':\n return applyLetBind(frame, value, k)\n case 'LoopBind':\n return applyLoopBind(frame, value, k)\n case 'LoopIterate':\n return applyLoopIterate(frame, value, k)\n case 'ForLoop':\n return applyForLoop(frame, value, k)\n case 'Throw':\n return applyThrow(frame, value, k)\n case 'Recur':\n return applyRecur(frame, value, k)\n case 'PerformArgs':\n return applyPerformArgs(frame, value, k)\n case 'TryCatch':\n return applyTryCatch(value, k)\n case 'TryWith':\n return applyTryWith(value, k)\n case 'EffectResume':\n return applyEffectResume(frame, value, k)\n case 'ParallelResume':\n return applyParallelResume(frame, value, k)\n case 'EvalArgs':\n return applyEvalArgs(frame, value, k)\n case 'CallFn':\n return applyCallFn(frame, value, k)\n case 'FnBody':\n return applyFnBody(frame, value, k)\n case 'BindingDefault':\n return applyBindingDefault(frame, value, k)\n case 'NanCheck':\n return applyNanCheck(frame, value, k)\n case 'DebugStep':\n return applyDebugStep(frame, value, k)\n /* v8 ignore next 2 */\n default: {\n const _exhaustive: never = frame\n throw new DvalaError(`Unhandled frame type: ${(_exhaustive as Frame).type}`, undefined)\n }\n }\n}\n\n// ---------------------------------------------------------------------------\n// Frame apply handlers\n// ---------------------------------------------------------------------------\n\nfunction applySequence(frame: SequenceFrame, _value: Any, k: ContinuationStack): Step {\n const { nodes, index, env } = frame\n if (index >= nodes.length) {\n // All nodes evaluated — return the last value\n return { type: 'Value', value: _value, k }\n }\n // More nodes to evaluate\n const newFrame: SequenceFrame = { ...frame, index: index + 1 }\n if (index === nodes.length - 1) {\n // Last node — no need for frame\n return { type: 'Eval', node: nodes[index]!, env, k }\n }\n return { type: 'Eval', node: nodes[index]!, env, k: [newFrame, ...k] }\n}\n\nfunction applyIfBranch(frame: IfBranchFrame, value: Any, k: ContinuationStack): Step {\n const { thenNode, elseNode, inverted, env } = frame\n const condition = inverted ? !value : value\n if (condition) {\n return { type: 'Eval', node: thenNode, env, k }\n }\n if (elseNode) {\n return { type: 'Eval', node: elseNode, env, k }\n }\n return { type: 'Value', value: null, k }\n}\n\nfunction applyCond(frame: CondFrame, value: Any, k: ContinuationStack): Step {\n const { cases, index, env } = frame\n\n if (frame.phase === 'test') {\n if (value) {\n // Test is truthy — evaluate the body\n return { type: 'Eval', node: cases[index]![1], env, k }\n }\n // Test is falsy — try next case\n const nextIndex = index + 1\n if (nextIndex >= cases.length) {\n return { type: 'Value', value: null, k }\n }\n const newFrame: CondFrame = { ...frame, index: nextIndex }\n return { type: 'Eval', node: cases[nextIndex]![0], env, k: [newFrame, ...k] }\n }\n\n // phase === 'body' — body has been evaluated\n return { type: 'Value', value, k }\n}\n\nfunction applyMatch(frame: MatchFrame, value: Any, k: ContinuationStack): Step {\n const { cases, env } = frame\n\n if (frame.phase === 'matchValue') {\n // matchValue has been evaluated — start processing cases\n const matchValue = value\n return processMatchCase({ ...frame, matchValue, phase: 'guard' }, k)\n }\n\n if (frame.phase === 'guard') {\n // Guard was evaluated\n if (!value) {\n // Guard failed — try next case\n const newFrame: MatchFrame = { ...frame, index: frame.index + 1, bindings: {} }\n return processMatchCase(newFrame, k)\n }\n // Guard passed — evaluate body\n const context: Context = {}\n for (const [name, val] of Object.entries(frame.bindings)) {\n context[name] = { value: val }\n }\n const newEnv = env.create(context)\n return { type: 'Eval', node: cases[frame.index]![1], env: newEnv, k }\n }\n\n // phase === 'body' — body has been evaluated\n return { type: 'Value', value, k }\n}\n\n/**\n * Process match cases starting from `frame.index`.\n * Uses recursive tryMatch with evaluateNodeRecursive for pattern matching.\n */\nfunction processMatchCase(frame: MatchFrame, k: ContinuationStack): Step {\n const { matchValue, cases, index, env, sourceCodeInfo } = frame\n\n for (let i = index; i < cases.length; i++) {\n const [pattern, body, guard] = cases[i]!\n const bindings = tryMatch(pattern, matchValue, n => evaluateNodeRecursive(n, env))\n\n if (bindings instanceof Promise) {\n // Async tryMatch — fall back to recursive evaluation\n // This handles the case where pattern matching involves async operations\n throw new DvalaError('Async pattern matching not supported in trampoline yet', sourceCodeInfo)\n }\n\n if (bindings === null) {\n continue // Pattern didn't match — try next case\n }\n\n // Pattern matched\n if (guard) {\n // Need to evaluate guard with bindings in scope\n const context: Context = {}\n for (const [name, val] of Object.entries(bindings)) {\n context[name] = { value: val }\n }\n const guardEnv = env.create(context)\n const guardFrame: MatchFrame = { ...frame, phase: 'guard', index: i, bindings }\n return { type: 'Eval', node: guard, env: guardEnv, k: [guardFrame, ...k] }\n }\n\n // No guard — evaluate body directly\n const context: Context = {}\n for (const [name, val] of Object.entries(bindings)) {\n context[name] = { value: val }\n }\n const bodyEnv = env.create(context)\n return { type: 'Eval', node: body, env: bodyEnv, k }\n }\n\n // No case matched\n return { type: 'Value', value: null, k }\n}\n\nfunction applyAnd(frame: AndFrame, value: Any, k: ContinuationStack): Step {\n if (!value) {\n return { type: 'Value', value, k }\n }\n const { nodes, index, env } = frame\n if (index >= nodes.length) {\n return { type: 'Value', value, k }\n }\n if (index === nodes.length - 1) {\n // Last node — no need for frame\n return { type: 'Eval', node: nodes[index]!, env, k }\n }\n const newFrame: AndFrame = { ...frame, index: index + 1 }\n return { type: 'Eval', node: nodes[index]!, env, k: [newFrame, ...k] }\n}\n\nfunction applyOr(frame: OrFrame, value: Any, k: ContinuationStack): Step {\n if (value) {\n return { type: 'Value', value, k }\n }\n const { nodes, index, env } = frame\n if (index >= nodes.length) {\n return { type: 'Value', value, k }\n }\n if (index === nodes.length - 1) {\n return { type: 'Eval', node: nodes[index]!, env, k }\n }\n const newFrame: OrFrame = { ...frame, index: index + 1 }\n return { type: 'Eval', node: nodes[index]!, env, k: [newFrame, ...k] }\n}\n\nfunction applyQq(frame: QqFrame, value: Any, k: ContinuationStack): Step {\n // If value is non-null, we found our result\n if (value !== null) {\n return { type: 'Value', value, k }\n }\n return advanceQq(frame, k)\n}\n\n/** Advance ?? to the next node, skipping undefined user symbols. */\nfunction advanceQq(frame: QqFrame, k: ContinuationStack): Step {\n const { nodes, env } = frame\n let { index } = frame\n\n // Skip undefined user symbols\n while (index < nodes.length) {\n const node = nodes[index]!\n if (isUserDefinedSymbolNode(node) && env.lookUp(node) === null) {\n index++\n continue\n }\n break\n }\n\n if (index >= nodes.length) {\n return { type: 'Value', value: null, k }\n }\n\n if (index === nodes.length - 1) {\n // Last node — no need for frame\n return { type: 'Eval', node: nodes[index]!, env, k }\n }\n\n const newFrame: QqFrame = { ...frame, index: index + 1 }\n return { type: 'Eval', node: nodes[index]!, env, k: [newFrame, ...k] }\n}\n\n/** Skip undefined user symbols in ?? until we find one to evaluate. */\nfunction skipUndefinedQq(frame: QqFrame, k: ContinuationStack): Step {\n return advanceQq(frame, k)\n}\n\nfunction applyArrayBuild(frame: ArrayBuildFrame, value: Any, k: ContinuationStack): Step {\n const { nodes, result, env, sourceCodeInfo } = frame\n\n // Process the completed value\n if (frame.isSpread) {\n if (!Array.isArray(value)) {\n throw new DvalaError('Spread value is not an array', sourceCodeInfo)\n }\n result.push(...value)\n }\n else {\n result.push(value)\n }\n\n // Advance to next element\n const nextIndex = frame.index + 1\n if (nextIndex >= nodes.length) {\n return { type: 'Value', value: result, k }\n }\n\n const nextNode = nodes[nextIndex]!\n const isNextSpread = isSpreadNode(nextNode)\n const newFrame: ArrayBuildFrame = { ...frame, index: nextIndex, isSpread: isNextSpread }\n return {\n type: 'Eval',\n node: isNextSpread ? nextNode[1] : nextNode,\n env,\n k: [newFrame, ...k],\n }\n}\n\nfunction applyObjectBuild(frame: ObjectBuildFrame, value: Any, k: ContinuationStack): Step {\n const { nodes, result, env, sourceCodeInfo } = frame\n\n if (frame.isSpread) {\n // Spread value should be an object\n if (!isUnknownRecord(value)) {\n throw new DvalaError('Spread value is not an object', sourceCodeInfo)\n }\n Object.assign(result, value)\n // Advance to next entry\n const nextIndex = frame.index + 1\n if (nextIndex >= nodes.length) {\n return { type: 'Value', value: result, k }\n }\n const nextNode = nodes[nextIndex]!\n const isNextSpread = isSpreadNode(nextNode)\n const newFrame: ObjectBuildFrame = { ...frame, index: nextIndex, currentKey: null, isSpread: isNextSpread }\n return {\n type: 'Eval',\n node: isNextSpread ? nextNode[1] : nextNode,\n env,\n k: [newFrame, ...k],\n }\n }\n\n if (frame.currentKey === null) {\n // We just evaluated a key expression\n assertString(value, sourceCodeInfo)\n const valueNode = nodes[frame.index + 1]\n if (valueNode === undefined) {\n throw new DvalaError('Missing value for key', sourceCodeInfo)\n }\n const newFrame: ObjectBuildFrame = { ...frame, currentKey: value }\n return { type: 'Eval', node: valueNode, env, k: [newFrame, ...k] }\n }\n else {\n // We just evaluated a value expression\n result[frame.currentKey] = value\n // Advance to next key-value pair\n const nextIndex = frame.index + 2\n if (nextIndex >= nodes.length) {\n return { type: 'Value', value: result, k }\n }\n const nextNode = nodes[nextIndex]!\n const isNextSpread = isSpreadNode(nextNode)\n const newFrame: ObjectBuildFrame = { ...frame, index: nextIndex, currentKey: null, isSpread: isNextSpread }\n return {\n type: 'Eval',\n node: isNextSpread ? nextNode[1] : nextNode,\n env,\n k: [newFrame, ...k],\n }\n }\n}\n\nfunction applyLetBind(frame: LetBindFrame, value: Any, k: ContinuationStack): Step | Promise<Step> {\n const { target, env, sourceCodeInfo } = frame\n\n // Process the binding using the recursive helper\n const bindingResult = evaluateBindingNodeValues(target, value, n => evaluateNodeRecursive(n, env))\n return chain(bindingResult, (br) => {\n env.addValues(br, sourceCodeInfo)\n return { type: 'Value' as const, value, k }\n })\n}\n\nfunction applyLoopBind(frame: LoopBindFrame, value: Any, k: ContinuationStack): Step | Promise<Step> {\n const { bindingNodes, index, context, body, env, sourceCodeInfo } = frame\n\n // Value for the current binding has been evaluated\n const bindingNode = bindingNodes[index]!\n const target = bindingNode[1][0]\n\n const valueRecord = evaluateBindingNodeValues(target, value, n => evaluateNodeRecursive(n, env.create(context)))\n return chain(valueRecord, (vr) => {\n Object.entries(vr).forEach(([name, val]) => {\n context[name] = { value: val }\n })\n\n // Move to next binding\n const nextIndex = index + 1\n if (nextIndex >= bindingNodes.length) {\n // All bindings done — set up the loop iteration\n const loopEnv = env.create(context)\n const iterateFrame: LoopIterateFrame = {\n type: 'LoopIterate',\n bindingNodes,\n bindingContext: context,\n body,\n env: loopEnv,\n sourceCodeInfo,\n }\n return { type: 'Eval' as const, node: body, env: loopEnv, k: [iterateFrame, ...k] }\n }\n\n // Evaluate next binding's value expression (in context with previous bindings)\n const newFrame: LoopBindFrame = { ...frame, index: nextIndex }\n return { type: 'Eval' as const, node: bindingNodes[nextIndex]![1][1], env: env.create(context), k: [newFrame, ...k] }\n })\n}\n\nfunction applyLoopIterate(_frame: LoopIterateFrame, value: Any, k: ContinuationStack): Step {\n // Body has been evaluated successfully — return the value\n // (recur is handled by the RecurFrame, which will pop back to this frame)\n return { type: 'Value', value, k }\n}\n\nfunction applyForLoop(frame: ForLoopFrame, value: Any, k: ContinuationStack): Step | Promise<Step> {\n const { returnResult, bindingNodes, result, env, sourceCodeInfo, context } = frame\n const { asColl, isSeq } = getCollectionUtils()\n\n switch (frame.phase) {\n case 'evalCollection': {\n // A collection expression has been evaluated\n const coll = asColl(value, sourceCodeInfo)\n const seq = isSeq(coll) ? coll : Object.entries(coll as Obj)\n\n if ((seq as Arr).length === 0) {\n // Empty collection — abort this level\n return handleForAbort(frame, k)\n }\n\n // Store collection for this level\n const levelStates = [...frame.levelStates]\n levelStates[frame.bindingLevel] = { collection: seq as Arr, index: 0 }\n\n // Process the first element's binding\n const binding = bindingNodes[frame.bindingLevel]!\n const targetNode = binding[0][1][0]\n const element = (seq as Arr)[0]\n\n const elValue = asAny(element, sourceCodeInfo)\n const valueRecord = evaluateBindingNodeValues(targetNode, elValue, n => evaluateNodeRecursive(n, env))\n return chain(valueRecord, (vr) => {\n Object.entries(vr).forEach(([name, val]) => {\n context[name] = { value: val }\n })\n\n // Process let-bindings if any\n const letBindings = binding[1]\n if (letBindings.length > 0) {\n return processForLetBindings(frame, levelStates, letBindings, 0, k)\n }\n\n // Process when-guard if any\n return processForGuards(frame, levelStates, k)\n })\n }\n\n case 'evalLet': {\n // A let-binding value has been evaluated; handled via recursive fallback\n // (processForLetBindings handles this inline)\n /* v8 ignore next 1 */\n throw new DvalaError('ForLoop evalLet should not reach applyFrame', sourceCodeInfo)\n }\n\n case 'evalWhen': {\n // When-guard has been evaluated\n if (!value) {\n // When-guard failed — advance to next element\n return advanceForElement(frame, k)\n }\n // Check while-guard\n const binding = bindingNodes[frame.bindingLevel]!\n const whileNode = binding[3]\n if (whileNode) {\n const newFrame: ForLoopFrame = { ...frame, phase: 'evalWhile' }\n return { type: 'Eval', node: whileNode, env, k: [newFrame, ...k] }\n }\n return processForNextLevel(frame, k)\n }\n\n case 'evalWhile': {\n if (!value) {\n // While-guard failed — skip remaining elements at this level\n const levelStates = [...frame.levelStates]\n levelStates[frame.bindingLevel] = {\n ...levelStates[frame.bindingLevel]!,\n index: Number.POSITIVE_INFINITY,\n }\n return advanceForElement({ ...frame, levelStates }, k)\n }\n return processForNextLevel(frame, k)\n }\n\n case 'evalBody': {\n // Body has been evaluated\n if (returnResult) {\n result.push(value)\n }\n // Advance innermost binding to next element\n return advanceForElement(frame, k)\n }\n\n /* v8 ignore next 2 */\n case 'evalElement':\n throw new DvalaError(`Unexpected ForLoop phase: ${frame.phase}`, sourceCodeInfo)\n }\n\n /* v8 ignore next 1 */\n return { type: 'Value', value: null, k }\n}\n\n/** Handle for-loop abort: no more elements at the outermost level. */\nfunction handleForAbort(frame: ForLoopFrame, k: ContinuationStack): Step {\n return { type: 'Value', value: frame.returnResult ? frame.result : null, k }\n}\n\n/** Advance to the next element at the current binding level. */\nfunction advanceForElement(frame: ForLoopFrame, k: ContinuationStack): Step | Promise<Step> {\n const { bindingNodes, env, sourceCodeInfo, context } = frame\n const levelStates = [...frame.levelStates]\n const bindingLevel = frame.bindingLevel\n\n // Advance the innermost level\n const currentLevel = bindingLevel\n const currentState = levelStates[currentLevel]!\n const nextElementIndex = currentState.index + 1\n\n if (nextElementIndex >= currentState.collection.length) {\n // No more elements at this level — back up\n if (currentLevel === 0) {\n return handleForAbort(frame, k)\n }\n // Move to next element of the parent level\n return advanceForElement({ ...frame, bindingLevel: currentLevel - 1 }, k)\n }\n\n // Process next element at current level\n levelStates[currentLevel] = { ...currentState, index: nextElementIndex }\n const binding = bindingNodes[currentLevel]!\n const targetNode = binding[0][1][0]\n const element = currentState.collection[nextElementIndex]\n const elValue = asAny(element, sourceCodeInfo)\n\n const valueRecord = evaluateBindingNodeValues(targetNode, elValue, n => evaluateNodeRecursive(n, env))\n return chain(valueRecord, (vr) => {\n Object.entries(vr).forEach(([name, val]) => {\n context[name] = { value: val }\n })\n\n // Process let-bindings\n const letBindings = binding[1]\n if (letBindings.length > 0) {\n return processForLetBindings({ ...frame, levelStates, bindingLevel: currentLevel }, levelStates, letBindings, 0, k)\n }\n\n return processForGuards({ ...frame, levelStates, bindingLevel: currentLevel }, levelStates, k)\n })\n}\n\n/** Process let-bindings at the current for-loop level. */\nfunction processForLetBindings(frame: ForLoopFrame, levelStates: ForLoopFrame['levelStates'], letBindings: BindingNode[], letIndex: number, k: ContinuationStack): Step | Promise<Step> {\n const { env, context } = frame\n\n let result: MaybePromise<void> = undefined as unknown as void\n for (let i = letIndex; i < letBindings.length; i++) {\n const bindingIndex = i\n result = chain(result, () => {\n const bindingNode = letBindings[bindingIndex]!\n const [target, bindingValue] = bindingNode[1]\n const val = evaluateNodeRecursive(bindingValue, env)\n return chain(val, (v) => {\n const valueRecord = evaluateBindingNodeValues(target, v, n => evaluateNodeRecursive(n, env))\n return chain(valueRecord, (vr) => {\n Object.entries(vr).forEach(([name, value]) => {\n context[name] = { value }\n })\n })\n })\n })\n }\n\n return chain(result, () => processForGuards({ ...frame, levelStates }, levelStates, k))\n}\n\n/** Process when/while guards at the current level. */\nfunction processForGuards(frame: ForLoopFrame, levelStates: ForLoopFrame['levelStates'], k: ContinuationStack): Step {\n const { bindingNodes, env } = frame\n const binding = bindingNodes[frame.bindingLevel]!\n const whenNode = binding[2]\n const whileNode = binding[3]\n\n if (whenNode) {\n const newFrame: ForLoopFrame = { ...frame, levelStates, phase: 'evalWhen' }\n return { type: 'Eval', node: whenNode, env, k: [newFrame, ...k] }\n }\n\n if (whileNode) {\n const newFrame: ForLoopFrame = { ...frame, levelStates, phase: 'evalWhile' }\n return { type: 'Eval', node: whileNode, env, k: [newFrame, ...k] }\n }\n\n return processForNextLevel({ ...frame, levelStates }, k)\n}\n\n/** After guards pass, either go deeper (more binding levels) or evaluate body. */\nfunction processForNextLevel(frame: ForLoopFrame, k: ContinuationStack): Step {\n const { bindingNodes, body, env } = frame\n const nextLevel = frame.bindingLevel + 1\n\n if (nextLevel < bindingNodes.length) {\n // Go deeper — evaluate the next level's collection\n const binding = bindingNodes[nextLevel]!\n const collectionNode = binding[0][1][1]\n const newFrame: ForLoopFrame = {\n ...frame,\n phase: 'evalCollection',\n bindingLevel: nextLevel,\n }\n return { type: 'Eval', node: collectionNode, env, k: [newFrame, ...k] }\n }\n\n // All levels bound — evaluate the body\n const newFrame: ForLoopFrame = { ...frame, phase: 'evalBody' }\n return { type: 'Eval', node: body, env, k: [newFrame, ...k] }\n}\n\n/**\n * Search the continuation stack for the nearest TryCatchFrame.\n * If found, evaluate the catch body with the error bound (if errorSymbol is set).\n * If not found, re-throw the error.\n */\nfunction unwindToTryCatch(error: unknown, k: ContinuationStack): Step {\n for (let i = 0; i < k.length; i++) {\n const f = k[i]!\n if (f.type === 'TryCatch') {\n const { errorSymbol, catchNode, env } = f\n const catchContext: Context = errorSymbol\n ? { [errorSymbol]: { value: error as Any } }\n : {}\n const remainingK = k.slice(i + 1)\n return { type: 'Eval', node: catchNode, env: env.create(catchContext), k: remainingK }\n }\n }\n // No TryCatchFrame found — re-throw the error\n throw error\n}\n\nfunction applyThrow(frame: ThrowFrame, value: Any, k: ContinuationStack): Step {\n assertString(value, frame.sourceCodeInfo, { nonEmpty: true })\n const error = new UserDefinedError(value, frame.sourceCodeInfo)\n return unwindToTryCatch(error, k)\n}\n\nfunction applyRecur(frame: RecurFrame, value: Any, k: ContinuationStack): Step | Promise<Step> {\n const { nodes, index, params, env } = frame\n params.push(value)\n\n if (index >= nodes.length) {\n // All recur params collected — handle recur via continuation stack\n return handleRecur(params, k, frame.sourceCodeInfo)\n }\n\n // Evaluate next param\n const newFrame: RecurFrame = { ...frame, index: index + 1 }\n return { type: 'Eval', node: nodes[index]!, env, k: [newFrame, ...k] }\n}\n\n/**\n * Handle recur by searching the continuation stack for the nearest\n * LoopIterateFrame or FnBodyFrame, rebinding parameters, and restarting.\n * This replaces the exception-based RecurSignal approach from the recursive\n * evaluator with proper continuation-based control flow.\n */\nfunction handleRecur(params: Arr, k: ContinuationStack, sourceCodeInfo: SourceCodeInfo | undefined): Step | Promise<Step> {\n for (let i = 0; i < k.length; i++) {\n const frame = k[i]!\n\n if (frame.type === 'LoopIterate') {\n // Found loop frame — rebind variables and re-evaluate body\n const { bindingNodes, bindingContext, body, env } = frame\n const remainingK = k.slice(i + 1)\n\n if (params.length !== bindingNodes.length) {\n throw new DvalaError(\n `recur expected ${bindingNodes.length} parameters, got ${params.length}`,\n sourceCodeInfo,\n )\n }\n\n const rebindAll: MaybePromise<void> = forEachSequential(\n bindingNodes,\n (bindingNode, j) => {\n const target = bindingNode[1][0]\n const param = toAny(params[j])\n return chain(\n evaluateBindingNodeValues(target, param, n => evaluateNodeRecursive(n, env)),\n (valueRecord) => {\n Object.entries(valueRecord).forEach(([name, val]) => {\n bindingContext[name] = { value: val }\n })\n },\n )\n },\n )\n\n return chain(rebindAll, () => {\n // After serialization/deserialization, env's innermost context and\n // bindingContext may be separate copies. Sync them by copying the\n // updated bindings into the env's innermost context.\n const envContexts = env.getContextsRaw()\n const innermostContext = envContexts[0]!\n if (innermostContext !== bindingContext) {\n for (const [name, entry] of Object.entries(bindingContext)) {\n innermostContext[name] = entry\n }\n }\n\n // Push fresh LoopIterateFrame and re-evaluate body\n const newIterateFrame: LoopIterateFrame = {\n type: 'LoopIterate',\n bindingNodes,\n bindingContext,\n body,\n env,\n sourceCodeInfo: frame.sourceCodeInfo,\n }\n return { type: 'Eval' as const, node: body, env, k: [newIterateFrame, ...remainingK] }\n })\n }\n\n if (frame.type === 'FnBody') {\n // Found function body frame — restart with new params\n const { fn, outerEnv } = frame\n const remainingK = k.slice(i + 1)\n return setupUserDefinedCall(fn, params, outerEnv, frame.sourceCodeInfo, remainingK)\n }\n }\n\n throw new DvalaError('recur called outside of loop or function body', sourceCodeInfo)\n}\n\nfunction applyTryCatch(_value: Any, k: ContinuationStack): Step {\n // Try body completed successfully — the catch frame is discarded.\n // The value propagates up past the TryCatchFrame.\n return { type: 'Value', value: _value, k }\n}\n\nfunction applyTryWith(_value: Any, k: ContinuationStack): Step {\n // Try body completed successfully — the with frame is discarded.\n // The value propagates up past the TryWithFrame.\n return { type: 'Value', value: _value, k }\n}\n\nfunction applyEffectResume(frame: EffectResumeFrame, value: Any, _k: ContinuationStack): Step {\n // The handler returned a value. Replace the continuation with resumeK\n // (the original continuation from the perform call site, with TryWithFrame\n // still on the stack for subsequent performs).\n // The _k (handler's remaining outer_k) is discarded — resumeK already\n // includes the full original continuation.\n return { type: 'Value', value, k: frame.resumeK }\n}\n\n/**\n * Convert a ParallelResumeFrame into a ParallelResumeStep.\n *\n * The value is the resume value from the host for the first suspended branch.\n * The actual resumption logic happens in `tick()` → `handleParallelResume()`\n * which has access to `handlers` and `signal`.\n */\nfunction applyParallelResume(frame: ParallelResumeFrame, value: Any, k: ContinuationStack): Step {\n return {\n type: 'ParallelResume',\n value,\n branchCount: frame.branchCount,\n completedBranches: frame.completedBranches,\n suspendedBranches: frame.suspendedBranches,\n k,\n }\n}\n\nfunction applyPerformArgs(frame: PerformArgsFrame, value: Any, k: ContinuationStack): Step | Promise<Step> {\n const { argNodes, index, params, env } = frame\n params.push(value)\n\n if (index >= argNodes.length) {\n // All values collected — first is the effect ref, rest are args\n const effectRef = params[0]!\n assertEffectRef(effectRef, frame.sourceCodeInfo)\n const args = params.slice(1)\n // Produce a PerformStep — let the trampoline dispatch it\n return { type: 'Perform', effect: effectRef, args, k }\n }\n\n // Evaluate next arg\n const newFrame: PerformArgsFrame = { ...frame, index: index + 1 }\n return { type: 'Eval', node: argNodes[index]!, env, k: [newFrame, ...k] }\n}\n\n/**\n * Dispatch a Perform step by searching the continuation stack for a matching\n * TryWithFrame. If found, evaluate the handler and use its return value as the\n * result of the perform call. If not found, throw an unhandled effect error.\n *\n * Handler semantics (per P&P / Dvala contract):\n * - Handler receives the perform args as an array: `([arg1, arg2]) -> ...`\n * - Handler's return value IS the resume value — no explicit resume needed\n * - Handlers run OUTSIDE the try/with scope — the TryWithFrame is removed\n * from the handler's error/effect path. An EffectResumeFrame bridges the\n * handler's return value back to the original continuation.\n * - The handler function's environment is the one captured at the with-clause,\n * NOT the environment at the perform call site\n *\n * Continuation structure:\n * Original k: [...body_k, TryWithFrame(i), TryCatchFrame?(i+1), ...outer_k]\n * Handler's k: [EffectResumeFrame{resumeK=k}, ...outer_k]\n * When handler returns V: EffectResumeFrame replaces k with original k,\n * so V flows through body_k with TryWithFrame still on stack.\n */\nfunction dispatchPerform(effect: EffectRef, args: Arr, k: ContinuationStack, sourceCodeInfo?: SourceCodeInfo, handlers?: Handlers, signal?: AbortSignal): Step | Promise<Step> {\n for (let i = 0; i < k.length; i++) {\n const frame = k[i]!\n if (frame.type === 'TryWith') {\n // Search this frame's handlers for a matching effect\n for (const handler of frame.handlers) {\n if (isEffectRef(handler.effectRef) && handler.effectRef.name === effect.name) {\n // Found a match!\n // resumeK = original k — handler's return value resumes here\n // (TryWithFrame stays on the stack for subsequent performs)\n const resumeK = k\n\n // Determine outer_k — skip TryWithFrame and any adjacent TryCatchFrame\n // from the same try/with/catch block, so errors and effects from the\n // handler propagate upward past the current try block.\n let skipEnd = i + 1\n if (skipEnd < k.length && k[skipEnd]!.type === 'TryCatch') {\n skipEnd++ // also skip the TryCatchFrame from the same block\n }\n const outerK = k.slice(skipEnd)\n\n // Handler's continuation: EffectResumeFrame bridges back to resumeK\n const effectResumeFrame: EffectResumeFrame = {\n type: 'EffectResume',\n resumeK,\n sourceCodeInfo,\n }\n const handlerK: ContinuationStack = [effectResumeFrame, ...outerK]\n\n // Evaluate the handler fn expression using recursive evaluator.\n // Handler expressions are always simple (lambda or variable refs).\n const handlerFn = evaluateNodeRecursive(handler.handlerNode, frame.env) as Any\n const fnLike = asFunctionLike(handlerFn, frame.sourceCodeInfo)\n // Call the handler with args as an array\n return dispatchFunction(fnLike, [args], [], frame.env, sourceCodeInfo, handlerK)\n }\n }\n }\n }\n\n // No matching local handler found — dispatch to host handler if available.\n const hostHandler = handlers?.[effect.name]\n if (hostHandler) {\n return dispatchHostHandler(hostHandler, args, k, signal, sourceCodeInfo)\n }\n\n // No host handler — check standard effects (dvala.log, dvala.now, etc.).\n const standardHandler = getStandardEffectHandler(effect.name)\n if (standardHandler) {\n return standardHandler(args, k, sourceCodeInfo)\n }\n\n // No handler at all — unhandled effect.\n throw new DvalaError(`Unhandled effect: '${effect.name}'`, sourceCodeInfo)\n}\n\n/**\n * Dispatch an effect to a host-provided JavaScript handler.\n *\n * Creates an `EffectContext` with `resume` and `suspend` callbacks, then\n * calls the handler and returns a `Promise<Step>` that resolves when the\n * handler calls one of those callbacks:\n *\n * - `resume(value)` — resolves with a `ValueStep` that continues evaluation\n * at the `perform` call site with the provided value and the original `k`.\n * If `value` is a `Promise`, it's awaited first.\n * - `suspend(meta?)` — rejects with a `SuspensionSignal` carrying the\n * continuation `k` and optional metadata. The effect trampoline loop\n * catches this and returns `RunResult.suspended`.\n *\n * Host handler errors are treated as Dvala-level errors — they're fed to\n * `unwindToTryCatch` so that Dvala `try/catch` blocks can intercept them.\n */\nfunction dispatchHostHandler(\n handler: EffectHandler,\n args: Arr,\n k: ContinuationStack,\n signal: AbortSignal | undefined,\n sourceCodeInfo: SourceCodeInfo | undefined,\n): Promise<Step> {\n const effectSignal = signal ?? new AbortController().signal\n\n return new Promise<Step>((resolve, reject) => {\n let settled = false\n\n const ctx = {\n args: Array.from(args) as Any[],\n signal: effectSignal,\n resume: (value: Any | Promise<Any>) => {\n if (settled) {\n throw new DvalaError('Effect handler called resume() more than once or after suspend()', sourceCodeInfo)\n }\n settled = true\n\n if (value instanceof Promise) {\n value.then(\n (v) => {\n resolve({ type: 'Value', value: v, k })\n },\n (e) => {\n // The promise-value rejected — treat as a Dvala-level error\n // so try/catch in the Dvala program can handle it.\n try {\n resolve(unwindToTryCatch(e instanceof Error ? new DvalaError(e, sourceCodeInfo) : new DvalaError(`${e}`, sourceCodeInfo), k))\n }\n catch (unwoundError) {\n reject(unwoundError)\n }\n },\n )\n }\n else {\n resolve({ type: 'Value', value, k })\n }\n },\n suspend: (meta?: Any) => {\n if (settled) {\n throw new DvalaError('Effect handler called suspend() more than once or after resume()', sourceCodeInfo)\n }\n settled = true\n reject(new SuspensionSignal(k, meta))\n },\n }\n\n handler(ctx).catch((e) => {\n if (settled) {\n // Handler already resolved via resume/suspend — ignore late errors\n return\n }\n settled = true\n if (isSuspensionSignal(e)) {\n reject(e)\n }\n else {\n // Handler itself threw — treat as a Dvala-level error.\n try {\n resolve(unwindToTryCatch(e instanceof Error ? new DvalaError(e, sourceCodeInfo) : new DvalaError(`${e}`, sourceCodeInfo), k))\n }\n catch (unwoundError) {\n reject(unwoundError)\n }\n }\n })\n })\n}\n\n// ---------------------------------------------------------------------------\n// Parallel & Race — concurrent branch execution\n// ---------------------------------------------------------------------------\n\n/**\n * Throw a SuspensionSignal. Factored out to a helper so ESLint's\n * `only-throw-literal` rule can be suppressed in one place.\n */\nfunction throwSuspension(k: ContinuationStack, meta?: Any): never {\n // eslint-disable-next-line ts/no-throw-literal -- SuspensionSignal is a signaling mechanism, not an error\n throw new SuspensionSignal(k, meta)\n}\n\n/**\n * Run a single trampoline branch to completion with effect handler support.\n *\n * This is the core building block for `parallel` and `race`. Each branch\n * runs as an independent trampoline invocation through `runEffectLoop`,\n * producing a `RunResult` that is either `completed`, `suspended`, or `error`.\n *\n * The branch receives the same `handlers` and the given `signal`, allowing\n * the caller to cancel branches via AbortController.\n */\nasync function runBranch(\n node: AstNode,\n env: ContextStack,\n handlers: Handlers | undefined,\n signal: AbortSignal,\n): Promise<RunResult> {\n const initial: Step = { type: 'Eval', node, env, k: [] }\n return runEffectLoop(initial, handlers, signal)\n}\n\n/**\n * Execute a `parallel(...)` expression.\n *\n * Runs all branch expressions concurrently as independent trampoline\n * invocations using `Promise.allSettled`. Results are collected in order.\n *\n * Outcome:\n * - All branches complete → return `ValueStep` with array of results\n * - Any branch suspends → throw `SuspensionSignal` with a `ParallelResumeFrame`\n * on the outer continuation. The host can resume branches one at a time.\n * - Any branch errors → throw the first error (other branches still complete\n * but errors take priority)\n */\nasync function executeParallelBranches(\n branches: AstNode[],\n env: ContextStack,\n k: ContinuationStack,\n handlers: Handlers | undefined,\n signal: AbortSignal | undefined,\n): Promise<Step> {\n const effectSignal = signal ?? new AbortController().signal\n\n // Run all branches concurrently\n const branchPromises = branches.map(branch =>\n runBranch(branch, env, handlers, effectSignal),\n )\n const results = await Promise.allSettled(branchPromises)\n\n // Collect outcomes\n const completedBranches: Array<{ index: number, value: Any }> = []\n const suspendedBranches: Array<{ index: number, blob: string, meta?: Any }> = []\n const errors: DvalaError[] = []\n\n for (let i = 0; i < results.length; i++) {\n const result = results[i]!\n if (result.status === 'rejected') {\n // runEffectLoop should never reject, but handle defensively\n errors.push(new DvalaError(`${result.reason}`, undefined))\n }\n else {\n const r = result.value\n switch (r.type) {\n case 'completed':\n completedBranches.push({ index: i, value: r.value })\n break\n case 'suspended':\n suspendedBranches.push({ index: i, blob: r.blob, meta: r.meta })\n break\n case 'error':\n errors.push(r.error)\n break\n }\n }\n }\n\n // If any branch errored, throw the first error\n if (errors.length > 0) {\n throw errors[0]!\n }\n\n // If any branch suspended, build a composite suspension\n if (suspendedBranches.length > 0) {\n // Build a ParallelResumeFrame on the outer continuation\n const parallelResumeFrame: ParallelResumeFrame = {\n type: 'ParallelResume',\n branchCount: branches.length,\n completedBranches,\n suspendedBranches: suspendedBranches.slice(1), // remaining after the first\n }\n const resumeK: ContinuationStack = [parallelResumeFrame, ...k]\n\n // Throw SuspensionSignal with the first suspended branch's meta\n const firstSuspended = suspendedBranches[0]!\n return throwSuspension(resumeK, firstSuspended.meta)\n }\n\n // All branches completed — build the result array in original order\n const resultArray: Any[] = Array.from({ length: branches.length })\n for (const { index, value } of completedBranches) {\n resultArray[index] = value\n }\n return { type: 'Value', value: resultArray, k }\n}\n\n/**\n * Execute a `race(...)` expression.\n *\n * Runs all branch expressions concurrently. The first branch to complete\n * wins — its value becomes the result. Losing branches are cancelled via\n * per-branch AbortControllers.\n *\n * Branch outcome priority: completed > suspended > errored.\n * - First completed branch wins immediately.\n * - Errored branches are silently dropped.\n * - If no branch completes but some suspend, the race suspends with only\n * the outer continuation. The host provides the winner value directly.\n * - If all branches error, throw an aggregate error.\n */\nasync function executeRaceBranches(\n branches: AstNode[],\n env: ContextStack,\n k: ContinuationStack,\n handlers: Handlers | undefined,\n signal: AbortSignal | undefined,\n): Promise<Step> {\n const parentSignal = signal ?? new AbortController().signal\n\n // Each branch gets its own AbortController so losers can be cancelled\n const branchControllers = branches.map(() => new AbortController())\n\n // Link: if parent signal aborts, abort all branches\n const onParentAbort = () => {\n for (const ctrl of branchControllers) {\n ctrl.abort(parentSignal.reason)\n }\n }\n parentSignal.addEventListener('abort', onParentAbort, { once: true })\n\n try {\n // Track the first branch to complete (temporal order, not positional)\n let winnerIndex = -1\n let winnerValue: Any = null\n\n // Run all branches concurrently, tracking completion order\n const branchPromises = branches.map(async (branch, i) => {\n const branchSignal = branchControllers[i]!.signal\n const result = await runBranch(branch, env, handlers, branchSignal)\n\n // First branch to complete wins (JavaScript is single-threaded,\n // so the first resolved promise's continuation runs first)\n if (result.type === 'completed' && winnerIndex < 0) {\n winnerIndex = i\n winnerValue = result.value\n // Cancel all other branches\n for (let j = 0; j < branchControllers.length; j++) {\n if (j !== i) {\n branchControllers[j]!.abort('race: branch lost')\n }\n }\n }\n return result\n })\n\n // Wait for all branches to settle (even cancelled ones)\n const results = await Promise.allSettled(branchPromises)\n\n // If we have a winner, return it\n if (winnerIndex >= 0) {\n return { type: 'Value', value: winnerValue, k }\n }\n\n // No completed branch — collect suspended and errored\n const suspendedMetas: Any[] = []\n const errors: DvalaError[] = []\n\n for (let i = 0; i < results.length; i++) {\n const result = results[i]!\n if (result.status === 'rejected') {\n errors.push(new DvalaError(`${result.reason}`, undefined))\n }\n else {\n const r = result.value\n switch (r.type) {\n case 'suspended':\n suspendedMetas.push(r.meta ?? null)\n break\n case 'error':\n errors.push(r.error)\n break\n /* v8 ignore next 3 */\n case 'completed':\n // Already handled via winnerIndex above\n break\n }\n }\n }\n\n // If some branches suspended, the race suspends\n if (suspendedMetas.length > 0) {\n // Race suspension: only outer k, host provides winner value directly\n // Meta contains all branch metas so host knows who is waiting\n const raceMeta: Any = { type: 'race', branches: suspendedMetas }\n throwSuspension(k, raceMeta)\n }\n\n // All branches errored — throw aggregate error\n const messages = errors.map(e => e.message).join('; ')\n throw new DvalaError(`race: all branches failed: ${messages}`, undefined)\n }\n finally {\n parentSignal.removeEventListener('abort', onParentAbort)\n }\n}\n\n/**\n * Handle a `ParallelResume` step — resume the first suspended branch.\n *\n * Called from `tick()` when a `ParallelResumeFrame` produces a\n * `ParallelResumeStep`. The value is the host's resume value for the\n * first pending suspended branch.\n *\n * Logic:\n * 1. The `completedBranches` already has the branches that completed before.\n * 2. The `value` is for the branch that was exposed to the host (the one\n * whose meta was in the SuspensionSignal). We DON'T re-run any blob —\n * the host has already decided the value.\n * 3. If more branches are suspended, throw another SuspensionSignal.\n * 4. If all branches are now done, build the result array.\n */\nfunction handleParallelResume(\n step: Step & { type: 'ParallelResume' },\n _handlers: Handlers | undefined,\n _signal: AbortSignal | undefined,\n): Step {\n const { value, branchCount, completedBranches, suspendedBranches, k } = step\n\n // The first suspended branch (whose meta was exposed) is now completed\n // We need to know its index — it was removed from suspendedBranches\n // and its index can be derived from what's missing.\n // Actually, looking at how we build this: the first suspended branch\n // was kept OUT of suspendedBranches (slice(1)), and its meta was used\n // in the SuspensionSignal. But we need its index!\n //\n // Let me reconsider: we need to track which branch index the host resume\n // value is for. The index is determined by what's NOT in completedBranches\n // or suspendedBranches.\n //\n // Better approach: store the current branch index explicitly.\n // Since we're in the middle of implementing, let me find the missing index.\n const completedIndices = new Set(completedBranches.map(b => b.index))\n const suspendedIndices = new Set(suspendedBranches.map(b => b.index))\n let currentBranchIndex = -1\n for (let i = 0; i < branchCount; i++) {\n if (!completedIndices.has(i) && !suspendedIndices.has(i)) {\n currentBranchIndex = i\n break\n }\n }\n\n // Add the just-resumed branch to completed\n const updatedCompleted = [...completedBranches, { index: currentBranchIndex, value }]\n\n // If more branches are suspended, suspend again with next one's meta\n if (suspendedBranches.length > 0) {\n const nextSuspended = suspendedBranches[0]!\n const remaining = suspendedBranches.slice(1)\n\n const parallelResumeFrame: ParallelResumeFrame = {\n type: 'ParallelResume',\n branchCount,\n completedBranches: updatedCompleted,\n suspendedBranches: remaining,\n }\n const resumeK: ContinuationStack = [parallelResumeFrame, ...k]\n return throwSuspension(resumeK, nextSuspended.meta)\n }\n\n // All branches now completed — build the result array in original order\n const resultArray: Any[] = Array.from({ length: branchCount })\n for (const { index, value: v } of updatedCompleted) {\n resultArray[index] = v\n }\n return { type: 'Value', value: resultArray, k }\n}\n\nfunction applyEvalArgs(frame: EvalArgsFrame, value: Any, k: ContinuationStack): Step | Promise<Step> {\n const { node, params, placeholders, env } = frame\n const argNodes = node[1][1]\n const currentArgNode = argNodes[frame.index]!\n\n // Process the completed value\n if (isSpreadNode(currentArgNode)) {\n if (!Array.isArray(value)) {\n throw new DvalaError(`Spread operator requires an array, got ${valueToString(value)}`, currentArgNode[2])\n }\n params.push(...value)\n }\n else {\n params.push(value)\n }\n\n // Find the next real argument (skip placeholders)\n let nextIndex = frame.index + 1\n while (nextIndex < argNodes.length) {\n const nextArg = argNodes[nextIndex]!\n if (nextArg[0] === NodeTypes.ReservedSymbol && nextArg[1] === '_') {\n placeholders.push(params.length)\n nextIndex++\n }\n else {\n break\n }\n }\n\n if (nextIndex >= argNodes.length) {\n // All args evaluated — dispatch the call\n return dispatchCall({ ...frame, index: nextIndex }, k)\n }\n\n // Evaluate next argument\n const newFrame: EvalArgsFrame = { ...frame, index: nextIndex }\n const nextArg = argNodes[nextIndex]!\n if (isSpreadNode(nextArg)) {\n return { type: 'Eval', node: nextArg[1], env, k: [newFrame, ...k] }\n }\n return { type: 'Eval', node: nextArg, env, k: [newFrame, ...k] }\n}\n\nfunction applyCallFn(frame: CallFnFrame, value: Any, k: ContinuationStack): Step | Promise<Step> {\n // `value` is the resolved function value\n const fn = asFunctionLike(value, frame.sourceCodeInfo)\n return dispatchFunction(fn, frame.params, frame.placeholders, frame.env, frame.sourceCodeInfo, k)\n}\n\nfunction applyFnBody(frame: FnBodyFrame, value: Any, k: ContinuationStack): Step {\n const { fn, bodyIndex, env } = frame\n const bodyNodes = fn.evaluatedfunction[1]\n\n if (bodyIndex >= bodyNodes.length) {\n // All body nodes evaluated — return the result\n return { type: 'Value', value, k }\n }\n\n // More body nodes to evaluate.\n // The FnBodyFrame is always pushed — even for the last body node — because\n // `handleRecur` walks the continuation stack looking for it. When recur fires\n // inside the last expression, handleRecur finds this frame, slices the stack\n // at that point, and calls setupUserDefinedCall with the remaining stack.\n // This replaces the old FnBodyFrame rather than growing the stack — achieving\n // proper tail call elimination.\n const newFrame: FnBodyFrame = { ...frame, bodyIndex: bodyIndex + 1 }\n return { type: 'Eval', node: bodyNodes[bodyIndex]!, env, k: [newFrame, ...k] }\n}\n\nfunction applyBindingDefault(frame: BindingDefaultFrame, value: Any, k: ContinuationStack): Step {\n // Default value has been evaluated — continue binding processing\n // For Phase 1, this is handled by the recursive evaluateBindingNodeValues\n // This frame type will be fully utilized in later phases.\n const { target, record, env, sourceCodeInfo } = frame\n const valueRecord = evaluateBindingNodeValues(target, value, n => evaluateNodeRecursive(n, env))\n if (valueRecord instanceof Promise) {\n throw new DvalaError('Async binding default evaluation not supported in trampoline yet', sourceCodeInfo)\n }\n Object.assign(record, valueRecord)\n return { type: 'Value', value, k }\n}\n\nfunction applyNanCheck(frame: NanCheckFrame, value: Any, k: ContinuationStack): Step {\n if (typeof value === 'number' && Number.isNaN(value)) {\n throw new DvalaError('Number is NaN', frame.sourceCodeInfo)\n }\n return { type: 'Value', value: annotate(value), k }\n}\n\n// ---------------------------------------------------------------------------\n// Debug step handling\n// ---------------------------------------------------------------------------\n\n/**\n * Extract all visible bindings from a ContextStack as a flat record.\n * Iterates from outermost to innermost scope so that inner bindings\n * shadow outer ones, matching Dvala scoping semantics.\n */\nexport function extractBindings(env: ContextStack): Record<string, Any> {\n const result: Record<string, Any> = {}\n // Include host values (plain bindings passed at creation)\n const hostValues = env.getHostValues()\n if (hostValues) {\n for (const [name, value] of Object.entries(hostValues)) {\n result[name] = value as Any\n }\n }\n const contexts = env.getContextsRaw()\n // Outer scopes first, inner override\n for (let i = contexts.length - 1; i >= 0; i--) {\n for (const [name, entry] of Object.entries(contexts[i]!)) {\n result[name] = entry.value\n }\n }\n return result\n}\n\n/**\n * Apply a DebugStepFrame.\n *\n * Phase 'awaitValue': The compound expression just evaluated to `value`.\n * Build step info and produce a PerformStep for `dvala.debug.step`.\n * Push self (in 'awaitPerform' phase) onto k so that when the debug\n * perform completes, the value flows through correctly.\n *\n * Phase 'awaitPerform': The debug perform completed (handler resumed or\n * suspension was resumed). Pass the value through to the next frame.\n * For normal stepping, the debugger resumes with the original value.\n * For `rerunFrom`, the debugger resumes with an alternate value.\n */\nfunction applyDebugStep(frame: DebugStepFrame, value: Any, k: ContinuationStack): Step {\n if (frame.phase === 'awaitValue') {\n // Build step info from source code info and evaluation result\n const stepInfo: Obj = {\n expression: frame.sourceCodeInfo?.code ?? '',\n value,\n location: frame.sourceCodeInfo\n ? { line: frame.sourceCodeInfo.position.line, column: frame.sourceCodeInfo.position.column }\n : { line: 0, column: 0 },\n env: extractBindings(frame.env),\n }\n\n // Push awaitPerform phase frame, then produce PerformStep\n const awaitFrame: DebugStepFrame = {\n type: 'DebugStep',\n phase: 'awaitPerform',\n sourceCodeInfo: frame.sourceCodeInfo,\n env: frame.env,\n }\n const debugEffect = getEffectRef('dvala.debug.step')\n return { type: 'Perform', effect: debugEffect, args: [stepInfo as Any], k: [awaitFrame, ...k] }\n }\n\n // phase === 'awaitPerform': pass through the value\n return { type: 'Value', value, k }\n}\n\n// ---------------------------------------------------------------------------\n// Utility functions\n// ---------------------------------------------------------------------------\n\n/**\n * Wrap a MaybePromise<Any> result into a Step or Promise<Step>.\n * If the result is a value, return a ValueStep immediately.\n * If it's a Promise, return a Promise<Step> that resolves to a ValueStep.\n * The trampoline loop handles the async case: runSyncTrampoline throws,\n * runAsyncTrampoline awaits.\n */\nfunction wrapMaybePromiseAsStep(result: MaybePromise<Any>, k: ContinuationStack): Step | Promise<Step> {\n if (result instanceof Promise) {\n return result.then(\n value => ({ type: 'Value' as const, value, k }),\n error => unwindToTryCatch(error, k),\n )\n }\n return { type: 'Value', value: result, k }\n}\n\n/** Lazy-load collection utilities to avoid circular imports. */\nfunction getCollectionUtils(): { asColl: (v: Any, s?: SourceCodeInfo) => Any, isSeq: (v: Any) => boolean } {\n return {\n asColl: (v: Any, s?: SourceCodeInfo) => {\n if (typeof v === 'string' || Array.isArray(v) || isObj(v)) {\n return v\n }\n throw new DvalaError(`Expected collection, got ${valueToString(v)}`, s)\n },\n isSeq: (v: Any) => typeof v === 'string' || Array.isArray(v),\n }\n}\n\n// ---------------------------------------------------------------------------\n// Trampoline loop — tick, runSyncTrampoline, runAsyncTrampoline\n// ---------------------------------------------------------------------------\n\n/**\n * Process one step of the trampoline. Returns the next step, or a\n * Promise<Step> when an async operation (e.g., native JS function) is\n * encountered.\n *\n * - `Value` with empty `k`: the program is done (terminal state).\n * - `Value` with non-empty `k`: pop the top frame and apply it.\n * - `Eval`: evaluate an AST node via `stepNode` (always synchronous).\n * - `Apply`: apply a frame to a value (may return Promise<Step>).\n * - `Perform`: effect dispatch — local (try/with) first, then host handlers.\n *\n * When `handlers` and `signal` are provided (from `run()`), host handlers are\n * available as a fallback for effects not matched by any local `try/with`.\n */\nexport function tick(step: Step, handlers?: Handlers, signal?: AbortSignal): Step | Promise<Step> {\n try {\n switch (step.type) {\n case 'Value': {\n if (step.k.length === 0) {\n return step // Terminal state — program is complete\n }\n const [frame, ...rest] = step.k\n return applyFrame(frame!, step.value, rest)\n }\n case 'Eval':\n return stepNode(step.node, step.env, step.k)\n case 'Apply':\n return applyFrame(step.frame, step.value, step.k)\n case 'Perform':\n return dispatchPerform(step.effect, step.args, step.k, undefined, handlers, signal)\n case 'Parallel':\n return executeParallelBranches(step.branches, step.env, step.k, handlers, signal)\n case 'Race':\n return executeRaceBranches(step.branches, step.env, step.k, handlers, signal)\n case 'ParallelResume':\n return handleParallelResume(step, handlers, signal)\n }\n }\n catch (error) {\n // SuspensionSignal must propagate out of tick to the effect trampoline loop\n // (runEffectLoop). Never let unwindToTryCatch intercept it.\n if (isSuspensionSignal(error)) {\n // eslint-disable-next-line ts/no-throw-literal -- SuspensionSignal is a signaling mechanism, not an error\n throw error\n }\n // Search the continuation stack for a TryCatchFrame to handle the error.\n // This handles both explicit throw() and runtime errors (e.g., type errors).\n return unwindToTryCatch(error, step.k)\n }\n}\n\n/**\n * Run the trampoline synchronously to completion.\n * Throws if any step produces a Promise (i.e., an async operation was\n * encountered in a synchronous context).\n */\nexport function runSyncTrampoline(initial: Step): Any {\n let step: Step | Promise<Step> = initial\n for (;;) {\n if (step instanceof Promise) {\n throw new DvalaError('Unexpected async operation in synchronous context. Use async.run() for async operations.', undefined)\n }\n if (step.type === 'Value' && step.k.length === 0) {\n return step.value\n }\n step = tick(step)\n }\n}\n\n/**\n * Run the trampoline asynchronously to completion.\n * Awaits any Promise<Step> that surfaces from async operations.\n */\nexport async function runAsyncTrampoline(initial: Step): Promise<Any> {\n let step: Step | Promise<Step> = initial\n for (;;) {\n if (step instanceof Promise) {\n step = await step\n }\n if (step.type === 'Value' && step.k.length === 0) {\n return step.value\n }\n step = tick(step)\n }\n}\n\n// ---------------------------------------------------------------------------\n// Public entry points — evaluate an AST or a single node\n// ---------------------------------------------------------------------------\n\n/**\n * Build the initial Step for evaluating an AST (sequence of top-level nodes).\n */\nfunction buildInitialStep(nodes: AstNode[], env: ContextStack): Step {\n if (nodes.length === 0) {\n return { type: 'Value', value: null, k: [] }\n }\n if (nodes.length === 1) {\n return { type: 'Eval', node: nodes[0]!, env, k: [] }\n }\n const sequenceFrame: SequenceFrame = {\n type: 'Sequence',\n nodes,\n index: 1,\n env,\n }\n return { type: 'Eval', node: nodes[0]!, env, k: [sequenceFrame] }\n}\n\n/**\n * Evaluate an AST using the trampoline.\n * Returns the final value synchronously, or a Promise if async operations\n * are involved (e.g., native JS functions returning Promises).\n */\nexport function evaluate(ast: Ast, contextStack: ContextStack): MaybePromise<Any> {\n const initial = buildInitialStep(ast.body, contextStack)\n // Try synchronous first; if a Promise surfaces, switch to async\n try {\n return runSyncTrampoline(initial)\n }\n catch (error) {\n if (error instanceof DvalaError && error.message.includes('Unexpected async operation')) {\n // An async operation was encountered — re-run with the async trampoline.\n // We must rebuild the initial step since the sync attempt may have\n // partially mutated frames.\n const freshInitial = buildInitialStep(ast.body, contextStack)\n return runAsyncTrampoline(freshInitial)\n }\n throw error\n }\n}\n\n/**\n * Evaluate an AST using the async trampoline directly.\n * Use this when the caller knows that async operations may be involved\n * (e.g., from Dvala.async.run) to avoid the sync-first-then-retry pattern\n * which can cause side effects to be executed twice.\n */\nexport function evaluateAsync(ast: Ast, contextStack: ContextStack): Promise<Any> {\n const initial = buildInitialStep(ast.body, contextStack)\n return runAsyncTrampoline(initial)\n}\n\n/**\n * Evaluate a single AST node using the trampoline.\n * Used as the `evaluateNode` callback passed to `getUndefinedSymbols`\n * and other utilities.\n */\nexport function evaluateNode(node: AstNode, contextStack: ContextStack): MaybePromise<Any> {\n const initial: Step = { type: 'Eval', node, env: contextStack, k: [] }\n try {\n return runSyncTrampoline(initial)\n }\n catch (error) {\n if (error instanceof DvalaError && error.message.includes('Unexpected async operation')) {\n const freshInitial: Step = { type: 'Eval', node, env: contextStack, k: [] }\n return runAsyncTrampoline(freshInitial)\n }\n throw error\n }\n}\n\n// ---------------------------------------------------------------------------\n// Effect trampoline — async loop with host handler support\n// ---------------------------------------------------------------------------\n\n/**\n * Evaluate an AST with full effect handler support.\n *\n * Uses the async trampoline loop, passing `handlers` and `signal` to `tick`\n * so that `dispatchPerform` can fall back to host handlers when no local\n * `try/with` matches.\n *\n * Always resolves — never rejects. All errors are captured in\n * `RunResult.error`. Suspension is signaled via `RunResult.suspended`.\n *\n * The `AbortController` is created internally per `run()` call. The signal\n * is passed to every host handler. Used for `race()` cancellation (Phase 6)\n * and host-side timeouts.\n */\nexport async function evaluateWithEffects(\n ast: Ast,\n contextStack: ContextStack,\n handlers?: Handlers,\n): Promise<RunResult> {\n const abortController = new AbortController()\n const signal = abortController.signal\n const initial = buildInitialStep(ast.body, contextStack)\n\n return runEffectLoop(initial, handlers, signal)\n}\n\n/**\n * Resume a suspended continuation with a value.\n *\n * Re-enters the trampoline with `{ type: 'Value', value, k }` where `k` is\n * the deserialized continuation stack. Host handlers and signal are provided\n * fresh for this run.\n */\nexport async function resumeWithEffects(\n k: ContinuationStack,\n value: Any,\n handlers?: Handlers,\n): Promise<RunResult> {\n const abortController = new AbortController()\n const signal = abortController.signal\n const initial: Step = { type: 'Value', value, k }\n\n return runEffectLoop(initial, handlers, signal)\n}\n\n/**\n * Shared effect trampoline loop used by both `evaluateWithEffects` and\n * `resumeWithEffects`. Runs the trampoline to completion, suspension, or error.\n *\n * When `handlers` includes a `dvala.debug.step` handler, the loop enters\n * debug mode: before evaluating compound nodes (NormalExpression,\n * SpecialExpression) that have source code info, a `DebugStepFrame` is\n * pushed onto the continuation stack. This causes each compound expression\n * to fire a `perform(dvala.debug.step, stepInfo)` after evaluation,\n * enabling the time-travel debugger.\n */\nasync function runEffectLoop(\n initial: Step,\n handlers: Handlers | undefined,\n signal: AbortSignal,\n): Promise<RunResult> {\n const debugMode = handlers != null && 'dvala.debug.step' in handlers\n\n try {\n let step: Step | Promise<Step> = initial\n for (;;) {\n if (step instanceof Promise) {\n step = await step\n }\n if (step.type === 'Value' && step.k.length === 0) {\n return { type: 'completed', value: step.value }\n }\n\n // Debug mode: inject DebugStepFrame for compound nodes with source info\n if (debugMode && step.type === 'Eval' && step.node[2]) {\n const nodeType = step.node[0]\n if (nodeType === NodeTypes.NormalExpression || nodeType === NodeTypes.SpecialExpression) {\n const debugFrame: DebugStepFrame = {\n type: 'DebugStep',\n phase: 'awaitValue',\n sourceCodeInfo: step.node[2],\n env: step.env,\n }\n step = { ...step, k: [debugFrame, ...step.k] }\n }\n }\n\n step = tick(step, handlers, signal)\n }\n }\n catch (error) {\n if (isSuspensionSignal(error)) {\n const blob = serializeSuspension(error.k, error.meta)\n return { type: 'suspended', blob, meta: error.meta }\n }\n if (error instanceof DvalaError) {\n return { type: 'error', error }\n }\n return { type: 'error', error: new DvalaError(`${error}`, undefined) }\n }\n}\n"],"names":["getCodeMarker","sourceCodeInfo","position","code","leftPadding","column","rightPadding","length","repeat","Math","max","RecurSignal","Error","params","constructor","super","Object","setPrototypeOf","this","prototype","name","DvalaError","shortMessage","err","message","location","line","filePath","getDvalaErrorMessage","UserDefinedError","userMessage","AssertionError","UndefinedSymbolError","symbol","symbolName","NodeTypes","Number","String","NormalExpression","SpecialExpression","UserDefinedSymbol","NormalBuiltinSymbol","SpecialBuiltinSymbol","ReservedSymbol","Binding","Spread","NodeTypesSet","Set","values","getNodeTypeName","type","keys","find","key","functionTypeSet","FUNCTION_SYMBOL","REGEXP_SYMBOL","EFFECT_SYMBOL","isDvalaFunction","func","has","isFunctionType","functionType","isNode","value","Array","isArray","isNodeType","valueToString","RegExp","toString","JSON","stringify","getSourceCodeInfo","anyValue","getAssertionError","typeName","asNonUndefined","assertNonUndefined","undefined","isNonUndefined","isUnknownRecord","assertDvalaFunction","isUserDefinedFunction","assertUserDefinedFunction","isNativeJsFunction","assertNativeJsFunction","isAny","asAny","assertAny","isSeq","assertSeq","isObj","isRegularExpression","isEffectRef","assertObj","isColl","assertColl","regexp","assertStringOrRegularExpression","isStringOrRegularExpression","asFunctionLike","assertFunctionLike","isFunctionLike","isString","options","nonEmpty","char","assertString","asString","isStringOrNumber","asStringOrNumber","assertStringOrNumber","assertionNormalExpression","assert","evaluate","arity","min","isNumber","isNaN","integer","isInteger","isFinite","zero","nonZero","positive","negative","nonPositive","nonNegative","gt","gte","lt","lte","assertNumber","sign","getSignString","numberType","finite","range","filter","join","getNumberTypeName","arityAcceptsMin","assertNumberOfParams","toFixedArity","bitwiseNormalExpression","num","count","first","rest","reduce","result","collHasKey","coll","getOwnPropertyDescriptor","compare","a","b","deepEqual","epsilon","EPSILON","diff","abs","absA","absB","approxEqual","i","s","f","aKeys","bKeys","toAny","joinSets","results","forEach","add","addToSet","target","source","smartTrim","minIndent","lines","str","match","shift","acc","lineIndent","map","slice","indent","trimEnd","assertStringArray","every","v","isStringArray","assertCharArray","isCharArray","chain","fn","Promise","then","mapSequential","arr","chainRemainingMap","async","currentPromise","startIndex","push","initial","next","chainRemainingReduce","chainRemainingForEach","findIndexSequential","chainRemainingFindIndex","collectionNormalExpression","contextStack","executeFunction","elem","keep","reduceSequential","split","filtered","entries","at","colls","obj","objKeys","includes","mapObjects","seqs","isStr","len","seq","assertArray","paramArray","mapped","resolvedMapped","defaultValue","get","assoc","copy","arrayNormalExpression","second","third","step","from","to","depth","actualDepth","POSITIVE_INFINITY","asNumber","flat","mapcat","windowSize","windows","window","subArrays","subArr","array","last","index","indexOf","findIndex","item","substring","reverse","some","found","sort","_contextStack","_executeFunction","comparer","defaultComparer","compareValue","TypeError","input","n","ceil","drop","taken","annotatedArrays","WeakSet","vectors","notVectors","matrices","grids","notGrids","annotate","isVector","isMatrix","vector","assertVector","grid","nbrOfCols","row","matrix","notMatrices","cell","getNumberVectorOrMatrixOperation","hasVector","hasMatrix","param","rows","cold","operands","operation","val","binaryMathOp","j","identity","m","mathNormalExpression","inc","unaryMathOp","dec","reduceMathOp","firstVector","firstMatrix","quot","trunc","floor","sqrt","cbrt","round","decimals","factor","assertNonEmptyVector","Infinity","firstAny","miscNormalExpression","isEqual","isIdentical","currentValue","ms","toISOString","dateTime","Date","valueOf","console","pure","boolean","parse","objectNormalExpression","dissoc","newObj","merge","res","entry","merged","r","zipmap","NEGATIVE_INFINITY","table","isGrid","sourceArg","flagsArg","flags","e","text","assertRegularExpression","exec","replace","matcher","blankRegexp","stringNormalExpression","number","toLowerCase","toUpperCase","trim","stringList","delimiter","stringOrRegExpValue","limit","test","functionalNormalExpression","apply","comp","constantly","generateDocString","reference","title","description","variants","args","returns","_isOperator","functionForms","variant","argumentNames","argName","operatorForm","signature","arg","argStrings","example","typeString","argType","prod","mean","median","sorted","mid","expressions","normalExpressionReference","doc","docString","getMetaNormalExpression","predicatesNormalExpression","regexpNormalExpression","expression","allNormalExpressions","normalExpressions","normalExpressionTypes","andSpecialExpression","evaluateAsNormalExpression","node","getUndefinedSymbols","builtin","evaluateNode","bindingTargetTypes","walkDefaults","bindingTarget","onDefault","element","record","createRecord","forEachSequential","restElement","existingVal","resolvedVal","restValues","capturedKeys","restIndex","elements","getAllBindingTargetNames","names","getNamesFromBindingTarget","tryMatch","tryMatchRecord","matched","literalNode","literalValue","defaultNode","symbolNode","arrayTarget","el","matchSpecialExpression","body","newContext","pattern","caseContextStack","create","guard","lambdaSpecialExpression","self","assign","overloadResult","newContextStack","getFunctionUnresolvedSymbols","letSpecialExpression","bindingNode","bindingResult","addValues","loopSpecialExpression","bindingNodes","context","loopNode","loopBindings","loopBindingNode","letBindings","whenNode","whileNode","letBindingNode","letTarget","letValue","forSpecialExpression","analyze","doseqSpecialExpression","orSpecialExpression","qqSpecialExpression","recurSpecialExpression","throwSpecialExpression","trySpecialExpression","tryExpression","errorSymbol","catchExpression","withHandlers","tryResult","catchResult","withResult","effectExpr","handlerFn","effectSpecialExpression","importSpecialExpression","parallelSpecialExpression","branch","performSpecialExpression","argExprs","raceSpecialExpression","cond","for","if","let","loop","object","recur","throw","unless","perform","parallel","race","specialExpressions","arraySpecialExpression","objectSpecialExpression","normalExpressionKeys","specialExpressionKeys","specialExpressionTypes","asUserDefinedSymbolNode","assertUserDefinedSymbolNode","isSpecialBuiltinSymbolNode","nodeType","isSpreadNode","ast","block","unresolvedSymbols","subNode","nodes","findUnresolvedSymbolsInNode","lookUp","normalExpressionNode","isNormalExpressionNodeWithName","isUserDefinedSymbolNode","expressionNode","specialExpressionNode","specialExpressionType","castedGetUndefinedSymbols","phi","numberReservedSymbolRecord","E","PI","PHI","MAX_SAFE_INTEGER","MIN_SAFE_INTEGER","MAX_VALUE","MIN_VALUE","NaN","reservedSymbolRecord","true","false","null","when","while","catch","function","as","end","with","_","SuspensionSignal","k","meta","isSuspensionSignal","Map","getEffectRef","ref","internMap","set","ContextStackImpl","_contexts","globalContext","nativeJsFunctions","modules","valueModules","hostValues","contexts","getContextsRaw","getHostValues","cs","globalContextIndex","getModule","getValueModule","registerValueModule","currentContext","shadowedName","getShadowedBuiltinName","getValue","contextEntry","nativeJsFunction","hostValue","evaluateSymbol","specialExpression","specialBuiltinSymbolType","isNormalBuiltinSymbolNode","normalExpression","lookUpResult","createContextStack","identifier","bindings","jsFunction","assertNotShadowingBuiltin","nativeFn","globalModuleScope","describeSerializationIssue","path","partial","fnIssue","paramIssue","juxt","everyPred","somePred","fnull","issue","serializeSuspension","csMap","nextId","collectContextStacks","ctx","serializeValue","__csRef","id","ctxIdx","serialized","getGlobalContextIndex","serializedMeta","blobData","version","contextStacks","serializedContextStacks","serializedK","standardEffectHandlers","log","_args","now","random","resolve","setTimeout","evaluateReservedSymbol","paramNodes","paramNode","evaluateNodeRecursive","spreadValue","placeholders","evaluateParamsRecursive","nameSymbol","resolvedFn","executeFunctionRecursive","evaluateNormalExpressionRecursive","resolved","env","runAsyncTrampoline","error","evaluateArrayAsFunction","evaluateObjectAsFunction","evaluateNumberAsFunction","executeDvalaFunctionRecursive","executeUserDefinedRecursive","actualParams","placeholderIndex","splice","paramsCopy","fun","currentParams","finalArr","executeCompRecursive","checks","check","fnulledParams","executeFnullRecursive","normalBuiltinSymbolType","executeBuiltinRecursive","executeSpecialBuiltinRecursive","dvalaModule","moduleName","functions","functionName","executeModuleRecursive","executeNativeJsFunctionRecursive","setupAndExecute","evaluatedFunction","evaluatedfunction","nbrOfNonRestArgs","paramSetup","defaultSetup","paramIndex","evaluateBindingNodeValues","valueRecord","argIndex","restArgument","restSetup","bodyResult","evaluateStringAsFunction","reservedName","stepNode","argNodes","docs","evalArgsFrame","nanFrame","firstArg","newK","stepNormalExpression","conditionNode","thenNode","elseNode","inverted","frame","firstNode","nextNode","advanceQq","cases","phase","matchValueNode","matchValue","newEnv","bindingContext","doseq","returnResult","levelStates","try","withHandlerNodes","withFrame","handlerNode","effectRef","catchFrame","catchNode","handleRecur","singleFrame","isFirstSpread","isSpread","evaluatedFunc","functionContext","new","evaluateFunction","import","valueModule","effect","allNodes","branches","dispatchCall","builtinType","dispatchFunction","setupUserDefinedCall","wrapMaybePromiseAsStep","bodyEnv","bodyNodes","fnBodyFrame","bodyIndex","outerEnv","applyFrame","_value","newFrame","condition","nextIndex","applyCond","processMatchCase","applyMatch","applyAnd","applyOr","applyQq","isNextSpread","currentKey","valueNode","applyObjectBuild","br","applyLetBind","vr","loopEnv","applyLoopBind","_frame","applyLoopIterate","asColl","handleForAbort","bindingLevel","collection","binding","processForLetBindings","processForGuards","advanceForElement","processForNextLevel","applyForLoop","unwindToTryCatch","applyThrow","applyPerformArgs","applyTryWith","branchCount","completedBranches","suspendedBranches","currentArgNode","nextArg","applyCallFn","applyNanCheck","stepInfo","extractBindings","awaitFrame","currentLevel","currentState","nextElementIndex","letIndex","bindingIndex","bindingValue","nextLevel","remainingK","catchContext","rebindAll","innermostContext","dispatchPerform","handlers","signal","handler","resumeK","skipEnd","handlerK","hostHandler","AbortController","reject","settled","effectSignal","unwoundError","suspend","dispatchHostHandler","standardHandler","effectName","throwSuspension","runBranch","runEffectLoop","branchPromises","status","errors","reason","blob","branchControllers","onParentAbort","once","winnerIndex","winnerValue","branchSignal","allSettled","suspendedMetas","messages","parentSignal","removeEventListener","executeRaceBranches","completedIndices","suspendedIndices","currentBranchIndex","tick","buildInitialStep","runSyncTrampoline","debugMode","debugFrame","binaryOperators","symbolicOperators","nonFunctionOperatorSet","isFunctionOperator","operator","binaryOperatorSet","isBinaryOperator","symbolicOperatorSet","isSymbolicOperator","illegalFirstSymbolCharacters","illegalSymbolCharacters","illegalSymbolCharacterSet","illegalFirstSymbolCharacterSet","whitespaceRegExp","NO_MATCH","tokenizeString","escaping","tokenizeToken","decimalNumberRegExp","octalNumberRegExp","hexNumberRegExp","postNumberRegExp","initialPosition","endsWith","tokenizers","symbolMeta","tokenizeSymbol","startsWith","nextThreeChars","stringLength","token","baseChar","binaryNumberRegExp","nextChar","negate","plusPrefix","start","hasDecimalPoint","hasExponent","threeChars","twoChars","oneChar","tokenize","debug","tokenStream","tokens","createSourceCodeInfo","tokenDescriptor","getCurrentToken","lastLine","lineNbr","getSourceCodeLine","nbrOfCharacters","tokenizeShebang","tokenizer","isSymbolToken","assertSymbolToken","isReservedSymbolToken","throwUnexpectedToken","asReservedSymbolToken","assertReservedSymbolToken","isOperatorToken","operatorName","assertOperatorToken","isBasePrefixedNumberToken","isRParenToken","assertRParenToken","isLBracketToken","assertLBracketToken","isRBracketToken","isLBraceToken","assertLBraceToken","isA_BinaryOperatorToken","expected","expectedValue","actual","actualOutput","minifyTokenStream","removeWhiteSpace","isSingleLineCommentToken","isMultiLineCommentToken","isShebangToken","isWhitespaceToken","dvalaCommands","AutoCompleter","originalPosition","prefixProgram","suggestionIndex","originalProgram","partialProgram","lastToken","dvala","searchString","suffixProgram","generateSuggestions","getNextSuggestion","getAutoCompleteSuggestionResult","getNextSuggestionSymbol","getPreviousSuggestionSymbol","suggestion","program","suggestions","getSuggestions","getSearchString","startsWithCaseSensitive","generateWithPredicate","blacklist","startsWithCaseInsensitive","includesCaseSensitive","includesCaseInsensitive","shouldInclude","localeCompare","fileModules","withSourceCodeInfo","stringToSymbolNode","backslash","singleQuote","normalChar","specialExpressionNames","getSymbolName","createNamedNormalExpressionNode","isAtExpressionEnd","isAtEnd","tryPeek","fromBinaryOperatorToNode","left","right","ParserContext","storedPosition","parseExpression","advance","peekSourceCodeInfo","currentToken","storePosition","restorePosition","peekAhead","getPosition","getTokenAt","pos","operatorSign","parseImplicitBlock","ends","isImplicitBlockEnd","assertImplicitBlockEnd","parseString","doubleQuote","newline","tab","carriageReturn","backspace","formFeed","parseDo","allowDocString","peek","stringToken","stringNode","parseDocString","parseSymbol","stringFromQuotedSymbol","parseNumber","numberString","parseBindingTarget","requireDefaultValue","noRest","allowLiteralPatterns","firstToken","isStringToken","parseOptionalDefaulValue","isRBraceToken","keySymbol","keyName","isLiteralToken","parseLet","parseForLoopBinding","parseBinding","modifiers","assertInternalLoopBindingDelimiter","existingBoundNames","flatMap","letNode","symbols","isInternalLoopBindingDelimiter","symbolsString","parseReservedSymbol","isNumberReservedSymbol","placeholderRegexp","parseLambdaFunction","isLParenToken","functionArguments","assertLParenToken","defaults","parseFunctionArguments","parsedDo","nextToken","parseObject","asLBraceToken","assertRBracketToken","parseOperand","operand","lamdaFunction","endPos","dollar1","startPos","asLBracketToken","tokenType","endStringPosition","lastIndexOf","regexpString","optionsNode","optionsString","parseOperandPart","symbolToken","createAccessorNode","parseFunctionCall","thenExpression","elseExpression","isUnless","parseIfOrUnless","caseExpression","parseCond","valueExpression","isDoseq","loopBinding","forLoopBindings","newBoundNames","parseForOrDoseq","parseTry","newPrecedece","getPrecedence","precedence","newPrecedence","falseNode","trueNode","createParserContext","cache","firstEntry","lastEntry","_size","maxSize","getContent","size","newEntry","dropFirstEntry","buildAst","hasDebugData","astCache","astCacheSize","config","initialCache","cacheEntry","nsList","ns","getRuntimeInfo","run","programOrBundle","isDvalaBundle","generateAst","evaluateAsync","fnParams","runBundle","bundle","savedPure","programOrAst","tokenizeParams","minify","transformSymbols","transformer","tokenStram","transformSymbolTokens","untokenize","fnName","generateApplyFunctionCall","paramsString","cachedAst","getAutoCompleter","exports","asDvalaFunction","asNativeJsFunction","isBuiltinFunction","placeholderContexts","scs","fromDeserialized","resolveValue","isCSRef","serializedCtx","setContextsFromDeserialized","resolvedContexts","deserializeSuspension","runSync"],"mappings":"aAEM,SAAUA,EAAcC,GAC5B,IAAKA,EAAeC,WAAaD,EAAeE,KAC9C,MAAO,GAET,MAAMC,EAAcH,EAAeC,SAASG,OAAS,EAC/CC,EAAeL,EAAeE,KAAKI,OAASH,EAAc,EAChE,MAAO,GAAG,IAAII,OAAOC,KAAKC,IAAIN,EAAa,OAAO,IAAII,OAAOC,KAAKC,IAAIJ,EAAc,KACtF,CCQM,MAAOK,UAAoBC,MACxBC,OACP,WAAAC,CAAYD,GACVE,MAAM,kBAAkBF,KACxBG,OAAOC,eAAeC,KAAMP,EAAYQ,WACxCD,KAAKE,KAAO,cACZF,KAAKL,OAASA,CACf,EAGG,MAAOQ,UAAmBT,MACdX,eACAqB,aAChB,WAAAR,CAAYS,EAActB,GACxB,MAAMuB,EAAUD,aAAeX,MAC3BW,EAAIC,QACJ,GAAGD,IAEPR,MA/BJ,SAA8BS,EAAiBvB,GAC7C,IAAKA,EACH,OAAOuB,EAET,MAAMC,EAAW,GAAGxB,EAAeC,SAASwB,QAAQzB,EAAeC,SA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