From 84a0d83efb926d5f78f8bd75b5e45f2ada627130 Mon Sep 17 00:00:00 2001 From: Vyacheslav Matyukhin Date: Wed, 22 Jun 2022 00:34:35 +0300 Subject: [PATCH 01/12] store location on RESyntaxError; export parse() function --- packages/squiggle-lang/src/js/index.ts | 20 ++++++++++++++++++- .../rescript/Reducer/Reducer_ErrorValue.res | 7 +++++-- .../Reducer_Expression/Reducer_Expression.res | 2 +- .../Reducer_Peggy/Reducer_Peggy_Parse.res | 6 +++++- .../src/rescript/TypescriptInterface.res | 3 +++ 5 files changed, 33 insertions(+), 5 deletions(-) diff --git a/packages/squiggle-lang/src/js/index.ts b/packages/squiggle-lang/src/js/index.ts index 592de8e3..74ca1d1d 100644 --- a/packages/squiggle-lang/src/js/index.ts +++ b/packages/squiggle-lang/src/js/index.ts @@ -10,6 +10,7 @@ import { evaluatePartialUsingExternalBindings, evaluateUsingOptions, foreignFunctionInterface, + parse as parseRescript, } from "../rescript/TypescriptInterface.gen"; export { makeSampleSetDist, @@ -31,7 +32,7 @@ import { convertRawToTypescript, lambdaValue, } from "./rescript_interop"; -import { result, resultMap, tag, tagged } from "./types"; +import { Ok, result, resultMap, tag, tagged } from "./types"; import { Distribution, shape } from "./distribution"; export { Distribution, resultMap, defaultEnvironment }; @@ -58,6 +59,23 @@ export function run( return resultMap(res, (x) => createTsExport(x, e)); } +export function parse( + squiggleString: string +): result> { + const maybeExpression = parseRescript(squiggleString); + if (maybeExpression.tag === "Ok") { + return Ok(null); // TODO - return AST + } else { + if ( + typeof maybeExpression.value !== "object" || + maybeExpression.value.tag !== "RESyntaxError" + ) { + throw new Error("Expected syntax error"); + } + return { tag: "Error", value: maybeExpression.value }; + } +} + // Run Partial. A partial is a block of code that doesn't return a value export function runPartial( squiggleString: string, diff --git a/packages/squiggle-lang/src/rescript/Reducer/Reducer_ErrorValue.res b/packages/squiggle-lang/src/rescript/Reducer/Reducer_ErrorValue.res index 721fbc40..beaee7f7 100644 --- a/packages/squiggle-lang/src/rescript/Reducer/Reducer_ErrorValue.res +++ b/packages/squiggle-lang/src/rescript/Reducer/Reducer_ErrorValue.res @@ -1,3 +1,6 @@ +@gentype.import("peggy") @genType.as("LocationRange") +type location + @genType type errorValue = | REArityError(option, int, int) //TODO: Binding a lambda to a variable should record the variable name in lambda for error reporting @@ -14,7 +17,7 @@ type errorValue = | REOperationError(Operation.operationError) | RERecordPropertyNotFound(string, string) | RESymbolNotFound(string) - | RESyntaxError(string) + | RESyntaxError(string, option) | RETodo(string) // To do | REUnitNotFound(string) @@ -50,7 +53,7 @@ let errorToString = err => | RENotAFunction(valueString) => `${valueString} is not a function` | RERecordPropertyNotFound(msg, index) => `${msg}: ${index}` | RESymbolNotFound(symbolName) => `${symbolName} is not defined` - | RESyntaxError(desc) => `Syntax Error: ${desc}` + | RESyntaxError(desc, _) => `Syntax Error: ${desc}` | RETodo(msg) => `TODO: ${msg}` | REExpectedType(typeName) => `Expected type: ${typeName}` | REUnitNotFound(unitName) => `Unit not found: ${unitName}` diff --git a/packages/squiggle-lang/src/rescript/Reducer/Reducer_Expression/Reducer_Expression.res b/packages/squiggle-lang/src/rescript/Reducer/Reducer_Expression/Reducer_Expression.res index 6b4168c3..dabe3150 100644 --- a/packages/squiggle-lang/src/rescript/Reducer/Reducer_Expression/Reducer_Expression.res +++ b/packages/squiggle-lang/src/rescript/Reducer/Reducer_Expression/Reducer_Expression.res @@ -157,7 +157,7 @@ let evaluatePartialUsingExternalBindings = ( switch rAnswer { | Ok(EvRecord(externalBindings)) => Ok(externalBindings) | Ok(_) => - Error(Reducer_ErrorValue.RESyntaxError(`Partials must end with an assignment or record`)) + Error(Reducer_ErrorValue.RESyntaxError(`Partials must end with an assignment or record`, None)) | Error(err) => err->Error } } diff --git a/packages/squiggle-lang/src/rescript/Reducer/Reducer_Peggy/Reducer_Peggy_Parse.res b/packages/squiggle-lang/src/rescript/Reducer/Reducer_Peggy/Reducer_Peggy_Parse.res index 5bdcda14..1a37ccc0 100644 --- a/packages/squiggle-lang/src/rescript/Reducer/Reducer_Peggy/Reducer_Peggy_Parse.res +++ b/packages/squiggle-lang/src/rescript/Reducer/Reducer_Peggy/Reducer_Peggy_Parse.res @@ -5,11 +5,15 @@ type node = {"type": string} @module("./Reducer_Peggy_GeneratedParser.js") external parse__: string => node = "parse" +let syntaxErrorToLocation: Js.Exn.t => Reducer_ErrorValue.location = error => %raw(`error.location`) + +@genType let parse = (expr: string): result => try { Ok(parse__(expr)) } catch { - | Js.Exn.Error(obj) => REJavaScriptExn(Js.Exn.message(obj), Js.Exn.name(obj))->Error + | Js.Exn.Error(obj) => + RESyntaxError(Belt.Option.getExn(Js.Exn.message(obj)), syntaxErrorToLocation(obj)->Some)->Error } type nodeBlock = {...node, "statements": array} diff --git a/packages/squiggle-lang/src/rescript/TypescriptInterface.res b/packages/squiggle-lang/src/rescript/TypescriptInterface.res index 932edaa1..5bc913d8 100644 --- a/packages/squiggle-lang/src/rescript/TypescriptInterface.res +++ b/packages/squiggle-lang/src/rescript/TypescriptInterface.res @@ -40,6 +40,9 @@ let evaluate = Reducer.evaluate @genType let evaluateUsingOptions = Reducer.evaluateUsingOptions +@genType +let parse = Reducer_Peggy_Parse.parse + @genType let evaluatePartialUsingExternalBindings = Reducer.evaluatePartialUsingExternalBindings From 250d42707cf4f0d57757a8c2381d158dab5cdb26 Mon Sep 17 00:00:00 2001 From: Vyacheslav Matyukhin Date: Wed, 22 Jun 2022 01:00:43 +0300 Subject: [PATCH 02/12] language server for vscode; patched vsce --- packages/vscode-ext/.gitignore | 3 +- packages/vscode-ext/client/src/client.ts | 60 + .../vscode-ext/{ => client}/src/editor.ts | 0 .../vscode-ext/{ => client}/src/extension.ts | 7 +- .../vscode-ext/{ => client}/src/preview.ts | 0 packages/vscode-ext/{ => client}/src/utils.ts | 0 packages/vscode-ext/client/tsconfig.json | 12 + packages/vscode-ext/package.json | 19 +- packages/vscode-ext/server/src/server.ts | 84 + packages/vscode-ext/server/tsconfig.json | 12 + packages/vscode-ext/tsconfig.json | 16 +- packages/vscode-ext/yarn.lock | 1407 +---------------- yarn.lock | 240 ++- 13 files changed, 428 insertions(+), 1432 deletions(-) create mode 100644 packages/vscode-ext/client/src/client.ts rename packages/vscode-ext/{ => client}/src/editor.ts (100%) rename packages/vscode-ext/{ => client}/src/extension.ts (83%) rename packages/vscode-ext/{ => client}/src/preview.ts (100%) rename packages/vscode-ext/{ => client}/src/utils.ts (100%) create mode 100644 packages/vscode-ext/client/tsconfig.json create mode 100644 packages/vscode-ext/server/src/server.ts create mode 100644 packages/vscode-ext/server/tsconfig.json diff --git a/packages/vscode-ext/.gitignore b/packages/vscode-ext/.gitignore index e1e96097..a4e24e9e 100644 --- a/packages/vscode-ext/.gitignore +++ b/packages/vscode-ext/.gitignore @@ -1,4 +1,5 @@ /media/vendor -/out +/client/out +/server/out /*.vsix /syntaxes/*.json diff --git a/packages/vscode-ext/client/src/client.ts b/packages/vscode-ext/client/src/client.ts new file mode 100644 index 00000000..83cbd59e --- /dev/null +++ b/packages/vscode-ext/client/src/client.ts @@ -0,0 +1,60 @@ +import * as path from "path"; + +import * as vscode from "vscode"; +import { + LanguageClient, + LanguageClientOptions, + ServerOptions, + TransportKind, +} from "vscode-languageclient/node"; + +let client: LanguageClient; + +export const startClient = (context: vscode.ExtensionContext) => { + // The server is implemented in node + let serverModule = context.asAbsolutePath( + path.join("server", "out", "server.js") + ); + // The debug options for the server + // --inspect=6009: runs the server in Node's Inspector mode so VS Code can attach to the server for debugging + let debugOptions = { execArgv: ["--nolazy", "--inspect=6009"] }; + + // If the extension is launched in debug mode then the debug server options are used + // Otherwise the run options are used + let serverOptions: ServerOptions = { + run: { module: serverModule, transport: TransportKind.ipc }, + debug: { + module: serverModule, + transport: TransportKind.ipc, + options: debugOptions, + }, + }; + + // Options to control the language client + let clientOptions: LanguageClientOptions = { + // Register the server for plain text documents + documentSelector: [{ scheme: "file", language: "squiggle" }], + synchronize: { + // Notify the server about file changes to '.clientrc files contained in the workspace + fileEvents: vscode.workspace.createFileSystemWatcher("**/.clientrc"), + }, + }; + + // Create the language client and start the client. + client = new LanguageClient( + "squiggleServer", + "Squiggle Server", + serverOptions, + clientOptions + ); + + // Start the client. This will also launch the server + client.start(); +}; + +export const stopClient = () => { + if (!client) { + return undefined; + } + return client.stop(); +}; diff --git a/packages/vscode-ext/src/editor.ts b/packages/vscode-ext/client/src/editor.ts similarity index 100% rename from packages/vscode-ext/src/editor.ts rename to packages/vscode-ext/client/src/editor.ts diff --git a/packages/vscode-ext/src/extension.ts b/packages/vscode-ext/client/src/extension.ts similarity index 83% rename from packages/vscode-ext/src/extension.ts rename to packages/vscode-ext/client/src/extension.ts index 3b07fcfb..6ba040a4 100644 --- a/packages/vscode-ext/src/extension.ts +++ b/packages/vscode-ext/client/src/extension.ts @@ -1,6 +1,7 @@ // The module 'vscode' contains the VS Code extensibility API // Import the module and reference it with the alias vscode in your code below import * as vscode from "vscode"; +import { startClient, stopClient } from "./client"; import { SquiggleEditorProvider } from "./editor"; import { registerPreviewCommand } from "./preview"; @@ -11,7 +12,11 @@ export function activate(context: vscode.ExtensionContext) { context.subscriptions.push(SquiggleEditorProvider.register(context)); registerPreviewCommand(context); + + startClient(context); } // this method is called when your extension is deactivated -export function deactivate() {} +export function deactivate() { + stopClient(); +} diff --git a/packages/vscode-ext/src/preview.ts b/packages/vscode-ext/client/src/preview.ts similarity index 100% rename from packages/vscode-ext/src/preview.ts rename to packages/vscode-ext/client/src/preview.ts diff --git a/packages/vscode-ext/src/utils.ts b/packages/vscode-ext/client/src/utils.ts similarity index 100% rename from packages/vscode-ext/src/utils.ts rename to packages/vscode-ext/client/src/utils.ts diff --git a/packages/vscode-ext/client/tsconfig.json b/packages/vscode-ext/client/tsconfig.json new file mode 100644 index 00000000..079e3466 --- /dev/null +++ b/packages/vscode-ext/client/tsconfig.json @@ -0,0 +1,12 @@ +{ + "compilerOptions": { + "module": "commonjs", + "target": "es2020", + "lib": ["ES2020", "dom"], + "outDir": "out", + "rootDir": "src", + "sourceMap": true + }, + "include": ["src"], + "exclude": ["node_modules", ".vscode-test"] +} diff --git a/packages/vscode-ext/package.json b/packages/vscode-ext/package.json index af70abda..e2f6c025 100644 --- a/packages/vscode-ext/package.json +++ b/packages/vscode-ext/package.json @@ -3,7 +3,7 @@ "displayName": "Squiggle", "description": "Squiggle language support", "license": "MIT", - "version": "0.1.2", + "version": "0.2.0", "publisher": "QURI", "repository": { "type": "git", @@ -18,10 +18,11 @@ "Visualization" ], "activationEvents": [ + "onLanguage:squiggle", "onCustomEditor:squiggle.wysiwyg", "onCommand:squiggle.preview" ], - "main": "./out/extension.js", + "main": "./client/out/extension.js", "contributes": { "languages": [ { @@ -130,8 +131,9 @@ "compile": "yarn run compile:tsc && yarn run compile:grammar && yarn run compile:vendor", "watch": "tsc -watch -p ./", "pretest": "yarn run compile && yarn run lint", - "lint": "eslint src --ext ts", - "format": "eslint src --ext ts --fix" + "lint": "eslint client/src server/src --ext ts", + "format": "eslint client/src server/src --ext ts --fix", + "package": "npx vsce package --yarn" }, "devDependencies": { "@types/glob": "^7.2.0", @@ -142,6 +144,13 @@ "eslint": "^8.18.0", "glob": "^8.0.3", "js-yaml": "^4.1.0", - "typescript": "^4.7.4" + "typescript": "^4.7.4", + "vsce-yarn-patch": "^1.66.2" + }, + "dependencies": { + "vscode-languageclient": "^8.0.1", + "vscode-languageserver": "^7.0.0", + "vscode-languageserver-textdocument": "^1.0.5", + "@quri/squiggle-lang": "^0.2.11" } } diff --git a/packages/vscode-ext/server/src/server.ts b/packages/vscode-ext/server/src/server.ts new file mode 100644 index 00000000..84d9fd44 --- /dev/null +++ b/packages/vscode-ext/server/src/server.ts @@ -0,0 +1,84 @@ +import { + createConnection, + TextDocuments, + Diagnostic, + DiagnosticSeverity, + ProposedFeatures, + InitializeParams, + TextDocumentSyncKind, + InitializeResult, +} from "vscode-languageserver/node"; + +import { parse } from "@quri/squiggle-lang"; + +import { TextDocument } from "vscode-languageserver-textdocument"; + +// Create a connection for the server, using Node's IPC as a transport. +// Also include all preview / proposed LSP features. +let connection = createConnection(ProposedFeatures.all); + +const documents: TextDocuments = new TextDocuments(TextDocument); + +documents.onDidChangeContent((change) => { + validateSquiggleDocument(change.document); +}); + +let hasDiagnosticRelatedInformationCapability = false; + +connection.onInitialize((params: InitializeParams) => { + const capabilities = params.capabilities; + + hasDiagnosticRelatedInformationCapability = !!( + capabilities.textDocument && + capabilities.textDocument.publishDiagnostics && + capabilities.textDocument.publishDiagnostics.relatedInformation + ); + + const result: InitializeResult = { + capabilities: { + textDocumentSync: TextDocumentSyncKind.Incremental, + }, + }; + return result; +}); + +async function validateSquiggleDocument( + textDocument: TextDocument +): Promise { + // The validator creates diagnostics for all uppercase words length 2 and more + const text = textDocument.getText(); + const pattern = /\b[A-Z]{2,}\b/g; + let m: RegExpExecArray | null; + + let problems = 0; + const diagnostics: Diagnostic[] = []; + + const parseResult = parse(text); + if (parseResult.tag === "Error") { + const location = parseResult.value.value[1]; + diagnostics.push({ + severity: DiagnosticSeverity.Error, + range: { + start: { + line: location.start.line - 1, + character: location.start.column - 1, + }, + end: { + line: location.end.line - 1, + character: location.end.column - 1, + }, + }, + message: parseResult.value.value[0], + }); + } + + // Send the computed diagnostics to VSCode. + connection.sendDiagnostics({ uri: textDocument.uri, diagnostics }); +} + +// Make the text document manager listen on the connection +// for open, change and close text document events +documents.listen(connection); + +// Listen on the connection +connection.listen(); diff --git a/packages/vscode-ext/server/tsconfig.json b/packages/vscode-ext/server/tsconfig.json new file mode 100644 index 00000000..39822b33 --- /dev/null +++ b/packages/vscode-ext/server/tsconfig.json @@ -0,0 +1,12 @@ +{ + "compilerOptions": { + "module": "commonjs", + "target": "es2020", + "lib": ["ES2020", "dom"], + "outDir": "out", + "rootDir": "src", + "sourceMap": true + }, + "include": ["src"], + "exclude": ["node_modules"] +} diff --git a/packages/vscode-ext/tsconfig.json b/packages/vscode-ext/tsconfig.json index aed48ef9..62d1f7fa 100644 --- a/packages/vscode-ext/tsconfig.json +++ b/packages/vscode-ext/tsconfig.json @@ -1,15 +1,13 @@ { "compilerOptions": { "module": "commonjs", - "target": "ES2020", + "target": "es2020", + "lib": ["es2020", "dom"], "outDir": "out", - "lib": ["ES2020", "dom"], - "sourceMap": true, "rootDir": "src", - "strict": true /* enable all strict type-checking options */ - /* Additional Checks */ - // "noImplicitReturns": true, /* Report error when not all code paths in function return a value. */ - // "noFallthroughCasesInSwitch": true, /* Report errors for fallthrough cases in switch statement. */ - // "noUnusedParameters": true, /* Report errors on unused parameters. */ - } + "sourceMap": true + }, + "include": ["src"], + "exclude": ["node_modules", ".vscode-test"], + "references": [{ "path": "./client" }, { "path": "./server" }] } diff --git a/packages/vscode-ext/yarn.lock b/packages/vscode-ext/yarn.lock index 81cf74f7..787b7efd 100644 --- a/packages/vscode-ext/yarn.lock +++ b/packages/vscode-ext/yarn.lock @@ -1,1406 +1 @@ -# THIS IS AN AUTOGENERATED FILE. DO NOT EDIT THIS FILE DIRECTLY. -# yarn lockfile v1 - - -"@eslint/eslintrc@^1.3.0": - version "1.3.0" - resolved "https://registry.yarnpkg.com/@eslint/eslintrc/-/eslintrc-1.3.0.tgz#29f92c30bb3e771e4a2048c95fa6855392dfac4f" - integrity sha512-UWW0TMTmk2d7hLcWD1/e2g5HDM/HQ3csaLSqXCfqwh4uNDuNqlaKWXmEsL4Cs41Z0KnILNvwbHAah3C2yt06kw== - dependencies: - ajv "^6.12.4" - debug "^4.3.2" - espree "^9.3.2" - globals "^13.15.0" - ignore "^5.2.0" - import-fresh "^3.2.1" - js-yaml "^4.1.0" - minimatch "^3.1.2" - strip-json-comments "^3.1.1" - -"@humanwhocodes/config-array@^0.9.2": - version "0.9.5" - resolved "https://registry.yarnpkg.com/@humanwhocodes/config-array/-/config-array-0.9.5.tgz#2cbaf9a89460da24b5ca6531b8bbfc23e1df50c7" - integrity sha512-ObyMyWxZiCu/yTisA7uzx81s40xR2fD5Cg/2Kq7G02ajkNubJf6BopgDTmDyc3U7sXpNKM8cYOw7s7Tyr+DnCw== - dependencies: - "@humanwhocodes/object-schema" "^1.2.1" - debug "^4.1.1" - minimatch "^3.0.4" - -"@humanwhocodes/object-schema@^1.2.1": - version "1.2.1" - resolved "https://registry.yarnpkg.com/@humanwhocodes/object-schema/-/object-schema-1.2.1.tgz#b520529ec21d8e5945a1851dfd1c32e94e39ff45" - integrity sha512-ZnQMnLV4e7hDlUvw8H+U8ASL02SS2Gn6+9Ac3wGGLIe7+je2AeAOxPY+izIPJDfFDb7eDjev0Us8MO1iFRN8hA== - -"@nodelib/fs.scandir@2.1.5": - version "2.1.5" - resolved "https://registry.yarnpkg.com/@nodelib/fs.scandir/-/fs.scandir-2.1.5.tgz#7619c2eb21b25483f6d167548b4cfd5a7488c3d5" - integrity sha512-vq24Bq3ym5HEQm2NKCr3yXDwjc7vTsEThRDnkp2DK9p1uqLR+DHurm/NOTo0KG7HYHU7eppKZj3MyqYuMBf62g== - dependencies: - "@nodelib/fs.stat" "2.0.5" - run-parallel "^1.1.9" - -"@nodelib/fs.stat@2.0.5", "@nodelib/fs.stat@^2.0.2": - version "2.0.5" - resolved "https://registry.yarnpkg.com/@nodelib/fs.stat/-/fs.stat-2.0.5.tgz#5bd262af94e9d25bd1e71b05deed44876a222e8b" - integrity sha512-RkhPPp2zrqDAQA/2jNhnztcPAlv64XdhIp7a7454A5ovI7Bukxgt7MX7udwAu3zg1DcpPU0rz3VV1SeaqvY4+A== - -"@nodelib/fs.walk@^1.2.3": - version "1.2.8" - resolved "https://registry.yarnpkg.com/@nodelib/fs.walk/-/fs.walk-1.2.8.tgz#e95737e8bb6746ddedf69c556953494f196fe69a" - integrity sha512-oGB+UxlgWcgQkgwo8GcEGwemoTFt3FIO9ababBmaGwXIoBKZ+GTy0pP185beGg7Llih/NSHSV2XAs1lnznocSg== - dependencies: - "@nodelib/fs.scandir" "2.1.5" - fastq "^1.6.0" - -"@tootallnate/once@1": - version "1.1.2" - resolved "https://registry.yarnpkg.com/@tootallnate/once/-/once-1.1.2.tgz#ccb91445360179a04e7fe6aff78c00ffc1eeaf82" - integrity sha512-RbzJvlNzmRq5c3O09UipeuXno4tA1FE6ikOjxZK0tuxVv3412l64l5t1W5pj4+rJq9vpkm/kwiR07aZXnsKPxw== - -"@types/glob@^7.2.0": - version "7.2.0" - resolved "https://registry.yarnpkg.com/@types/glob/-/glob-7.2.0.tgz#bc1b5bf3aa92f25bd5dd39f35c57361bdce5b2eb" - integrity sha512-ZUxbzKl0IfJILTS6t7ip5fQQM/J3TJYubDm3nMbgubNNYS62eXeUpoLUC8/7fJNiFYHTrGPQn7hspDUzIHX3UA== - dependencies: - "@types/minimatch" "*" - "@types/node" "*" - -"@types/json-schema@^7.0.9": - version "7.0.11" - resolved "https://registry.yarnpkg.com/@types/json-schema/-/json-schema-7.0.11.tgz#d421b6c527a3037f7c84433fd2c4229e016863d3" - integrity sha512-wOuvG1SN4Us4rez+tylwwwCV1psiNVOkJeM3AUWUNWg/jDQY2+HE/444y5gc+jBmRqASOm2Oeh5c1axHobwRKQ== - -"@types/minimatch@*": - version "3.0.5" - resolved "https://registry.yarnpkg.com/@types/minimatch/-/minimatch-3.0.5.tgz#1001cc5e6a3704b83c236027e77f2f58ea010f40" - integrity sha512-Klz949h02Gz2uZCMGwDUSDS1YBlTdDDgbWHi+81l29tQALUtvz4rAYi5uoVhE5Lagoq6DeqAUlbrHvW/mXDgdQ== - -"@types/mocha@^9.1.1": - version "9.1.1" - resolved "https://registry.yarnpkg.com/@types/mocha/-/mocha-9.1.1.tgz#e7c4f1001eefa4b8afbd1eee27a237fee3bf29c4" - integrity sha512-Z61JK7DKDtdKTWwLeElSEBcWGRLY8g95ic5FoQqI9CMx0ns/Ghep3B4DfcEimiKMvtamNVULVNKEsiwV3aQmXw== - -"@types/node@*": - version "18.0.0" - resolved "https://registry.yarnpkg.com/@types/node/-/node-18.0.0.tgz#67c7b724e1bcdd7a8821ce0d5ee184d3b4dd525a" - integrity sha512-cHlGmko4gWLVI27cGJntjs/Sj8th9aYwplmZFwmmgYQQvL5NUsgVJG7OddLvNfLqYS31KFN0s3qlaD9qCaxACA== - -"@types/node@16.x": - version "16.11.41" - resolved "https://registry.yarnpkg.com/@types/node/-/node-16.11.41.tgz#88eb485b1bfdb4c224d878b7832239536aa2f813" - integrity sha512-mqoYK2TnVjdkGk8qXAVGc/x9nSaTpSrFaGFm43BUH3IdoBV0nta6hYaGmdOvIMlbHJbUEVen3gvwpwovAZKNdQ== - -"@types/vscode@^1.68.0": - version "1.68.0" - resolved "https://registry.yarnpkg.com/@types/vscode/-/vscode-1.68.0.tgz#c0864e4ea43c509bfc6b53f4e91aa923fd0475b8" - integrity sha512-duBwEK5ta/eBBMJMQ7ECMEsMvlE3XJdRGh3xoS1uOO4jl2Z4LPBl5vx8WvBP10ERAgDRmIt/FaSD4RHyBGbChw== - -"@typescript-eslint/eslint-plugin@^5.27.0": - version "5.28.0" - resolved "https://registry.yarnpkg.com/@typescript-eslint/eslint-plugin/-/eslint-plugin-5.28.0.tgz#6204ac33bdd05ab27c7f77960f1023951115d403" - integrity sha512-DXVU6Cg29H2M6EybqSg2A+x8DgO9TCUBRp4QEXQHJceLS7ogVDP0g3Lkg/SZCqcvkAP/RruuQqK0gdlkgmhSUA== - dependencies: - "@typescript-eslint/scope-manager" "5.28.0" - "@typescript-eslint/type-utils" "5.28.0" - "@typescript-eslint/utils" "5.28.0" - debug "^4.3.4" - functional-red-black-tree "^1.0.1" - ignore "^5.2.0" - regexpp "^3.2.0" - semver "^7.3.7" - tsutils "^3.21.0" - -"@typescript-eslint/parser@^5.27.0": - version "5.28.0" - resolved "https://registry.yarnpkg.com/@typescript-eslint/parser/-/parser-5.28.0.tgz#639b101cad2bfb7ae16e69710ac95c42bd4eae33" - integrity sha512-ekqoNRNK1lAcKhZESN/PdpVsWbP9jtiNqzFWkp/yAUdZvJalw2heCYuqRmM5eUJSIYEkgq5sGOjq+ZqsLMjtRA== - dependencies: - "@typescript-eslint/scope-manager" "5.28.0" - "@typescript-eslint/types" "5.28.0" - "@typescript-eslint/typescript-estree" "5.28.0" - debug "^4.3.4" - -"@typescript-eslint/scope-manager@5.28.0": - version "5.28.0" - resolved "https://registry.yarnpkg.com/@typescript-eslint/scope-manager/-/scope-manager-5.28.0.tgz#ef9a5c68fecde72fd2ff8a84b9c120324826c1b9" - integrity sha512-LeBLTqF/he1Z+boRhSqnso6YrzcKMTQ8bO/YKEe+6+O/JGof9M0g3IJlIsqfrK/6K03MlFIlycbf1uQR1IjE+w== - dependencies: - "@typescript-eslint/types" "5.28.0" - "@typescript-eslint/visitor-keys" "5.28.0" - -"@typescript-eslint/type-utils@5.28.0": - version "5.28.0" - resolved "https://registry.yarnpkg.com/@typescript-eslint/type-utils/-/type-utils-5.28.0.tgz#53ccc78fdcf0205ef544d843b84104c0e9c7ca8e" - integrity sha512-SyKjKh4CXPglueyC6ceAFytjYWMoPHMswPQae236zqe1YbhvCVQyIawesYywGiu98L9DwrxsBN69vGIVxJ4mQQ== - dependencies: - "@typescript-eslint/utils" "5.28.0" - debug "^4.3.4" - tsutils "^3.21.0" - -"@typescript-eslint/types@5.28.0": - version "5.28.0" - resolved "https://registry.yarnpkg.com/@typescript-eslint/types/-/types-5.28.0.tgz#cffd9bcdce28db6daaa146e48a0be4387a6f4e9d" - integrity sha512-2OOm8ZTOQxqkPbf+DAo8oc16sDlVR5owgJfKheBkxBKg1vAfw2JsSofH9+16VPlN9PWtv8Wzhklkqw3k/zCVxA== - -"@typescript-eslint/typescript-estree@5.28.0": - version "5.28.0" - resolved "https://registry.yarnpkg.com/@typescript-eslint/typescript-estree/-/typescript-estree-5.28.0.tgz#3487d158d091ca2772b285e67412ff6d9797d863" - integrity sha512-9GX+GfpV+F4hdTtYc6OV9ZkyYilGXPmQpm6AThInpBmKJEyRSIjORJd1G9+bknb7OTFYL+Vd4FBJAO6T78OVqA== - dependencies: - "@typescript-eslint/types" "5.28.0" - "@typescript-eslint/visitor-keys" "5.28.0" - debug "^4.3.4" - globby "^11.1.0" - is-glob "^4.0.3" - semver "^7.3.7" - tsutils "^3.21.0" - -"@typescript-eslint/utils@5.28.0": - version "5.28.0" - resolved "https://registry.yarnpkg.com/@typescript-eslint/utils/-/utils-5.28.0.tgz#b27a136eac300a48160b36d2aad0da44a1341b99" - integrity sha512-E60N5L0fjv7iPJV3UGc4EC+A3Lcj4jle9zzR0gW7vXhflO7/J29kwiTGITA2RlrmPokKiZbBy2DgaclCaEUs6g== - dependencies: - "@types/json-schema" "^7.0.9" - "@typescript-eslint/scope-manager" "5.28.0" - "@typescript-eslint/types" "5.28.0" - "@typescript-eslint/typescript-estree" "5.28.0" - eslint-scope "^5.1.1" - eslint-utils "^3.0.0" - -"@typescript-eslint/visitor-keys@5.28.0": - version "5.28.0" - resolved "https://registry.yarnpkg.com/@typescript-eslint/visitor-keys/-/visitor-keys-5.28.0.tgz#982bb226b763c48fc1859a60de33fbf939d40a0f" - integrity sha512-BtfP1vCor8cWacovzzPFOoeW4kBQxzmhxGoOpt0v1SFvG+nJ0cWaVdJk7cky1ArTcFHHKNIxyo2LLr3oNkSuXA== - dependencies: - "@typescript-eslint/types" "5.28.0" - eslint-visitor-keys "^3.3.0" - -"@ungap/promise-all-settled@1.1.2": - version "1.1.2" - resolved "https://registry.yarnpkg.com/@ungap/promise-all-settled/-/promise-all-settled-1.1.2.tgz#aa58042711d6e3275dd37dc597e5d31e8c290a44" - integrity sha512-sL/cEvJWAnClXw0wHk85/2L0G6Sj8UB0Ctc1TEMbKSsmpRosqhwj9gWgFRZSrBr2f9tiXISwNhCPmlfqUqyb9Q== - -"@vscode/test-electron@^2.1.3": - version "2.1.4" - resolved "https://registry.yarnpkg.com/@vscode/test-electron/-/test-electron-2.1.4.tgz#fa1b8915246d0102e81d4fd664bb6c337ca7092f" - integrity sha512-tHHAWNVwl8C7nyezHAHdNPWkksdXWvmae6bt4k1tJ9hvMm6QIIk95Mkutl82XHcD60mdP46EHDGU+xFsAvygOQ== - dependencies: - http-proxy-agent "^4.0.1" - https-proxy-agent "^5.0.0" - rimraf "^3.0.2" - unzipper "^0.10.11" - -acorn-jsx@^5.3.2: - version "5.3.2" - resolved "https://registry.yarnpkg.com/acorn-jsx/-/acorn-jsx-5.3.2.tgz#7ed5bb55908b3b2f1bc55c6af1653bada7f07937" - integrity sha512-rq9s+JNhf0IChjtDXxllJ7g41oZk5SlXtp0LHwyA5cejwn7vKmKp4pPri6YEePv2PU65sAsegbXtIinmDFDXgQ== - -acorn@^8.7.1: - version "8.7.1" - resolved "https://registry.yarnpkg.com/acorn/-/acorn-8.7.1.tgz#0197122c843d1bf6d0a5e83220a788f278f63c30" - integrity sha512-Xx54uLJQZ19lKygFXOWsscKUbsBZW0CPykPhVQdhIeIwrbPmJzqeASDInc8nKBnp/JT6igTs82qPXz069H8I/A== - -agent-base@6: - version "6.0.2" - resolved "https://registry.yarnpkg.com/agent-base/-/agent-base-6.0.2.tgz#49fff58577cfee3f37176feab4c22e00f86d7f77" - integrity sha512-RZNwNclF7+MS/8bDg70amg32dyeZGZxiDuQmZxKLAlQjr3jGyLx+4Kkk58UO7D2QdgFIQCovuSuZESne6RG6XQ== - dependencies: - debug "4" - -ajv@^6.10.0, ajv@^6.12.4: - version "6.12.6" - resolved "https://registry.yarnpkg.com/ajv/-/ajv-6.12.6.tgz#baf5a62e802b07d977034586f8c3baf5adf26df4" - integrity sha512-j3fVLgvTo527anyYyJOGTYJbG+vnnQYvE0m5mmkc1TK+nxAppkCLMIL0aZ4dblVCNoGShhm+kzE4ZUykBoMg4g== - dependencies: - fast-deep-equal "^3.1.1" - fast-json-stable-stringify "^2.0.0" - json-schema-traverse "^0.4.1" - uri-js "^4.2.2" - -ansi-colors@4.1.1: - version "4.1.1" - resolved "https://registry.yarnpkg.com/ansi-colors/-/ansi-colors-4.1.1.tgz#cbb9ae256bf750af1eab344f229aa27fe94ba348" - integrity sha512-JoX0apGbHaUJBNl6yF+p6JAFYZ666/hhCGKN5t9QFjbJQKUU/g8MNbFDbvfrgKXvI1QpZplPOnwIo99lX/AAmA== - -ansi-regex@^5.0.1: - version "5.0.1" - resolved "https://registry.yarnpkg.com/ansi-regex/-/ansi-regex-5.0.1.tgz#082cb2c89c9fe8659a311a53bd6a4dc5301db304" - integrity sha512-quJQXlTSUGL2LH9SUXo8VwsY4soanhgo6LNSm84E1LBcE8s3O0wpdiRzyR9z/ZZJMlMWv37qOOb9pdJlMUEKFQ== - -ansi-styles@^4.0.0, ansi-styles@^4.1.0: - version "4.3.0" - resolved "https://registry.yarnpkg.com/ansi-styles/-/ansi-styles-4.3.0.tgz#edd803628ae71c04c85ae7a0906edad34b648937" - integrity sha512-zbB9rCJAT1rbjiVDb2hqKFHNYLxgtk8NURxZ3IZwD3F6NtxbXZQCnnSi1Lkx+IDohdPlFp222wVALIheZJQSEg== - dependencies: - color-convert "^2.0.1" - -anymatch@~3.1.2: - version "3.1.2" - resolved "https://registry.yarnpkg.com/anymatch/-/anymatch-3.1.2.tgz#c0557c096af32f106198f4f4e2a383537e378716" - integrity sha512-P43ePfOAIupkguHUycrc4qJ9kz8ZiuOUijaETwX7THt0Y/GNK7v0aa8rY816xWjZ7rJdA5XdMcpVFTKMq+RvWg== - dependencies: - normalize-path "^3.0.0" - picomatch "^2.0.4" - -argparse@^2.0.1: - version "2.0.1" - resolved "https://registry.yarnpkg.com/argparse/-/argparse-2.0.1.tgz#246f50f3ca78a3240f6c997e8a9bd1eac49e4b38" - integrity sha512-8+9WqebbFzpX9OR+Wa6O29asIogeRMzcGtAINdpMHHyAg10f05aSFVBbcEqGf/PXw1EjAZ+q2/bEBg3DvurK3Q== - -array-union@^2.1.0: - version "2.1.0" - resolved "https://registry.yarnpkg.com/array-union/-/array-union-2.1.0.tgz#b798420adbeb1de828d84acd8a2e23d3efe85e8d" - integrity sha512-HGyxoOTYUyCM6stUe6EJgnd4EoewAI7zMdfqO+kGjnlZmBDz/cR5pf8r/cR4Wq60sL/p0IkcjUEEPwS3GFrIyw== - -balanced-match@^1.0.0: - version "1.0.2" - resolved "https://registry.yarnpkg.com/balanced-match/-/balanced-match-1.0.2.tgz#e83e3a7e3f300b34cb9d87f615fa0cbf357690ee" - integrity sha512-3oSeUO0TMV67hN1AmbXsK4yaqU7tjiHlbxRDZOpH0KW9+CeX4bRAaX0Anxt0tx2MrpRpWwQaPwIlISEJhYU5Pw== - -big-integer@^1.6.17: - version "1.6.51" - resolved "https://registry.yarnpkg.com/big-integer/-/big-integer-1.6.51.tgz#0df92a5d9880560d3ff2d5fd20245c889d130686" - integrity sha512-GPEid2Y9QU1Exl1rpO9B2IPJGHPSupF5GnVIP0blYvNOMer2bTvSWs1jGOUg04hTmu67nmLsQ9TBo1puaotBHg== - -binary-extensions@^2.0.0: - version "2.2.0" - resolved "https://registry.yarnpkg.com/binary-extensions/-/binary-extensions-2.2.0.tgz#75f502eeaf9ffde42fc98829645be4ea76bd9e2d" - integrity sha512-jDctJ/IVQbZoJykoeHbhXpOlNBqGNcwXJKJog42E5HDPUwQTSdjCHdihjj0DlnheQ7blbT6dHOafNAiS8ooQKA== - -binary@~0.3.0: - version "0.3.0" - resolved "https://registry.yarnpkg.com/binary/-/binary-0.3.0.tgz#9f60553bc5ce8c3386f3b553cff47462adecaa79" - integrity sha512-D4H1y5KYwpJgK8wk1Cue5LLPgmwHKYSChkbspQg5JtVuR5ulGckxfR62H3AE9UDkdMC8yyXlqYihuz3Aqg2XZg== - dependencies: - buffers "~0.1.1" - chainsaw "~0.1.0" - -bluebird@~3.4.1: - version "3.4.7" - resolved "https://registry.yarnpkg.com/bluebird/-/bluebird-3.4.7.tgz#f72d760be09b7f76d08ed8fae98b289a8d05fab3" - integrity sha512-iD3898SR7sWVRHbiQv+sHUtHnMvC1o3nW5rAcqnq3uOn07DSAppZYUkIGslDz6gXC7HfunPe7YVBgoEJASPcHA== - -brace-expansion@^1.1.7: - version "1.1.11" - resolved "https://registry.yarnpkg.com/brace-expansion/-/brace-expansion-1.1.11.tgz#3c7fcbf529d87226f3d2f52b966ff5271eb441dd" - integrity sha512-iCuPHDFgrHX7H2vEI/5xpz07zSHB00TpugqhmYtVmMO6518mCuRMoOYFldEBl0g187ufozdaHgWKcYFb61qGiA== - dependencies: - balanced-match "^1.0.0" - concat-map "0.0.1" - -brace-expansion@^2.0.1: - version "2.0.1" - resolved "https://registry.yarnpkg.com/brace-expansion/-/brace-expansion-2.0.1.tgz#1edc459e0f0c548486ecf9fc99f2221364b9a0ae" - integrity sha512-XnAIvQ8eM+kC6aULx6wuQiwVsnzsi9d3WxzV3FpWTGA19F621kwdbsAcFKXgKUHZWsy+mY6iL1sHTxWEFCytDA== - dependencies: - balanced-match "^1.0.0" - -braces@^3.0.2, braces@~3.0.2: - version "3.0.2" - resolved "https://registry.yarnpkg.com/braces/-/braces-3.0.2.tgz#3454e1a462ee8d599e236df336cd9ea4f8afe107" - integrity sha512-b8um+L1RzM3WDSzvhm6gIz1yfTbBt6YTlcEKAvsmqCZZFw46z626lVj9j1yEPW33H5H+lBQpZMP1k8l+78Ha0A== - dependencies: - fill-range "^7.0.1" - -browser-stdout@1.3.1: - version "1.3.1" - resolved "https://registry.yarnpkg.com/browser-stdout/-/browser-stdout-1.3.1.tgz#baa559ee14ced73452229bad7326467c61fabd60" - integrity sha512-qhAVI1+Av2X7qelOfAIYwXONood6XlZE/fXaBSmW/T5SzLAmCgzi+eiWE7fUvbHaeNBQH13UftjpXxsfLkMpgw== - -buffer-indexof-polyfill@~1.0.0: - version "1.0.2" - resolved "https://registry.yarnpkg.com/buffer-indexof-polyfill/-/buffer-indexof-polyfill-1.0.2.tgz#d2732135c5999c64b277fcf9b1abe3498254729c" - integrity sha512-I7wzHwA3t1/lwXQh+A5PbNvJxgfo5r3xulgpYDB5zckTu/Z9oUK9biouBKQUjEqzaz3HnAT6TYoovmE+GqSf7A== - -buffers@~0.1.1: - version "0.1.1" - resolved "https://registry.yarnpkg.com/buffers/-/buffers-0.1.1.tgz#b24579c3bed4d6d396aeee6d9a8ae7f5482ab7bb" - integrity sha512-9q/rDEGSb/Qsvv2qvzIzdluL5k7AaJOTrw23z9reQthrbF7is4CtlT0DXyO1oei2DCp4uojjzQ7igaSHp1kAEQ== - -callsites@^3.0.0: - version "3.1.0" - resolved "https://registry.yarnpkg.com/callsites/-/callsites-3.1.0.tgz#b3630abd8943432f54b3f0519238e33cd7df2f73" - integrity sha512-P8BjAsXvZS+VIDUI11hHCQEv74YT67YUi5JJFNWIqL235sBmjX4+qx9Muvls5ivyNENctx46xQLQ3aTuE7ssaQ== - -camelcase@^6.0.0: - version "6.3.0" - resolved "https://registry.yarnpkg.com/camelcase/-/camelcase-6.3.0.tgz#5685b95eb209ac9c0c177467778c9c84df58ba9a" - integrity sha512-Gmy6FhYlCY7uOElZUSbxo2UCDH8owEk996gkbrpsgGtrJLM3J7jGxl9Ic7Qwwj4ivOE5AWZWRMecDdF7hqGjFA== - -chainsaw@~0.1.0: - version "0.1.0" - resolved "https://registry.yarnpkg.com/chainsaw/-/chainsaw-0.1.0.tgz#5eab50b28afe58074d0d58291388828b5e5fbc98" - integrity sha512-75kWfWt6MEKNC8xYXIdRpDehRYY/tNSgwKaJq+dbbDcxORuVrrQ+SEHoWsniVn9XPYfP4gmdWIeDk/4YNp1rNQ== - dependencies: - traverse ">=0.3.0 <0.4" - -chalk@^4.0.0, chalk@^4.1.0: - version "4.1.2" - resolved "https://registry.yarnpkg.com/chalk/-/chalk-4.1.2.tgz#aac4e2b7734a740867aeb16bf02aad556a1e7a01" - integrity sha512-oKnbhFyRIXpUuez8iBMmyEa4nbj4IOQyuhc/wy9kY7/WVPcwIO9VA668Pu8RkO7+0G76SLROeyw9CpQ061i4mA== - dependencies: - ansi-styles "^4.1.0" - supports-color "^7.1.0" - -chokidar@3.5.3: - version "3.5.3" - resolved "https://registry.yarnpkg.com/chokidar/-/chokidar-3.5.3.tgz#1cf37c8707b932bd1af1ae22c0432e2acd1903bd" - integrity sha512-Dr3sfKRP6oTcjf2JmUmFJfeVMvXBdegxB0iVQ5eb2V10uFJUCAS8OByZdVAyVb8xXNz3GjjTgj9kLWsZTqE6kw== - dependencies: - anymatch "~3.1.2" - braces "~3.0.2" - glob-parent "~5.1.2" - is-binary-path "~2.1.0" - is-glob "~4.0.1" - normalize-path "~3.0.0" - readdirp "~3.6.0" - optionalDependencies: - fsevents "~2.3.2" - -cliui@^7.0.2: - version "7.0.4" - resolved "https://registry.yarnpkg.com/cliui/-/cliui-7.0.4.tgz#a0265ee655476fc807aea9df3df8df7783808b4f" - integrity sha512-OcRE68cOsVMXp1Yvonl/fzkQOyjLSu/8bhPDfQt0e0/Eb283TKP20Fs2MqoPsr9SwA595rRCA+QMzYc9nBP+JQ== - dependencies: - string-width "^4.2.0" - strip-ansi "^6.0.0" - wrap-ansi "^7.0.0" - -color-convert@^2.0.1: - version "2.0.1" - resolved "https://registry.yarnpkg.com/color-convert/-/color-convert-2.0.1.tgz#72d3a68d598c9bdb3af2ad1e84f21d896abd4de3" - integrity sha512-RRECPsj7iu/xb5oKYcsFHSppFNnsj/52OVTRKb4zP5onXwVF3zVmmToNcOfGC+CRDpfK/U584fMg38ZHCaElKQ== - dependencies: - color-name "~1.1.4" - -color-name@~1.1.4: - version "1.1.4" - resolved "https://registry.yarnpkg.com/color-name/-/color-name-1.1.4.tgz#c2a09a87acbde69543de6f63fa3995c826c536a2" - integrity sha512-dOy+3AuW3a2wNbZHIuMZpTcgjGuLU/uBL/ubcZF9OXbDo8ff4O8yVp5Bf0efS8uEoYo5q4Fx7dY9OgQGXgAsQA== - -concat-map@0.0.1: - version "0.0.1" - resolved "https://registry.yarnpkg.com/concat-map/-/concat-map-0.0.1.tgz#d8a96bd77fd68df7793a73036a3ba0d5405d477b" - integrity sha512-/Srv4dswyQNBfohGpz9o6Yb3Gz3SrUDqBH5rTuhGR7ahtlbYKnVxw2bCFMRljaA7EXHaXZ8wsHdodFvbkhKmqg== - -core-util-is@~1.0.0: - version "1.0.3" - resolved "https://registry.yarnpkg.com/core-util-is/-/core-util-is-1.0.3.tgz#a6042d3634c2b27e9328f837b965fac83808db85" - integrity sha512-ZQBvi1DcpJ4GDqanjucZ2Hj3wEO5pZDS89BWbkcrvdxksJorwUDDZamX9ldFkp9aw2lmBDLgkObEA4DWNJ9FYQ== - -cross-spawn@^7.0.2: - version "7.0.3" - resolved "https://registry.yarnpkg.com/cross-spawn/-/cross-spawn-7.0.3.tgz#f73a85b9d5d41d045551c177e2882d4ac85728a6" - integrity sha512-iRDPJKUPVEND7dHPO8rkbOnPpyDygcDFtWjpeWNCgy8WP2rXcxXL8TskReQl6OrB2G7+UJrags1q15Fudc7G6w== - dependencies: - path-key "^3.1.0" - shebang-command "^2.0.0" - which "^2.0.1" - -debug@4, debug@4.3.4, debug@^4.1.1, debug@^4.3.2, debug@^4.3.4: - version "4.3.4" - resolved "https://registry.yarnpkg.com/debug/-/debug-4.3.4.tgz#1319f6579357f2338d3337d2cdd4914bb5dcc865" - integrity sha512-PRWFHuSU3eDtQJPvnNY7Jcket1j0t5OuOsFzPPzsekD52Zl8qUfFIPEiswXqIvHWGVHOgX+7G/vCNNhehwxfkQ== - dependencies: - ms "2.1.2" - -decamelize@^4.0.0: - version "4.0.0" - resolved "https://registry.yarnpkg.com/decamelize/-/decamelize-4.0.0.tgz#aa472d7bf660eb15f3494efd531cab7f2a709837" - integrity sha512-9iE1PgSik9HeIIw2JO94IidnE3eBoQrFJ3w7sFuzSX4DpmZ3v5sZpUiV5Swcf6mQEF+Y0ru8Neo+p+nyh2J+hQ== - -deep-is@^0.1.3: - version "0.1.4" - resolved "https://registry.yarnpkg.com/deep-is/-/deep-is-0.1.4.tgz#a6f2dce612fadd2ef1f519b73551f17e85199831" - integrity sha512-oIPzksmTg4/MriiaYGO+okXDT7ztn/w3Eptv/+gSIdMdKsJo0u4CfYNFJPy+4SKMuCqGw2wxnA+URMg3t8a/bQ== - -diff@5.0.0: - version "5.0.0" - resolved "https://registry.yarnpkg.com/diff/-/diff-5.0.0.tgz#7ed6ad76d859d030787ec35855f5b1daf31d852b" - integrity sha512-/VTCrvm5Z0JGty/BWHljh+BAiw3IK+2j87NGMu8Nwc/f48WoDAC395uomO9ZD117ZOBaHmkX1oyLvkVM/aIT3w== - -dir-glob@^3.0.1: - version "3.0.1" - resolved "https://registry.yarnpkg.com/dir-glob/-/dir-glob-3.0.1.tgz#56dbf73d992a4a93ba1584f4534063fd2e41717f" - integrity sha512-WkrWp9GR4KXfKGYzOLmTuGVi1UWFfws377n9cc55/tb6DuqyF6pcQ5AbiHEshaDpY9v6oaSr2XCDidGmMwdzIA== - dependencies: - path-type "^4.0.0" - -doctrine@^3.0.0: - version "3.0.0" - resolved "https://registry.yarnpkg.com/doctrine/-/doctrine-3.0.0.tgz#addebead72a6574db783639dc87a121773973961" - integrity sha512-yS+Q5i3hBf7GBkd4KG8a7eBNNWNGLTaEwwYWUijIYM7zrlYDM0BFXHjjPWlWZ1Rg7UaddZeIDmi9jF3HmqiQ2w== - dependencies: - esutils "^2.0.2" - -duplexer2@~0.1.4: - version "0.1.4" - resolved "https://registry.yarnpkg.com/duplexer2/-/duplexer2-0.1.4.tgz#8b12dab878c0d69e3e7891051662a32fc6bddcc1" - integrity sha512-asLFVfWWtJ90ZyOUHMqk7/S2w2guQKxUI2itj3d92ADHhxUSbCMGi1f1cBcJ7xM1To+pE/Khbwo1yuNbMEPKeA== - dependencies: - readable-stream "^2.0.2" - -emoji-regex@^8.0.0: - version "8.0.0" - resolved "https://registry.yarnpkg.com/emoji-regex/-/emoji-regex-8.0.0.tgz#e818fd69ce5ccfcb404594f842963bf53164cc37" - integrity sha512-MSjYzcWNOA0ewAHpz0MxpYFvwg6yjy1NG3xteoqz644VCo/RPgnr1/GGt+ic3iJTzQ8Eu3TdM14SawnVUmGE6A== - -escalade@^3.1.1: - version "3.1.1" - resolved "https://registry.yarnpkg.com/escalade/-/escalade-3.1.1.tgz#d8cfdc7000965c5a0174b4a82eaa5c0552742e40" - integrity sha512-k0er2gUkLf8O0zKJiAhmkTnJlTvINGv7ygDNPbeIsX/TJjGJZHuh9B2UxbsaEkmlEo9MfhrSzmhIlhRlI2GXnw== - -escape-string-regexp@4.0.0, escape-string-regexp@^4.0.0: - version "4.0.0" - resolved "https://registry.yarnpkg.com/escape-string-regexp/-/escape-string-regexp-4.0.0.tgz#14ba83a5d373e3d311e5afca29cf5bfad965bf34" - integrity sha512-TtpcNJ3XAzx3Gq8sWRzJaVajRs0uVxA2YAkdb1jm2YkPz4G6egUFAyA3n5vtEIZefPk5Wa4UXbKuS5fKkJWdgA== - -eslint-scope@^5.1.1: - version "5.1.1" - resolved "https://registry.yarnpkg.com/eslint-scope/-/eslint-scope-5.1.1.tgz#e786e59a66cb92b3f6c1fb0d508aab174848f48c" - integrity sha512-2NxwbF/hZ0KpepYN0cNbo+FN6XoK7GaHlQhgx/hIZl6Va0bF45RQOOwhLIy8lQDbuCiadSLCBnH2CFYquit5bw== - dependencies: - esrecurse "^4.3.0" - estraverse "^4.1.1" - -eslint-scope@^7.1.1: - version "7.1.1" - resolved "https://registry.yarnpkg.com/eslint-scope/-/eslint-scope-7.1.1.tgz#fff34894c2f65e5226d3041ac480b4513a163642" - integrity sha512-QKQM/UXpIiHcLqJ5AOyIW7XZmzjkzQXYE54n1++wb0u9V/abW3l9uQnxX8Z5Xd18xyKIMTUAyQ0k1e8pz6LUrw== - dependencies: - esrecurse "^4.3.0" - estraverse "^5.2.0" - -eslint-utils@^3.0.0: - version "3.0.0" - resolved "https://registry.yarnpkg.com/eslint-utils/-/eslint-utils-3.0.0.tgz#8aebaface7345bb33559db0a1f13a1d2d48c3672" - integrity sha512-uuQC43IGctw68pJA1RgbQS8/NP7rch6Cwd4j3ZBtgo4/8Flj4eGE7ZYSZRN3iq5pVUv6GPdW5Z1RFleo84uLDA== - dependencies: - eslint-visitor-keys "^2.0.0" - -eslint-visitor-keys@^2.0.0: - version "2.1.0" - resolved "https://registry.yarnpkg.com/eslint-visitor-keys/-/eslint-visitor-keys-2.1.0.tgz#f65328259305927392c938ed44eb0a5c9b2bd303" - integrity sha512-0rSmRBzXgDzIsD6mGdJgevzgezI534Cer5L/vyMX0kHzT/jiB43jRhd9YUlMGYLQy2zprNmoT8qasCGtY+QaKw== - -eslint-visitor-keys@^3.3.0: - version "3.3.0" - resolved "https://registry.yarnpkg.com/eslint-visitor-keys/-/eslint-visitor-keys-3.3.0.tgz#f6480fa6b1f30efe2d1968aa8ac745b862469826" - integrity sha512-mQ+suqKJVyeuwGYHAdjMFqjCyfl8+Ldnxuyp3ldiMBFKkvytrXUZWaiPCEav8qDHKty44bD+qV1IP4T+w+xXRA== - -eslint@^8.16.0: - version "8.17.0" - resolved "https://registry.yarnpkg.com/eslint/-/eslint-8.17.0.tgz#1cfc4b6b6912f77d24b874ca1506b0fe09328c21" - integrity sha512-gq0m0BTJfci60Fz4nczYxNAlED+sMcihltndR8t9t1evnU/azx53x3t2UHXC/uRjcbvRw/XctpaNygSTcQD+Iw== - dependencies: - "@eslint/eslintrc" "^1.3.0" - "@humanwhocodes/config-array" "^0.9.2" - ajv "^6.10.0" - chalk "^4.0.0" - cross-spawn "^7.0.2" - debug "^4.3.2" - doctrine "^3.0.0" - escape-string-regexp "^4.0.0" - eslint-scope "^7.1.1" - eslint-utils "^3.0.0" - eslint-visitor-keys "^3.3.0" - espree "^9.3.2" - esquery "^1.4.0" - esutils "^2.0.2" - fast-deep-equal "^3.1.3" - file-entry-cache "^6.0.1" - functional-red-black-tree "^1.0.1" - glob-parent "^6.0.1" - globals "^13.15.0" - ignore "^5.2.0" - import-fresh "^3.0.0" - imurmurhash "^0.1.4" - is-glob "^4.0.0" - js-yaml "^4.1.0" - json-stable-stringify-without-jsonify "^1.0.1" - levn "^0.4.1" - lodash.merge "^4.6.2" - minimatch "^3.1.2" - natural-compare "^1.4.0" - optionator "^0.9.1" - regexpp "^3.2.0" - strip-ansi "^6.0.1" - strip-json-comments "^3.1.0" - text-table "^0.2.0" - v8-compile-cache "^2.0.3" - -espree@^9.3.2: - version "9.3.2" - resolved "https://registry.yarnpkg.com/espree/-/espree-9.3.2.tgz#f58f77bd334731182801ced3380a8cc859091596" - integrity sha512-D211tC7ZwouTIuY5x9XnS0E9sWNChB7IYKX/Xp5eQj3nFXhqmiUDB9q27y76oFl8jTg3pXcQx/bpxMfs3CIZbA== - dependencies: - acorn "^8.7.1" - acorn-jsx "^5.3.2" - eslint-visitor-keys "^3.3.0" - -esquery@^1.4.0: - version "1.4.0" - resolved "https://registry.yarnpkg.com/esquery/-/esquery-1.4.0.tgz#2148ffc38b82e8c7057dfed48425b3e61f0f24a5" - integrity sha512-cCDispWt5vHHtwMY2YrAQ4ibFkAL8RbH5YGBnZBc90MolvvfkkQcJro/aZiAQUlQ3qgrYS6D6v8Gc5G5CQsc9w== - dependencies: - estraverse "^5.1.0" - -esrecurse@^4.3.0: - version "4.3.0" - resolved "https://registry.yarnpkg.com/esrecurse/-/esrecurse-4.3.0.tgz#7ad7964d679abb28bee72cec63758b1c5d2c9921" - integrity sha512-KmfKL3b6G+RXvP8N1vr3Tq1kL/oCFgn2NYXEtqP8/L3pKapUA4G8cFVaoF3SU323CD4XypR/ffioHmkti6/Tag== - dependencies: - estraverse "^5.2.0" - -estraverse@^4.1.1: - version "4.3.0" - resolved "https://registry.yarnpkg.com/estraverse/-/estraverse-4.3.0.tgz#398ad3f3c5a24948be7725e83d11a7de28cdbd1d" - integrity sha512-39nnKffWz8xN1BU/2c79n9nB9HDzo0niYUqx6xyqUnyoAnQyyWpOTdZEeiCch8BBu515t4wp9ZmgVfVhn9EBpw== - -estraverse@^5.1.0, estraverse@^5.2.0: - version "5.3.0" - resolved "https://registry.yarnpkg.com/estraverse/-/estraverse-5.3.0.tgz#2eea5290702f26ab8fe5370370ff86c965d21123" - integrity sha512-MMdARuVEQziNTeJD8DgMqmhwR11BRQ/cBP+pLtYdSTnf3MIO8fFeiINEbX36ZdNlfU/7A9f3gUw49B3oQsvwBA== - -esutils@^2.0.2: - version "2.0.3" - resolved "https://registry.yarnpkg.com/esutils/-/esutils-2.0.3.tgz#74d2eb4de0b8da1293711910d50775b9b710ef64" - integrity sha512-kVscqXk4OCp68SZ0dkgEKVi6/8ij300KBWTJq32P/dYeWTSwK41WyTxalN1eRmA5Z9UU/LX9D7FWSmV9SAYx6g== - -fast-deep-equal@^3.1.1, fast-deep-equal@^3.1.3: - version "3.1.3" - resolved "https://registry.yarnpkg.com/fast-deep-equal/-/fast-deep-equal-3.1.3.tgz#3a7d56b559d6cbc3eb512325244e619a65c6c525" - integrity sha512-f3qQ9oQy9j2AhBe/H9VC91wLmKBCCU/gDOnKNAYG5hswO7BLKj09Hc5HYNz9cGI++xlpDCIgDaitVs03ATR84Q== - -fast-glob@^3.2.9: - version "3.2.11" - resolved "https://registry.yarnpkg.com/fast-glob/-/fast-glob-3.2.11.tgz#a1172ad95ceb8a16e20caa5c5e56480e5129c1d9" - integrity sha512-xrO3+1bxSo3ZVHAnqzyuewYT6aMFHRAd4Kcs92MAonjwQZLsK9d0SF1IyQ3k5PoirxTW0Oe/RqFgMQ6TcNE5Ew== - dependencies: - "@nodelib/fs.stat" "^2.0.2" - "@nodelib/fs.walk" "^1.2.3" - glob-parent "^5.1.2" - merge2 "^1.3.0" - micromatch "^4.0.4" - -fast-json-stable-stringify@^2.0.0: - version "2.1.0" - resolved "https://registry.yarnpkg.com/fast-json-stable-stringify/-/fast-json-stable-stringify-2.1.0.tgz#874bf69c6f404c2b5d99c481341399fd55892633" - integrity sha512-lhd/wF+Lk98HZoTCtlVraHtfh5XYijIjalXck7saUtuanSDyLMxnHhSXEDJqHxD7msR8D0uCmqlkwjCV8xvwHw== - -fast-levenshtein@^2.0.6: - version "2.0.6" - resolved "https://registry.yarnpkg.com/fast-levenshtein/-/fast-levenshtein-2.0.6.tgz#3d8a5c66883a16a30ca8643e851f19baa7797917" - integrity sha512-DCXu6Ifhqcks7TZKY3Hxp3y6qphY5SJZmrWMDrKcERSOXWQdMhU9Ig/PYrzyw/ul9jOIyh0N4M0tbC5hodg8dw== - -fastq@^1.6.0: - version "1.13.0" - resolved "https://registry.yarnpkg.com/fastq/-/fastq-1.13.0.tgz#616760f88a7526bdfc596b7cab8c18938c36b98c" - integrity sha512-YpkpUnK8od0o1hmeSc7UUs/eB/vIPWJYjKck2QKIzAf71Vm1AAQ3EbuZB3g2JIy+pg+ERD0vqI79KyZiB2e2Nw== - dependencies: - reusify "^1.0.4" - -file-entry-cache@^6.0.1: - version "6.0.1" - resolved "https://registry.yarnpkg.com/file-entry-cache/-/file-entry-cache-6.0.1.tgz#211b2dd9659cb0394b073e7323ac3c933d522027" - integrity sha512-7Gps/XWymbLk2QLYK4NzpMOrYjMhdIxXuIvy2QBsLE6ljuodKvdkWs/cpyJJ3CVIVpH0Oi1Hvg1ovbMzLdFBBg== - dependencies: - flat-cache "^3.0.4" - -fill-range@^7.0.1: - version "7.0.1" - resolved "https://registry.yarnpkg.com/fill-range/-/fill-range-7.0.1.tgz#1919a6a7c75fe38b2c7c77e5198535da9acdda40" - integrity sha512-qOo9F+dMUmC2Lcb4BbVvnKJxTPjCm+RRpe4gDuGrzkL7mEVl/djYSu2OdQ2Pa302N4oqkSg9ir6jaLWJ2USVpQ== - dependencies: - to-regex-range "^5.0.1" - -find-up@5.0.0: - version "5.0.0" - resolved "https://registry.yarnpkg.com/find-up/-/find-up-5.0.0.tgz#4c92819ecb7083561e4f4a240a86be5198f536fc" - integrity sha512-78/PXT1wlLLDgTzDs7sjq9hzz0vXD+zn+7wypEe4fXQxCmdmqfGsEPQxmiCSQI3ajFV91bVSsvNtrJRiW6nGng== - dependencies: - locate-path "^6.0.0" - path-exists "^4.0.0" - -flat-cache@^3.0.4: - version "3.0.4" - resolved "https://registry.yarnpkg.com/flat-cache/-/flat-cache-3.0.4.tgz#61b0338302b2fe9f957dcc32fc2a87f1c3048b11" - integrity sha512-dm9s5Pw7Jc0GvMYbshN6zchCA9RgQlzzEZX3vylR9IqFfS8XciblUXOKfW6SiuJ0e13eDYZoZV5wdrev7P3Nwg== - dependencies: - flatted "^3.1.0" - rimraf "^3.0.2" - -flat@^5.0.2: - version "5.0.2" - resolved "https://registry.yarnpkg.com/flat/-/flat-5.0.2.tgz#8ca6fe332069ffa9d324c327198c598259ceb241" - integrity sha512-b6suED+5/3rTpUBdG1gupIl8MPFCAMA0QXwmljLhvCUKcUvdE4gWky9zpuGCcXHOsz4J9wPGNWq6OKpmIzz3hQ== - -flatted@^3.1.0: - version "3.2.5" - resolved "https://registry.yarnpkg.com/flatted/-/flatted-3.2.5.tgz#76c8584f4fc843db64702a6bd04ab7a8bd666da3" - integrity sha512-WIWGi2L3DyTUvUrwRKgGi9TwxQMUEqPOPQBVi71R96jZXJdFskXEmf54BoZaS1kknGODoIGASGEzBUYdyMCBJg== - -fs.realpath@^1.0.0: - version "1.0.0" - resolved "https://registry.yarnpkg.com/fs.realpath/-/fs.realpath-1.0.0.tgz#1504ad2523158caa40db4a2787cb01411994ea4f" - integrity sha512-OO0pH2lK6a0hZnAdau5ItzHPI6pUlvI7jMVnxUQRtw4owF2wk8lOSabtGDCTP4Ggrg2MbGnWO9X8K1t4+fGMDw== - -fsevents@~2.3.2: - version "2.3.2" - resolved "https://registry.yarnpkg.com/fsevents/-/fsevents-2.3.2.tgz#8a526f78b8fdf4623b709e0b975c52c24c02fd1a" - integrity sha512-xiqMQR4xAeHTuB9uWm+fFRcIOgKBMiOBP+eXiyT7jsgVCq1bkVygt00oASowB7EdtpOHaaPgKt812P9ab+DDKA== - -fstream@^1.0.12: - version "1.0.12" - resolved "https://registry.yarnpkg.com/fstream/-/fstream-1.0.12.tgz#4e8ba8ee2d48be4f7d0de505455548eae5932045" - integrity sha512-WvJ193OHa0GHPEL+AycEJgxvBEwyfRkN1vhjca23OaPVMCaLCXTd5qAu82AjTcgP1UJmytkOKb63Ypde7raDIg== - dependencies: - graceful-fs "^4.1.2" - inherits "~2.0.0" - mkdirp ">=0.5 0" - rimraf "2" - -functional-red-black-tree@^1.0.1: - version "1.0.1" - resolved "https://registry.yarnpkg.com/functional-red-black-tree/-/functional-red-black-tree-1.0.1.tgz#1b0ab3bd553b2a0d6399d29c0e3ea0b252078327" - integrity sha512-dsKNQNdj6xA3T+QlADDA7mOSlX0qiMINjn0cgr+eGHGsbSHzTabcIogz2+p/iqP1Xs6EP/sS2SbqH+brGTbq0g== - -get-caller-file@^2.0.5: - version "2.0.5" - resolved "https://registry.yarnpkg.com/get-caller-file/-/get-caller-file-2.0.5.tgz#4f94412a82db32f36e3b0b9741f8a97feb031f7e" - integrity sha512-DyFP3BM/3YHTQOCUL/w0OZHR0lpKeGrxotcHWcqNEdnltqFwXVfhEBQ94eIo34AfQpo0rGki4cyIiftY06h2Fg== - -glob-parent@^5.1.2, glob-parent@~5.1.2: - version "5.1.2" - resolved "https://registry.yarnpkg.com/glob-parent/-/glob-parent-5.1.2.tgz#869832c58034fe68a4093c17dc15e8340d8401c4" - integrity sha512-AOIgSQCepiJYwP3ARnGx+5VnTu2HBYdzbGP45eLw1vr3zB3vZLeyed1sC9hnbcOc9/SrMyM5RPQrkGz4aS9Zow== - dependencies: - is-glob "^4.0.1" - -glob-parent@^6.0.1: - version "6.0.2" - resolved "https://registry.yarnpkg.com/glob-parent/-/glob-parent-6.0.2.tgz#6d237d99083950c79290f24c7642a3de9a28f9e3" - integrity sha512-XxwI8EOhVQgWp6iDL+3b0r86f4d6AX6zSU55HfB4ydCEuXLXc5FcYeOu+nnGftS4TEju/11rt4KJPTMgbfmv4A== - dependencies: - is-glob "^4.0.3" - -glob@7.2.0: - version "7.2.0" - resolved "https://registry.yarnpkg.com/glob/-/glob-7.2.0.tgz#d15535af7732e02e948f4c41628bd910293f6023" - integrity sha512-lmLf6gtyrPq8tTjSmrO94wBeQbFR3HbLHbuyD69wuyQkImp2hWqMGB47OX65FBkPffO641IP9jWa1z4ivqG26Q== - dependencies: - fs.realpath "^1.0.0" - inflight "^1.0.4" - inherits "2" - minimatch "^3.0.4" - once "^1.3.0" - path-is-absolute "^1.0.0" - -glob@^7.1.3: - version "7.2.3" - resolved "https://registry.yarnpkg.com/glob/-/glob-7.2.3.tgz#b8df0fb802bbfa8e89bd1d938b4e16578ed44f2b" - integrity sha512-nFR0zLpU2YCaRxwoCJvL6UvCH2JFyFVIvwTLsIf21AuHlMskA1hhTdk+LlYJtOlYt9v6dvszD2BGRqBL+iQK9Q== - dependencies: - fs.realpath "^1.0.0" - inflight "^1.0.4" - inherits "2" - minimatch "^3.1.1" - once "^1.3.0" - path-is-absolute "^1.0.0" - -glob@^8.0.3: - version "8.0.3" - resolved "https://registry.yarnpkg.com/glob/-/glob-8.0.3.tgz#415c6eb2deed9e502c68fa44a272e6da6eeca42e" - integrity sha512-ull455NHSHI/Y1FqGaaYFaLGkNMMJbavMrEGFXG/PGrg6y7sutWHUHrz6gy6WEBH6akM1M414dWKCNs+IhKdiQ== - dependencies: - fs.realpath "^1.0.0" - inflight "^1.0.4" - inherits "2" - minimatch "^5.0.1" - once "^1.3.0" - -globals@^13.15.0: - version "13.15.0" - resolved "https://registry.yarnpkg.com/globals/-/globals-13.15.0.tgz#38113218c907d2f7e98658af246cef8b77e90bac" - integrity sha512-bpzcOlgDhMG070Av0Vy5Owklpv1I6+j96GhUI7Rh7IzDCKLzboflLrrfqMu8NquDbiR4EOQk7XzJwqVJxicxog== - dependencies: - type-fest "^0.20.2" - -globby@^11.1.0: - version "11.1.0" - resolved "https://registry.yarnpkg.com/globby/-/globby-11.1.0.tgz#bd4be98bb042f83d796f7e3811991fbe82a0d34b" - integrity sha512-jhIXaOzy1sb8IyocaruWSn1TjmnBVs8Ayhcy83rmxNJ8q2uWKCAj3CnJY+KpGSXCueAPc0i05kVvVKtP1t9S3g== - dependencies: - array-union "^2.1.0" - dir-glob "^3.0.1" - fast-glob "^3.2.9" - ignore "^5.2.0" - merge2 "^1.4.1" - slash "^3.0.0" - -graceful-fs@^4.1.2, graceful-fs@^4.2.2: - version "4.2.10" - resolved "https://registry.yarnpkg.com/graceful-fs/-/graceful-fs-4.2.10.tgz#147d3a006da4ca3ce14728c7aefc287c367d7a6c" - integrity sha512-9ByhssR2fPVsNZj478qUUbKfmL0+t5BDVyjShtyZZLiK7ZDAArFFfopyOTj0M05wE2tJPisA4iTnnXl2YoPvOA== - -has-flag@^4.0.0: - version "4.0.0" - resolved "https://registry.yarnpkg.com/has-flag/-/has-flag-4.0.0.tgz#944771fd9c81c81265c4d6941860da06bb59479b" - integrity sha512-EykJT/Q1KjTWctppgIAgfSO0tKVuZUjhgMr17kqTumMl6Afv3EISleU7qZUzoXDFTAHTDC4NOoG/ZxU3EvlMPQ== - -he@1.2.0: - version "1.2.0" - resolved "https://registry.yarnpkg.com/he/-/he-1.2.0.tgz#84ae65fa7eafb165fddb61566ae14baf05664f0f" - integrity sha512-F/1DnUGPopORZi0ni+CvrCgHQ5FyEAHRLSApuYWMmrbSwoN2Mn/7k+Gl38gJnR7yyDZk6WLXwiGod1JOWNDKGw== - -http-proxy-agent@^4.0.1: - version "4.0.1" - resolved "https://registry.yarnpkg.com/http-proxy-agent/-/http-proxy-agent-4.0.1.tgz#8a8c8ef7f5932ccf953c296ca8291b95aa74aa3a" - integrity sha512-k0zdNgqWTGA6aeIRVpvfVob4fL52dTfaehylg0Y4UvSySvOq/Y+BOyPrgpUrA7HylqvU8vIZGsRuXmspskV0Tg== - dependencies: - "@tootallnate/once" "1" - agent-base "6" - debug "4" - -https-proxy-agent@^5.0.0: - version "5.0.1" - resolved "https://registry.yarnpkg.com/https-proxy-agent/-/https-proxy-agent-5.0.1.tgz#c59ef224a04fe8b754f3db0063a25ea30d0005d6" - integrity sha512-dFcAjpTQFgoLMzC2VwU+C/CbS7uRL0lWmxDITmqm7C+7F0Odmj6s9l6alZc6AELXhrnggM2CeWSXHGOdX2YtwA== - dependencies: - agent-base "6" - debug "4" - -ignore@^5.2.0: - version "5.2.0" - resolved "https://registry.yarnpkg.com/ignore/-/ignore-5.2.0.tgz#6d3bac8fa7fe0d45d9f9be7bac2fc279577e345a" - integrity sha512-CmxgYGiEPCLhfLnpPp1MoRmifwEIOgjcHXxOBjv7mY96c+eWScsOP9c112ZyLdWHi0FxHjI+4uVhKYp/gcdRmQ== - -import-fresh@^3.0.0, import-fresh@^3.2.1: - version "3.3.0" - resolved "https://registry.yarnpkg.com/import-fresh/-/import-fresh-3.3.0.tgz#37162c25fcb9ebaa2e6e53d5b4d88ce17d9e0c2b" - integrity sha512-veYYhQa+D1QBKznvhUHxb8faxlrwUnxseDAbAp457E0wLNio2bOSKnjYDhMj+YiAq61xrMGhQk9iXVk5FzgQMw== - dependencies: - parent-module "^1.0.0" - resolve-from "^4.0.0" - -imurmurhash@^0.1.4: - version "0.1.4" - resolved "https://registry.yarnpkg.com/imurmurhash/-/imurmurhash-0.1.4.tgz#9218b9b2b928a238b13dc4fb6b6d576f231453ea" - integrity sha512-JmXMZ6wuvDmLiHEml9ykzqO6lwFbof0GG4IkcGaENdCRDDmMVnny7s5HsIgHCbaq0w2MyPhDqkhTUgS2LU2PHA== - -inflight@^1.0.4: - version "1.0.6" - resolved "https://registry.yarnpkg.com/inflight/-/inflight-1.0.6.tgz#49bd6331d7d02d0c09bc910a1075ba8165b56df9" - integrity sha512-k92I/b08q4wvFscXCLvqfsHCrjrF7yiXsQuIVvVE7N82W3+aqpzuUdBbfhWcy/FZR3/4IgflMgKLOsvPDrGCJA== - dependencies: - once "^1.3.0" - wrappy "1" - -inherits@2, inherits@~2.0.0, inherits@~2.0.3: - version "2.0.4" - resolved "https://registry.yarnpkg.com/inherits/-/inherits-2.0.4.tgz#0fa2c64f932917c3433a0ded55363aae37416b7c" - integrity sha512-k/vGaX4/Yla3WzyMCvTQOXYeIHvqOKtnqBduzTHpzpQZzAskKMhZ2K+EnBiSM9zGSoIFeMpXKxa4dYeZIQqewQ== - -is-binary-path@~2.1.0: - version "2.1.0" - resolved "https://registry.yarnpkg.com/is-binary-path/-/is-binary-path-2.1.0.tgz#ea1f7f3b80f064236e83470f86c09c254fb45b09" - integrity sha512-ZMERYes6pDydyuGidse7OsHxtbI7WVeUEozgR/g7rd0xUimYNlvZRE/K2MgZTjWy725IfelLeVcEM97mmtRGXw== - dependencies: - binary-extensions "^2.0.0" - -is-extglob@^2.1.1: - version "2.1.1" - resolved "https://registry.yarnpkg.com/is-extglob/-/is-extglob-2.1.1.tgz#a88c02535791f02ed37c76a1b9ea9773c833f8c2" - integrity sha512-SbKbANkN603Vi4jEZv49LeVJMn4yGwsbzZworEoyEiutsN3nJYdbO36zfhGJ6QEDpOZIFkDtnq5JRxmvl3jsoQ== - -is-fullwidth-code-point@^3.0.0: - version "3.0.0" - resolved "https://registry.yarnpkg.com/is-fullwidth-code-point/-/is-fullwidth-code-point-3.0.0.tgz#f116f8064fe90b3f7844a38997c0b75051269f1d" - integrity sha512-zymm5+u+sCsSWyD9qNaejV3DFvhCKclKdizYaJUuHA83RLjb7nSuGnddCHGv0hk+KY7BMAlsWeK4Ueg6EV6XQg== - -is-glob@^4.0.0, is-glob@^4.0.1, is-glob@^4.0.3, is-glob@~4.0.1: - version "4.0.3" - resolved "https://registry.yarnpkg.com/is-glob/-/is-glob-4.0.3.tgz#64f61e42cbbb2eec2071a9dac0b28ba1e65d5084" - integrity sha512-xelSayHH36ZgE7ZWhli7pW34hNbNl8Ojv5KVmkJD4hBdD3th8Tfk9vYasLM+mXWOZhFkgZfxhLSnrwRr4elSSg== - dependencies: - is-extglob "^2.1.1" - -is-number@^7.0.0: - version "7.0.0" - resolved "https://registry.yarnpkg.com/is-number/-/is-number-7.0.0.tgz#7535345b896734d5f80c4d06c50955527a14f12b" - integrity sha512-41Cifkg6e8TylSpdtTpeLVMqvSBEVzTttHvERD741+pnZ8ANv0004MRL43QKPDlK9cGvNp6NZWZUBlbGXYxxng== - -is-plain-obj@^2.1.0: - version "2.1.0" - resolved "https://registry.yarnpkg.com/is-plain-obj/-/is-plain-obj-2.1.0.tgz#45e42e37fccf1f40da8e5f76ee21515840c09287" - integrity sha512-YWnfyRwxL/+SsrWYfOpUtz5b3YD+nyfkHvjbcanzk8zgyO4ASD67uVMRt8k5bM4lLMDnXfriRhOpemw+NfT1eA== - -is-unicode-supported@^0.1.0: - version "0.1.0" - resolved "https://registry.yarnpkg.com/is-unicode-supported/-/is-unicode-supported-0.1.0.tgz#3f26c76a809593b52bfa2ecb5710ed2779b522a7" - integrity sha512-knxG2q4UC3u8stRGyAVJCOdxFmv5DZiRcdlIaAQXAbSfJya+OhopNotLQrstBhququ4ZpuKbDc/8S6mgXgPFPw== - -isarray@~1.0.0: - version "1.0.0" - resolved "https://registry.yarnpkg.com/isarray/-/isarray-1.0.0.tgz#bb935d48582cba168c06834957a54a3e07124f11" - integrity sha512-VLghIWNM6ELQzo7zwmcg0NmTVyWKYjvIeM83yjp0wRDTmUnrM678fQbcKBo6n2CJEF0szoG//ytg+TKla89ALQ== - -isexe@^2.0.0: - version "2.0.0" - resolved "https://registry.yarnpkg.com/isexe/-/isexe-2.0.0.tgz#e8fbf374dc556ff8947a10dcb0572d633f2cfa10" - integrity sha512-RHxMLp9lnKHGHRng9QFhRCMbYAcVpn69smSGcq3f36xjgVVWThj4qqLbTLlq7Ssj8B+fIQ1EuCEGI2lKsyQeIw== - -js-yaml@4.1.0, js-yaml@^4.1.0: - version "4.1.0" - resolved "https://registry.yarnpkg.com/js-yaml/-/js-yaml-4.1.0.tgz#c1fb65f8f5017901cdd2c951864ba18458a10602" - integrity sha512-wpxZs9NoxZaJESJGIZTyDEaYpl0FKSA+FB9aJiyemKhMwkxQg63h4T1KJgUGHpTqPDNRcmmYLugrRjJlBtWvRA== - dependencies: - argparse "^2.0.1" - -json-schema-traverse@^0.4.1: - version "0.4.1" - resolved "https://registry.yarnpkg.com/json-schema-traverse/-/json-schema-traverse-0.4.1.tgz#69f6a87d9513ab8bb8fe63bdb0979c448e684660" - integrity sha512-xbbCH5dCYU5T8LcEhhuh7HJ88HXuW3qsI3Y0zOZFKfZEHcpWiHU/Jxzk629Brsab/mMiHQti9wMP+845RPe3Vg== - -json-stable-stringify-without-jsonify@^1.0.1: - version "1.0.1" - resolved "https://registry.yarnpkg.com/json-stable-stringify-without-jsonify/-/json-stable-stringify-without-jsonify-1.0.1.tgz#9db7b59496ad3f3cfef30a75142d2d930ad72651" - integrity sha512-Bdboy+l7tA3OGW6FjyFHWkP5LuByj1Tk33Ljyq0axyzdk9//JSi2u3fP1QSmd1KNwq6VOKYGlAu87CisVir6Pw== - -levn@^0.4.1: - version "0.4.1" - resolved "https://registry.yarnpkg.com/levn/-/levn-0.4.1.tgz#ae4562c007473b932a6200d403268dd2fffc6ade" - integrity sha512-+bT2uH4E5LGE7h/n3evcS/sQlJXCpIp6ym8OWJ5eV6+67Dsql/LaaT7qJBAt2rzfoa/5QBGBhxDix1dMt2kQKQ== - dependencies: - prelude-ls "^1.2.1" - type-check "~0.4.0" - -listenercount@~1.0.1: - version "1.0.1" - resolved "https://registry.yarnpkg.com/listenercount/-/listenercount-1.0.1.tgz#84c8a72ab59c4725321480c975e6508342e70937" - integrity sha512-3mk/Zag0+IJxeDrxSgaDPy4zZ3w05PRZeJNnlWhzFz5OkX49J4krc+A8X2d2M69vGMBEX0uyl8M+W+8gH+kBqQ== - -locate-path@^6.0.0: - version "6.0.0" - resolved "https://registry.yarnpkg.com/locate-path/-/locate-path-6.0.0.tgz#55321eb309febbc59c4801d931a72452a681d286" - integrity sha512-iPZK6eYjbxRu3uB4/WZ3EsEIMJFMqAoopl3R+zuq0UjcAm/MO6KCweDgPfP3elTztoKP3KtnVHxTn2NHBSDVUw== - dependencies: - p-locate "^5.0.0" - -lodash.merge@^4.6.2: - version "4.6.2" - resolved "https://registry.yarnpkg.com/lodash.merge/-/lodash.merge-4.6.2.tgz#558aa53b43b661e1925a0afdfa36a9a1085fe57a" - integrity sha512-0KpjqXRVvrYyCsX1swR/XTK0va6VQkQM6MNo7PqW77ByjAhoARA8EfrP1N4+KlKj8YS0ZUCtRT/YUuhyYDujIQ== - -log-symbols@4.1.0: - version "4.1.0" - resolved "https://registry.yarnpkg.com/log-symbols/-/log-symbols-4.1.0.tgz#3fbdbb95b4683ac9fc785111e792e558d4abd503" - integrity sha512-8XPvpAA8uyhfteu8pIvQxpJZ7SYYdpUivZpGy6sFsBuKRY/7rQGavedeB8aK+Zkyq6upMFVL/9AW6vOYzfRyLg== - dependencies: - chalk "^4.1.0" - is-unicode-supported "^0.1.0" - -lru-cache@^6.0.0: - version "6.0.0" - resolved "https://registry.yarnpkg.com/lru-cache/-/lru-cache-6.0.0.tgz#6d6fe6570ebd96aaf90fcad1dafa3b2566db3a94" - integrity sha512-Jo6dJ04CmSjuznwJSS3pUeWmd/H0ffTlkXXgwZi+eq1UCmqQwCh+eLsYOYCwY991i2Fah4h1BEMCx4qThGbsiA== - dependencies: - yallist "^4.0.0" - -merge2@^1.3.0, merge2@^1.4.1: - version "1.4.1" - resolved "https://registry.yarnpkg.com/merge2/-/merge2-1.4.1.tgz#4368892f885e907455a6fd7dc55c0c9d404990ae" - integrity sha512-8q7VEgMJW4J8tcfVPy8g09NcQwZdbwFEqhe/WZkoIzjn/3TGDwtOCYtXGxA3O8tPzpczCCDgv+P2P5y00ZJOOg== - -micromatch@^4.0.4: - version "4.0.5" - resolved "https://registry.yarnpkg.com/micromatch/-/micromatch-4.0.5.tgz#bc8999a7cbbf77cdc89f132f6e467051b49090c6" - integrity sha512-DMy+ERcEW2q8Z2Po+WNXuw3c5YaUSFjAO5GsJqfEl7UjvtIuFKO6ZrKvcItdy98dwFI2N1tg3zNIdKaQT+aNdA== - dependencies: - braces "^3.0.2" - picomatch "^2.3.1" - -minimatch@5.0.1: - version "5.0.1" - resolved "https://registry.yarnpkg.com/minimatch/-/minimatch-5.0.1.tgz#fb9022f7528125187c92bd9e9b6366be1cf3415b" - integrity sha512-nLDxIFRyhDblz3qMuq+SoRZED4+miJ/G+tdDrjkkkRnjAsBexeGpgjLEQ0blJy7rHhR2b93rhQY4SvyWu9v03g== - dependencies: - brace-expansion "^2.0.1" - -minimatch@^3.0.4, minimatch@^3.1.1, minimatch@^3.1.2: - version "3.1.2" - resolved "https://registry.yarnpkg.com/minimatch/-/minimatch-3.1.2.tgz#19cd194bfd3e428f049a70817c038d89ab4be35b" - integrity sha512-J7p63hRiAjw1NDEww1W7i37+ByIrOWO5XQQAzZ3VOcL0PNybwpfmV/N05zFAzwQ9USyEcX6t3UO+K5aqBQOIHw== - dependencies: - brace-expansion "^1.1.7" - -minimatch@^5.0.1: - version "5.1.0" - resolved "https://registry.yarnpkg.com/minimatch/-/minimatch-5.1.0.tgz#1717b464f4971b144f6aabe8f2d0b8e4511e09c7" - integrity sha512-9TPBGGak4nHfGZsPBohm9AWg6NoT7QTCehS3BIJABslyZbzxfV78QM2Y6+i741OPZIafFAaiiEMh5OyIrJPgtg== - dependencies: - brace-expansion "^2.0.1" - -minimist@^1.2.6: - version "1.2.6" - resolved "https://registry.yarnpkg.com/minimist/-/minimist-1.2.6.tgz#8637a5b759ea0d6e98702cfb3a9283323c93af44" - integrity sha512-Jsjnk4bw3YJqYzbdyBiNsPWHPfO++UGG749Cxs6peCu5Xg4nrena6OVxOYxrQTqww0Jmwt+Ref8rggumkTLz9Q== - -"mkdirp@>=0.5 0": - version "0.5.6" - resolved "https://registry.yarnpkg.com/mkdirp/-/mkdirp-0.5.6.tgz#7def03d2432dcae4ba1d611445c48396062255f6" - integrity sha512-FP+p8RB8OWpF3YZBCrP5gtADmtXApB5AMLn+vdyA+PyxCjrCs00mjyUozssO33cwDeT3wNGdLxJ5M//YqtHAJw== - dependencies: - minimist "^1.2.6" - -mocha@^10.0.0: - version "10.0.0" - resolved "https://registry.yarnpkg.com/mocha/-/mocha-10.0.0.tgz#205447d8993ec755335c4b13deba3d3a13c4def9" - integrity sha512-0Wl+elVUD43Y0BqPZBzZt8Tnkw9CMUdNYnUsTfOM1vuhJVZL+kiesFYsqwBkEEuEixaiPe5ZQdqDgX2jddhmoA== - dependencies: - "@ungap/promise-all-settled" "1.1.2" - ansi-colors "4.1.1" - browser-stdout "1.3.1" - chokidar "3.5.3" - debug "4.3.4" - diff "5.0.0" - escape-string-regexp "4.0.0" - find-up "5.0.0" - glob "7.2.0" - he "1.2.0" - js-yaml "4.1.0" - log-symbols "4.1.0" - minimatch "5.0.1" - ms "2.1.3" - nanoid "3.3.3" - serialize-javascript "6.0.0" - strip-json-comments "3.1.1" - supports-color "8.1.1" - workerpool "6.2.1" - yargs "16.2.0" - yargs-parser "20.2.4" - yargs-unparser "2.0.0" - -ms@2.1.2: - version "2.1.2" - resolved "https://registry.yarnpkg.com/ms/-/ms-2.1.2.tgz#d09d1f357b443f493382a8eb3ccd183872ae6009" - integrity sha512-sGkPx+VjMtmA6MX27oA4FBFELFCZZ4S4XqeGOXCv68tT+jb3vk/RyaKWP0PTKyWtmLSM0b+adUTEvbs1PEaH2w== - -ms@2.1.3: - version "2.1.3" - resolved "https://registry.yarnpkg.com/ms/-/ms-2.1.3.tgz#574c8138ce1d2b5861f0b44579dbadd60c6615b2" - integrity sha512-6FlzubTLZG3J2a/NVCAleEhjzq5oxgHyaCU9yYXvcLsvoVaHJq/s5xXI6/XXP6tz7R9xAOtHnSO/tXtF3WRTlA== - -nanoid@3.3.3: - version "3.3.3" - resolved "https://registry.yarnpkg.com/nanoid/-/nanoid-3.3.3.tgz#fd8e8b7aa761fe807dba2d1b98fb7241bb724a25" - integrity sha512-p1sjXuopFs0xg+fPASzQ28agW1oHD7xDsd9Xkf3T15H3c/cifrFHVwrh74PdoklAPi+i7MdRsE47vm2r6JoB+w== - -natural-compare@^1.4.0: - version "1.4.0" - resolved "https://registry.yarnpkg.com/natural-compare/-/natural-compare-1.4.0.tgz#4abebfeed7541f2c27acfb29bdbbd15c8d5ba4f7" - integrity sha512-OWND8ei3VtNC9h7V60qff3SVobHr996CTwgxubgyQYEpg290h9J0buyECNNJexkFm5sOajh5G116RYA1c8ZMSw== - -normalize-path@^3.0.0, normalize-path@~3.0.0: - version "3.0.0" - resolved "https://registry.yarnpkg.com/normalize-path/-/normalize-path-3.0.0.tgz#0dcd69ff23a1c9b11fd0978316644a0388216a65" - integrity sha512-6eZs5Ls3WtCisHWp9S2GUy8dqkpGi4BVSz3GaqiE6ezub0512ESztXUwUB6C6IKbQkY2Pnb/mD4WYojCRwcwLA== - -once@^1.3.0: - version "1.4.0" - resolved "https://registry.yarnpkg.com/once/-/once-1.4.0.tgz#583b1aa775961d4b113ac17d9c50baef9dd76bd1" - integrity sha512-lNaJgI+2Q5URQBkccEKHTQOPaXdUxnZZElQTZY0MFUAuaEqe1E+Nyvgdz/aIyNi6Z9MzO5dv1H8n58/GELp3+w== - dependencies: - wrappy "1" - -optionator@^0.9.1: - version "0.9.1" - resolved "https://registry.yarnpkg.com/optionator/-/optionator-0.9.1.tgz#4f236a6373dae0566a6d43e1326674f50c291499" - integrity sha512-74RlY5FCnhq4jRxVUPKDaRwrVNXMqsGsiW6AJw4XK8hmtm10wC0ypZBLw5IIp85NZMr91+qd1RvvENwg7jjRFw== - dependencies: - deep-is "^0.1.3" - fast-levenshtein "^2.0.6" - levn "^0.4.1" - prelude-ls "^1.2.1" - type-check "^0.4.0" - word-wrap "^1.2.3" - -p-limit@^3.0.2: - version "3.1.0" - resolved "https://registry.yarnpkg.com/p-limit/-/p-limit-3.1.0.tgz#e1daccbe78d0d1388ca18c64fea38e3e57e3706b" - integrity sha512-TYOanM3wGwNGsZN2cVTYPArw454xnXj5qmWF1bEoAc4+cU/ol7GVh7odevjp1FNHduHc3KZMcFduxU5Xc6uJRQ== - dependencies: - yocto-queue "^0.1.0" - -p-locate@^5.0.0: - version "5.0.0" - resolved "https://registry.yarnpkg.com/p-locate/-/p-locate-5.0.0.tgz#83c8315c6785005e3bd021839411c9e110e6d834" - integrity sha512-LaNjtRWUBY++zB5nE/NwcaoMylSPk+S+ZHNB1TzdbMJMny6dynpAGt7X/tl/QYq3TIeE6nxHppbo2LGymrG5Pw== - dependencies: - p-limit "^3.0.2" - -parent-module@^1.0.0: - version "1.0.1" - resolved "https://registry.yarnpkg.com/parent-module/-/parent-module-1.0.1.tgz#691d2709e78c79fae3a156622452d00762caaaa2" - integrity sha512-GQ2EWRpQV8/o+Aw8YqtfZZPfNRWZYkbidE9k5rpl/hC3vtHHBfGm2Ifi6qWV+coDGkrUKZAxE3Lot5kcsRlh+g== - dependencies: - callsites "^3.0.0" - -path-exists@^4.0.0: - version "4.0.0" - resolved "https://registry.yarnpkg.com/path-exists/-/path-exists-4.0.0.tgz#513bdbe2d3b95d7762e8c1137efa195c6c61b5b3" - integrity sha512-ak9Qy5Q7jYb2Wwcey5Fpvg2KoAc/ZIhLSLOSBmRmygPsGwkVVt0fZa0qrtMz+m6tJTAHfZQ8FnmB4MG4LWy7/w== - -path-is-absolute@^1.0.0: - version "1.0.1" - resolved "https://registry.yarnpkg.com/path-is-absolute/-/path-is-absolute-1.0.1.tgz#174b9268735534ffbc7ace6bf53a5a9e1b5c5f5f" - integrity sha512-AVbw3UJ2e9bq64vSaS9Am0fje1Pa8pbGqTTsmXfaIiMpnr5DlDhfJOuLj9Sf95ZPVDAUerDfEk88MPmPe7UCQg== - -path-key@^3.1.0: - version "3.1.1" - resolved "https://registry.yarnpkg.com/path-key/-/path-key-3.1.1.tgz#581f6ade658cbba65a0d3380de7753295054f375" - integrity sha512-ojmeN0qd+y0jszEtoY48r0Peq5dwMEkIlCOu6Q5f41lfkswXuKtYrhgoTpLnyIcHm24Uhqx+5Tqm2InSwLhE6Q== - -path-type@^4.0.0: - version "4.0.0" - resolved "https://registry.yarnpkg.com/path-type/-/path-type-4.0.0.tgz#84ed01c0a7ba380afe09d90a8c180dcd9d03043b" - integrity sha512-gDKb8aZMDeD/tZWs9P6+q0J9Mwkdl6xMV8TjnGP3qJVJ06bdMgkbBlLU8IdfOsIsFz2BW1rNVT3XuNEl8zPAvw== - -picomatch@^2.0.4, picomatch@^2.2.1, picomatch@^2.3.1: - version "2.3.1" - resolved "https://registry.yarnpkg.com/picomatch/-/picomatch-2.3.1.tgz#3ba3833733646d9d3e4995946c1365a67fb07a42" - integrity sha512-JU3teHTNjmE2VCGFzuY8EXzCDVwEqB2a8fsIvwaStHhAWJEeVd1o1QD80CU6+ZdEXXSLbSsuLwJjkCBWqRQUVA== - -prelude-ls@^1.2.1: - version "1.2.1" - resolved "https://registry.yarnpkg.com/prelude-ls/-/prelude-ls-1.2.1.tgz#debc6489d7a6e6b0e7611888cec880337d316396" - integrity sha512-vkcDPrRZo1QZLbn5RLGPpg/WmIQ65qoWWhcGKf/b5eplkkarX0m9z8ppCat4mlOqUsWpyNuYgO3VRyrYHSzX5g== - -process-nextick-args@~2.0.0: - version "2.0.1" - resolved "https://registry.yarnpkg.com/process-nextick-args/-/process-nextick-args-2.0.1.tgz#7820d9b16120cc55ca9ae7792680ae7dba6d7fe2" - integrity sha512-3ouUOpQhtgrbOa17J7+uxOTpITYWaGP7/AhoR3+A+/1e9skrzelGi/dXzEYyvbxubEF6Wn2ypscTKiKJFFn1ag== - -punycode@^2.1.0: - version "2.1.1" - resolved "https://registry.yarnpkg.com/punycode/-/punycode-2.1.1.tgz#b58b010ac40c22c5657616c8d2c2c02c7bf479ec" - integrity sha512-XRsRjdf+j5ml+y/6GKHPZbrF/8p2Yga0JPtdqTIY2Xe5ohJPD9saDJJLPvp9+NSBprVvevdXZybnj2cv8OEd0A== - -queue-microtask@^1.2.2: - version "1.2.3" - resolved "https://registry.yarnpkg.com/queue-microtask/-/queue-microtask-1.2.3.tgz#4929228bbc724dfac43e0efb058caf7b6cfb6243" - integrity sha512-NuaNSa6flKT5JaSYQzJok04JzTL1CA6aGhv5rfLW3PgqA+M2ChpZQnAC8h8i4ZFkBS8X5RqkDBHA7r4hej3K9A== - -randombytes@^2.1.0: - version "2.1.0" - resolved "https://registry.yarnpkg.com/randombytes/-/randombytes-2.1.0.tgz#df6f84372f0270dc65cdf6291349ab7a473d4f2a" - integrity sha512-vYl3iOX+4CKUWuxGi9Ukhie6fsqXqS9FE2Zaic4tNFD2N2QQaXOMFbuKK4QmDHC0JO6B1Zp41J0LpT0oR68amQ== - dependencies: - safe-buffer "^5.1.0" - -readable-stream@^2.0.2, readable-stream@~2.3.6: - version "2.3.7" - resolved "https://registry.yarnpkg.com/readable-stream/-/readable-stream-2.3.7.tgz#1eca1cf711aef814c04f62252a36a62f6cb23b57" - integrity sha512-Ebho8K4jIbHAxnuxi7o42OrZgF/ZTNcsZj6nRKyUmkhLFq8CHItp/fy6hQZuZmP/n3yZ9VBUbp4zz/mX8hmYPw== - dependencies: - core-util-is "~1.0.0" - inherits "~2.0.3" - isarray "~1.0.0" - process-nextick-args "~2.0.0" - safe-buffer "~5.1.1" - string_decoder "~1.1.1" - util-deprecate "~1.0.1" - -readdirp@~3.6.0: - version "3.6.0" - resolved "https://registry.yarnpkg.com/readdirp/-/readdirp-3.6.0.tgz#74a370bd857116e245b29cc97340cd431a02a6c7" - integrity sha512-hOS089on8RduqdbhvQ5Z37A0ESjsqz6qnRcffsMU3495FuTdqSm+7bhJ29JvIOsBDEEnan5DPu9t3To9VRlMzA== - dependencies: - picomatch "^2.2.1" - -regexpp@^3.2.0: - version "3.2.0" - resolved "https://registry.yarnpkg.com/regexpp/-/regexpp-3.2.0.tgz#0425a2768d8f23bad70ca4b90461fa2f1213e1b2" - integrity sha512-pq2bWo9mVD43nbts2wGv17XLiNLya+GklZ8kaDLV2Z08gDCsGpnKn9BFMepvWuHCbyVvY7J5o5+BVvoQbmlJLg== - -require-directory@^2.1.1: - version "2.1.1" - resolved "https://registry.yarnpkg.com/require-directory/-/require-directory-2.1.1.tgz#8c64ad5fd30dab1c976e2344ffe7f792a6a6df42" - integrity sha512-fGxEI7+wsG9xrvdjsrlmL22OMTTiHRwAMroiEeMgq8gzoLC/PQr7RsRDSTLUg/bZAZtF+TVIkHc6/4RIKrui+Q== - -resolve-from@^4.0.0: - version "4.0.0" - resolved "https://registry.yarnpkg.com/resolve-from/-/resolve-from-4.0.0.tgz#4abcd852ad32dd7baabfe9b40e00a36db5f392e6" - integrity sha512-pb/MYmXstAkysRFx8piNI1tGFNQIFA3vkE3Gq4EuA1dF6gHp/+vgZqsCGJapvy8N3Q+4o7FwvquPJcnZ7RYy4g== - -reusify@^1.0.4: - version "1.0.4" - resolved "https://registry.yarnpkg.com/reusify/-/reusify-1.0.4.tgz#90da382b1e126efc02146e90845a88db12925d76" - integrity sha512-U9nH88a3fc/ekCF1l0/UP1IosiuIjyTh7hBvXVMHYgVcfGvt897Xguj2UOLDeI5BG2m7/uwyaLVT6fbtCwTyzw== - -rimraf@2: - version "2.7.1" - resolved "https://registry.yarnpkg.com/rimraf/-/rimraf-2.7.1.tgz#35797f13a7fdadc566142c29d4f07ccad483e3ec" - integrity sha512-uWjbaKIK3T1OSVptzX7Nl6PvQ3qAGtKEtVRjRuazjfL3Bx5eI409VZSqgND+4UNnmzLVdPj9FqFJNPqBZFve4w== - dependencies: - glob "^7.1.3" - -rimraf@^3.0.2: - version "3.0.2" - resolved "https://registry.yarnpkg.com/rimraf/-/rimraf-3.0.2.tgz#f1a5402ba6220ad52cc1282bac1ae3aa49fd061a" - integrity sha512-JZkJMZkAGFFPP2YqXZXPbMlMBgsxzE8ILs4lMIX/2o0L9UBw9O/Y3o6wFw/i9YLapcUJWwqbi3kdxIPdC62TIA== - dependencies: - glob "^7.1.3" - -run-parallel@^1.1.9: - version "1.2.0" - resolved "https://registry.yarnpkg.com/run-parallel/-/run-parallel-1.2.0.tgz#66d1368da7bdf921eb9d95bd1a9229e7f21a43ee" - integrity sha512-5l4VyZR86LZ/lDxZTR6jqL8AFE2S0IFLMP26AbjsLVADxHdhB/c0GUsH+y39UfCi3dzz8OlQuPmnaJOMoDHQBA== - dependencies: - queue-microtask "^1.2.2" - -safe-buffer@^5.1.0: - version "5.2.1" - resolved "https://registry.yarnpkg.com/safe-buffer/-/safe-buffer-5.2.1.tgz#1eaf9fa9bdb1fdd4ec75f58f9cdb4e6b7827eec6" - integrity sha512-rp3So07KcdmmKbGvgaNxQSJr7bGVSVk5S9Eq1F+ppbRo70+YeaDxkw5Dd8NPN+GD6bjnYm2VuPuCXmpuYvmCXQ== - -safe-buffer@~5.1.0, safe-buffer@~5.1.1: - version "5.1.2" - resolved "https://registry.yarnpkg.com/safe-buffer/-/safe-buffer-5.1.2.tgz#991ec69d296e0313747d59bdfd2b745c35f8828d" - integrity sha512-Gd2UZBJDkXlY7GbJxfsE8/nvKkUEU1G38c1siN6QP6a9PT9MmHB8GnpscSmMJSoF8LOIrt8ud/wPtojys4G6+g== - -semver@^7.3.7: - version "7.3.7" - resolved "https://registry.yarnpkg.com/semver/-/semver-7.3.7.tgz#12c5b649afdbf9049707796e22a4028814ce523f" - integrity sha512-QlYTucUYOews+WeEujDoEGziz4K6c47V/Bd+LjSSYcA94p+DmINdf7ncaUinThfvZyu13lN9OY1XDxt8C0Tw0g== - dependencies: - lru-cache "^6.0.0" - -serialize-javascript@6.0.0: - version "6.0.0" - resolved "https://registry.yarnpkg.com/serialize-javascript/-/serialize-javascript-6.0.0.tgz#efae5d88f45d7924141da8b5c3a7a7e663fefeb8" - integrity sha512-Qr3TosvguFt8ePWqsvRfrKyQXIiW+nGbYpy8XK24NQHE83caxWt+mIymTT19DGFbNWNLfEwsrkSmN64lVWB9ag== - dependencies: - randombytes "^2.1.0" - -setimmediate@~1.0.4: - version "1.0.5" - resolved "https://registry.yarnpkg.com/setimmediate/-/setimmediate-1.0.5.tgz#290cbb232e306942d7d7ea9b83732ab7856f8285" - integrity sha512-MATJdZp8sLqDl/68LfQmbP8zKPLQNV6BIZoIgrscFDQ+RsvK/BxeDQOgyxKKoh0y/8h3BqVFnCqQ/gd+reiIXA== - -shebang-command@^2.0.0: - version "2.0.0" - resolved "https://registry.yarnpkg.com/shebang-command/-/shebang-command-2.0.0.tgz#ccd0af4f8835fbdc265b82461aaf0c36663f34ea" - integrity sha512-kHxr2zZpYtdmrN1qDjrrX/Z1rR1kG8Dx+gkpK1G4eXmvXswmcE1hTWBWYUzlraYw1/yZp6YuDY77YtvbN0dmDA== - dependencies: - shebang-regex "^3.0.0" - -shebang-regex@^3.0.0: - version "3.0.0" - resolved "https://registry.yarnpkg.com/shebang-regex/-/shebang-regex-3.0.0.tgz#ae16f1644d873ecad843b0307b143362d4c42172" - integrity sha512-7++dFhtcx3353uBaq8DDR4NuxBetBzC7ZQOhmTQInHEd6bSrXdiEyzCvG07Z44UYdLShWUyXt5M/yhz8ekcb1A== - -slash@^3.0.0: - version "3.0.0" - resolved "https://registry.yarnpkg.com/slash/-/slash-3.0.0.tgz#6539be870c165adbd5240220dbe361f1bc4d4634" - integrity sha512-g9Q1haeby36OSStwb4ntCGGGaKsaVSjQ68fBxoQcutl5fS1vuY18H3wSt3jFyFtrkx+Kz0V1G85A4MyAdDMi2Q== - -string-width@^4.1.0, string-width@^4.2.0: - version "4.2.3" - resolved "https://registry.yarnpkg.com/string-width/-/string-width-4.2.3.tgz#269c7117d27b05ad2e536830a8ec895ef9c6d010" - integrity sha512-wKyQRQpjJ0sIp62ErSZdGsjMJWsap5oRNihHhu6G7JVO/9jIB6UyevL+tXuOqrng8j/cxKTWyWUwvSTriiZz/g== - dependencies: - emoji-regex "^8.0.0" - is-fullwidth-code-point "^3.0.0" - strip-ansi "^6.0.1" - -string_decoder@~1.1.1: - version "1.1.1" - resolved "https://registry.yarnpkg.com/string_decoder/-/string_decoder-1.1.1.tgz#9cf1611ba62685d7030ae9e4ba34149c3af03fc8" - integrity sha512-n/ShnvDi6FHbbVfviro+WojiFzv+s8MPMHBczVePfUpDJLwoLT0ht1l4YwBCbi8pJAveEEdnkHyPyTP/mzRfwg== - dependencies: - safe-buffer "~5.1.0" - -strip-ansi@^6.0.0, strip-ansi@^6.0.1: - version "6.0.1" - resolved "https://registry.yarnpkg.com/strip-ansi/-/strip-ansi-6.0.1.tgz#9e26c63d30f53443e9489495b2105d37b67a85d9" - integrity sha512-Y38VPSHcqkFrCpFnQ9vuSXmquuv5oXOKpGeT6aGrr3o3Gc9AlVa6JBfUSOCnbxGGZF+/0ooI7KrPuUSztUdU5A== - dependencies: - ansi-regex "^5.0.1" - -strip-json-comments@3.1.1, strip-json-comments@^3.1.0, strip-json-comments@^3.1.1: - version "3.1.1" - resolved "https://registry.yarnpkg.com/strip-json-comments/-/strip-json-comments-3.1.1.tgz#31f1281b3832630434831c310c01cccda8cbe006" - integrity sha512-6fPc+R4ihwqP6N/aIv2f1gMH8lOVtWQHoqC4yK6oSDVVocumAsfCqjkXnqiYMhmMwS/mEHLp7Vehlt3ql6lEig== - -supports-color@8.1.1: - version "8.1.1" - resolved "https://registry.yarnpkg.com/supports-color/-/supports-color-8.1.1.tgz#cd6fc17e28500cff56c1b86c0a7fd4a54a73005c" - integrity sha512-MpUEN2OodtUzxvKQl72cUF7RQ5EiHsGvSsVG0ia9c5RbWGL2CI4C7EpPS8UTBIplnlzZiNuV56w+FuNxy3ty2Q== - dependencies: - has-flag "^4.0.0" - -supports-color@^7.1.0: - version "7.2.0" - resolved "https://registry.yarnpkg.com/supports-color/-/supports-color-7.2.0.tgz#1b7dcdcb32b8138801b3e478ba6a51caa89648da" - integrity sha512-qpCAvRl9stuOHveKsn7HncJRvv501qIacKzQlO/+Lwxc9+0q2wLyv4Dfvt80/DPn2pqOBsJdDiogXGR9+OvwRw== - dependencies: - has-flag "^4.0.0" - -text-table@^0.2.0: - version "0.2.0" - resolved "https://registry.yarnpkg.com/text-table/-/text-table-0.2.0.tgz#7f5ee823ae805207c00af2df4a84ec3fcfa570b4" - integrity sha512-N+8UisAXDGk8PFXP4HAzVR9nbfmVJ3zYLAWiTIoqC5v5isinhr+r5uaO8+7r3BMfuNIufIsA7RdpVgacC2cSpw== - -to-regex-range@^5.0.1: - version "5.0.1" - resolved "https://registry.yarnpkg.com/to-regex-range/-/to-regex-range-5.0.1.tgz#1648c44aae7c8d988a326018ed72f5b4dd0392e4" - integrity sha512-65P7iz6X5yEr1cwcgvQxbbIw7Uk3gOy5dIdtZ4rDveLqhrdJP+Li/Hx6tyK0NEb+2GCyneCMJiGqrADCSNk8sQ== - dependencies: - is-number "^7.0.0" - -"traverse@>=0.3.0 <0.4": - version "0.3.9" - resolved "https://registry.yarnpkg.com/traverse/-/traverse-0.3.9.tgz#717b8f220cc0bb7b44e40514c22b2e8bbc70d8b9" - integrity sha512-iawgk0hLP3SxGKDfnDJf8wTz4p2qImnyihM5Hh/sGvQ3K37dPi/w8sRhdNIxYA1TwFwc5mDhIJq+O0RsvXBKdQ== - -tslib@^1.8.1: - version "1.14.1" - resolved "https://registry.yarnpkg.com/tslib/-/tslib-1.14.1.tgz#cf2d38bdc34a134bcaf1091c41f6619e2f672d00" - integrity sha512-Xni35NKzjgMrwevysHTCArtLDpPvye8zV/0E4EyYn43P7/7qvQwPh9BGkHewbMulVntbigmcT7rdX3BNo9wRJg== - -tsutils@^3.21.0: - version "3.21.0" - resolved "https://registry.yarnpkg.com/tsutils/-/tsutils-3.21.0.tgz#b48717d394cea6c1e096983eed58e9d61715b623" - integrity sha512-mHKK3iUXL+3UF6xL5k0PEhKRUBKPBCv/+RkEOpjRWxxx27KKRBmmA60A9pgOUvMi8GKhRMPEmjBRPzs2W7O1OA== - dependencies: - tslib "^1.8.1" - -type-check@^0.4.0, type-check@~0.4.0: - version "0.4.0" - resolved "https://registry.yarnpkg.com/type-check/-/type-check-0.4.0.tgz#07b8203bfa7056c0657050e3ccd2c37730bab8f1" - integrity sha512-XleUoc9uwGXqjWwXaUTZAmzMcFZ5858QA2vvx1Ur5xIcixXIP+8LnFDgRplU30us6teqdlskFfu+ae4K79Ooew== - dependencies: - prelude-ls "^1.2.1" - -type-fest@^0.20.2: - version "0.20.2" - resolved "https://registry.yarnpkg.com/type-fest/-/type-fest-0.20.2.tgz#1bf207f4b28f91583666cb5fbd327887301cd5f4" - integrity sha512-Ne+eE4r0/iWnpAxD852z3A+N0Bt5RN//NjJwRd2VFHEmrywxf5vsZlh4R6lixl6B+wz/8d+maTSAkN1FIkI3LQ== - -typescript@^4.7.2: - version "4.7.3" - resolved "https://registry.yarnpkg.com/typescript/-/typescript-4.7.3.tgz#8364b502d5257b540f9de4c40be84c98e23a129d" - integrity sha512-WOkT3XYvrpXx4vMMqlD+8R8R37fZkjyLGlxavMc4iB8lrl8L0DeTcHbYgw/v0N/z9wAFsgBhcsF0ruoySS22mA== - -unzipper@^0.10.11: - version "0.10.11" - resolved "https://registry.yarnpkg.com/unzipper/-/unzipper-0.10.11.tgz#0b4991446472cbdb92ee7403909f26c2419c782e" - integrity sha512-+BrAq2oFqWod5IESRjL3S8baohbevGcVA+teAIOYWM3pDVdseogqbzhhvvmiyQrUNKFUnDMtELW3X8ykbyDCJw== - dependencies: - big-integer "^1.6.17" - binary "~0.3.0" - bluebird "~3.4.1" - buffer-indexof-polyfill "~1.0.0" - duplexer2 "~0.1.4" - fstream "^1.0.12" - graceful-fs "^4.2.2" - listenercount "~1.0.1" - readable-stream "~2.3.6" - setimmediate "~1.0.4" - -uri-js@^4.2.2: - version "4.4.1" - resolved "https://registry.yarnpkg.com/uri-js/-/uri-js-4.4.1.tgz#9b1a52595225859e55f669d928f88c6c57f2a77e" - integrity sha512-7rKUyy33Q1yc98pQ1DAmLtwX109F7TIfWlW1Ydo8Wl1ii1SeHieeh0HHfPeL2fMXK6z0s8ecKs9frCuLJvndBg== - dependencies: - punycode "^2.1.0" - -util-deprecate@~1.0.1: - version "1.0.2" - resolved "https://registry.yarnpkg.com/util-deprecate/-/util-deprecate-1.0.2.tgz#450d4dc9fa70de732762fbd2d4a28981419a0ccf" - integrity sha512-EPD5q1uXyFxJpCrLnCc1nHnq3gOa6DZBocAIiI2TaSCA7VCJ1UJDMagCzIkXNsUYfD1daK//LTEQ8xiIbrHtcw== - -v8-compile-cache@^2.0.3: - version "2.3.0" - resolved "https://registry.yarnpkg.com/v8-compile-cache/-/v8-compile-cache-2.3.0.tgz#2de19618c66dc247dcfb6f99338035d8245a2cee" - integrity sha512-l8lCEmLcLYZh4nbunNZvQCJc5pv7+RCwa8q/LdUx8u7lsWvPDKmpodJAJNwkAhJC//dFY48KuIEmjtd4RViDrA== - -which@^2.0.1: - version "2.0.2" - resolved "https://registry.yarnpkg.com/which/-/which-2.0.2.tgz#7c6a8dd0a636a0327e10b59c9286eee93f3f51b1" - integrity sha512-BLI3Tl1TW3Pvl70l3yq3Y64i+awpwXqsGBYWkkqMtnbXgrMD+yj7rhW0kuEDxzJaYXGjEW5ogapKNMEKNMjibA== - dependencies: - isexe "^2.0.0" - -word-wrap@^1.2.3: - version "1.2.3" - resolved "https://registry.yarnpkg.com/word-wrap/-/word-wrap-1.2.3.tgz#610636f6b1f703891bd34771ccb17fb93b47079c" - integrity sha512-Hz/mrNwitNRh/HUAtM/VT/5VH+ygD6DV7mYKZAtHOrbs8U7lvPS6xf7EJKMF0uW1KJCl0H701g3ZGus+muE5vQ== - -workerpool@6.2.1: - version "6.2.1" - resolved "https://registry.yarnpkg.com/workerpool/-/workerpool-6.2.1.tgz#46fc150c17d826b86a008e5a4508656777e9c343" - integrity sha512-ILEIE97kDZvF9Wb9f6h5aXK4swSlKGUcOEGiIYb2OOu/IrDU9iwj0fD//SsA6E5ibwJxpEvhullJY4Sl4GcpAw== - -wrap-ansi@^7.0.0: - version "7.0.0" - resolved "https://registry.yarnpkg.com/wrap-ansi/-/wrap-ansi-7.0.0.tgz#67e145cff510a6a6984bdf1152911d69d2eb9e43" - integrity sha512-YVGIj2kamLSTxw6NsZjoBxfSwsn0ycdesmc4p+Q21c5zPuZ1pl+NfxVdxPtdHvmNVOQ6XSYG4AUtyt/Fi7D16Q== - dependencies: - ansi-styles "^4.0.0" - string-width "^4.1.0" - strip-ansi "^6.0.0" - -wrappy@1: - version "1.0.2" - resolved "https://registry.yarnpkg.com/wrappy/-/wrappy-1.0.2.tgz#b5243d8f3ec1aa35f1364605bc0d1036e30ab69f" - integrity sha512-l4Sp/DRseor9wL6EvV2+TuQn63dMkPjZ/sp9XkghTEbV9KlPS1xUsZ3u7/IQO4wxtcFB4bgpQPRcR3QCvezPcQ== - -y18n@^5.0.5: - version "5.0.8" - resolved "https://registry.yarnpkg.com/y18n/-/y18n-5.0.8.tgz#7f4934d0f7ca8c56f95314939ddcd2dd91ce1d55" - integrity sha512-0pfFzegeDWJHJIAmTLRP2DwHjdF5s7jo9tuztdQxAhINCdvS+3nGINqPd00AphqJR/0LhANUS6/+7SCb98YOfA== - -yallist@^4.0.0: - version "4.0.0" - resolved "https://registry.yarnpkg.com/yallist/-/yallist-4.0.0.tgz#9bb92790d9c0effec63be73519e11a35019a3a72" - integrity sha512-3wdGidZyq5PB084XLES5TpOSRA3wjXAlIWMhum2kRcv/41Sn2emQ0dycQW4uZXLejwKvg6EsvbdlVL+FYEct7A== - -yargs-parser@20.2.4: - version "20.2.4" - resolved "https://registry.yarnpkg.com/yargs-parser/-/yargs-parser-20.2.4.tgz#b42890f14566796f85ae8e3a25290d205f154a54" - integrity sha512-WOkpgNhPTlE73h4VFAFsOnomJVaovO8VqLDzy5saChRBFQFBoMYirowyW+Q9HB4HFF4Z7VZTiG3iSzJJA29yRA== - -yargs-parser@^20.2.2: - version "20.2.9" - resolved "https://registry.yarnpkg.com/yargs-parser/-/yargs-parser-20.2.9.tgz#2eb7dc3b0289718fc295f362753845c41a0c94ee" - integrity sha512-y11nGElTIV+CT3Zv9t7VKl+Q3hTQoT9a1Qzezhhl6Rp21gJ/IVTW7Z3y9EWXhuUBC2Shnf+DX0antecpAwSP8w== - -yargs-unparser@2.0.0: - version "2.0.0" - resolved "https://registry.yarnpkg.com/yargs-unparser/-/yargs-unparser-2.0.0.tgz#f131f9226911ae5d9ad38c432fe809366c2325eb" - integrity sha512-7pRTIA9Qc1caZ0bZ6RYRGbHJthJWuakf+WmHK0rVeLkNrrGhfoabBNdue6kdINI6r4if7ocq9aD/n7xwKOdzOA== - dependencies: - camelcase "^6.0.0" - decamelize "^4.0.0" - flat "^5.0.2" - is-plain-obj "^2.1.0" - -yargs@16.2.0: - version "16.2.0" - resolved "https://registry.yarnpkg.com/yargs/-/yargs-16.2.0.tgz#1c82bf0f6b6a66eafce7ef30e376f49a12477f66" - integrity sha512-D1mvvtDG0L5ft/jGWkLpG1+m0eQxOfaBvTNELraWj22wSVUMWxZUvYgJYcKh6jGGIkJFhH4IZPQhR4TKpc8mBw== - dependencies: - cliui "^7.0.2" - escalade "^3.1.1" - get-caller-file "^2.0.5" - require-directory "^2.1.1" - string-width "^4.2.0" - y18n "^5.0.5" - yargs-parser "^20.2.2" - -yocto-queue@^0.1.0: - version "0.1.0" - resolved "https://registry.yarnpkg.com/yocto-queue/-/yocto-queue-0.1.0.tgz#0294eb3dee05028d31ee1a5fa2c556a6aaf10a1b" - integrity sha512-rVksvsnNCdJ/ohGc6xgPwyN8eheCxsiLM8mxuE/t/mOVqJewPuO1miLpTHQiRgTKCLexL4MeAFVagts7HmNZ2Q== +// should be empty, see https://github.com/microsoft/vscode-vsce/issues/300 diff --git a/yarn.lock b/yarn.lock index b1c89aa7..2ce67d62 100644 --- a/yarn.lock +++ b/yarn.lock @@ -5570,6 +5570,16 @@ axobject-query@^2.2.0: resolved "https://registry.yarnpkg.com/axobject-query/-/axobject-query-2.2.0.tgz#943d47e10c0b704aa42275e20edf3722648989be" integrity sha512-Td525n+iPOOyUQIeBfcASuG6uJsDOITl7Mds5gFyerkWiX7qhUTdYUBlSgNMyVqtSJqwpt1kXGLdUt6SykLMRA== +azure-devops-node-api@^7.2.0: + version "7.2.0" + resolved "https://registry.yarnpkg.com/azure-devops-node-api/-/azure-devops-node-api-7.2.0.tgz#131d4e01cf12ebc6e45569b5e0c5c249e4114d6d" + integrity sha512-pMfGJ6gAQ7LRKTHgiRF+8iaUUeGAI0c8puLaqHLc7B8AR7W6GJLozK9RFeUHFjEGybC9/EB3r67WPd7e46zQ8w== + dependencies: + os "0.1.1" + tunnel "0.0.4" + typed-rest-client "1.2.0" + underscore "1.8.3" + babel-code-frame@^6.26.0: version "6.26.0" resolved "https://registry.yarnpkg.com/babel-code-frame/-/babel-code-frame-6.26.0.tgz#63fd43f7dc1e3bb7ce35947db8fe369a3f58c74b" @@ -6147,6 +6157,11 @@ bser@2.1.1: dependencies: node-int64 "^0.4.0" +buffer-crc32@~0.2.3: + version "0.2.13" + resolved "https://registry.yarnpkg.com/buffer-crc32/-/buffer-crc32-0.2.13.tgz#0d333e3f00eac50aa1454abd30ef8c2a5d9a7242" + integrity sha512-VO9Ht/+p3SN7SKWqcrgEzjGbRSJYTx+Q1pTQC0wrWqHx0vpJraQ6GtHx8tvcg1rlK1byhU5gccxgOgj7B0TDkQ== + buffer-from@^1.0.0: version "1.1.2" resolved "https://registry.yarnpkg.com/buffer-from/-/buffer-from-1.1.2.tgz#2b146a6fd72e80b4f55d255f35ed59a3a9a41bd5" @@ -6384,7 +6399,7 @@ chalk@^1.1.3: strip-ansi "^3.0.0" supports-color "^2.0.0" -chalk@^2.0.0, chalk@^2.4.1: +chalk@^2.0.0, chalk@^2.4.1, chalk@^2.4.2: version "2.4.2" resolved "https://registry.yarnpkg.com/chalk/-/chalk-2.4.2.tgz#cd42541677a54333cf541a49108c1432b44c9424" integrity sha512-Mti+f9lpJNcwF4tWV8/OrTTtF1gZi+f8FqlyAdouralcFWFQWF2+NgCHShjkCb+IFBLq9buZwE1xckQU4peSuQ== @@ -6483,7 +6498,7 @@ cheerio@^0.22.0: lodash.reject "^4.4.0" lodash.some "^4.4.0" -cheerio@^1.0.0-rc.11: +cheerio@^1.0.0-rc.1, cheerio@^1.0.0-rc.11: version "1.0.0-rc.11" resolved "https://registry.yarnpkg.com/cheerio/-/cheerio-1.0.0-rc.11.tgz#1be84be1a126958366bcc57a11648cd9b30a60c2" integrity sha512-bQwNaDIBKID5ts/DsdhxrjqFXYfLw4ste+wMKqWA8DyKcS4qwsPP4Bk8ZNaTJjvpiX/qW3BT4sU7d6Bh5i+dag== @@ -6765,7 +6780,7 @@ comma-separated-tokens@^1.0.0: resolved "https://registry.yarnpkg.com/comma-separated-tokens/-/comma-separated-tokens-1.0.8.tgz#632b80b6117867a158f1080ad498b2fbe7e3f5ea" integrity sha512-GHuDRO12Sypu2cV70d1dkA2EUmXHgntrzbpvOB+Qy+49ypNfGgFQIC2fhhXbnyrJRynDCAARsT7Ou0M6hirpfw== -commander@2, commander@^2.19.0, commander@^2.20.0: +commander@2, commander@^2.19.0, commander@^2.20.0, commander@^2.8.1: version "2.20.3" resolved "https://registry.yarnpkg.com/commander/-/commander-2.20.3.tgz#fd485e84c03eb4881c20722ba48035e8531aeb33" integrity sha512-GpVkmM8vF2vQUkj2LvZmD35JxeJOLCwJ9cUkugyk2nuhbv3+mJvpLYYt+0+USMxE+oj+ey/lJEnhZw75x/OMcQ== @@ -7758,6 +7773,11 @@ delegates@^1.0.0: resolved "https://registry.yarnpkg.com/delegates/-/delegates-1.0.0.tgz#84c6e159b81904fdca59a0ef44cd870d31250f9a" integrity sha512-bd2L678uiWATM6m5Z1VzNCErI3jiGzt6HGY8OVICs40JQq/HALfbyNJmp0UDakEY4pMMaN0Ly5om/B1VI/+xfQ== +denodeify@^1.2.1: + version "1.2.1" + resolved "https://registry.yarnpkg.com/denodeify/-/denodeify-1.2.1.tgz#3a36287f5034e699e7577901052c2e6c94251631" + integrity sha512-KNTihKNmQENUZeKu5fzfpzRqR5S2VMp4gl9RFHiWzj9DfvYQPMJ6XHKNaQxaGCXwPk6y9yme3aUoaiAe+KX+vg== + depd@2.0.0: version "2.0.0" resolved "https://registry.yarnpkg.com/depd/-/depd-2.0.0.tgz#b696163cc757560d09cf22cc8fad1571b79e76df" @@ -7840,7 +7860,7 @@ detective@^5.2.1: defined "^1.0.0" minimist "^1.2.6" -didyoumean@^1.2.2: +didyoumean@^1.2.1, didyoumean@^1.2.2: version "1.2.2" resolved "https://registry.yarnpkg.com/didyoumean/-/didyoumean-1.2.2.tgz#989346ffe9e839b4555ecf5666edea0d3e8ad037" integrity sha512-gxtyfqMg7GKyhQmb056K7M3xszy/myH8w+B4RT+QXBQsvAOdc3XymqDDPHx1BgPgsdAA5SIifona89YtRATDzw== @@ -8940,6 +8960,13 @@ fbjs@^3.0.0, fbjs@^3.0.1: setimmediate "^1.0.5" ua-parser-js "^0.7.30" +fd-slicer@~1.1.0: + version "1.1.0" + resolved "https://registry.yarnpkg.com/fd-slicer/-/fd-slicer-1.1.0.tgz#25c7c89cb1f9077f8891bbe61d8f390eae256f1e" + integrity sha512-cE1qsB/VwyQozZ+q1dGxR8LBYNZeofhEdUNGSMbQD3Gw2lAzX9Zb3uIU6Ebc/Fmyjo9AWWfnn0AUCHqtevs/8g== + dependencies: + pend "~1.2.0" + feed@^4.2.2: version "4.2.2" resolved "https://registry.yarnpkg.com/feed/-/feed-4.2.2.tgz#865783ef6ed12579e2c44bbef3c9113bc4956a7e" @@ -9435,7 +9462,7 @@ glob-to-regexp@^0.4.1: resolved "https://registry.yarnpkg.com/glob-to-regexp/-/glob-to-regexp-0.4.1.tgz#c75297087c851b9a578bd217dd59a92f59fe546e" integrity sha512-lkX1HJXwyMcprw/5YUZc2s7DrpAiHB21/V+E1rHUrVNokkvB6bqMzT0VfV6/86ZNabt1k14YOIaT7nDvOX3Iiw== -glob@^7.0.0, glob@^7.1.1, glob@^7.1.2, glob@^7.1.3, glob@^7.1.4, glob@^7.1.6: +glob@^7.0.0, glob@^7.0.6, glob@^7.1.1, glob@^7.1.2, glob@^7.1.3, glob@^7.1.4, glob@^7.1.6: version "7.2.3" resolved "https://registry.yarnpkg.com/glob/-/glob-7.2.3.tgz#b8df0fb802bbfa8e89bd1d938b4e16578ed44f2b" integrity sha512-nFR0zLpU2YCaRxwoCJvL6UvCH2JFyFVIvwTLsIf21AuHlMskA1hhTdk+LlYJtOlYt9v6dvszD2BGRqBL+iQK9Q== @@ -11713,6 +11740,13 @@ lines-and-columns@^1.1.6: resolved "https://registry.yarnpkg.com/lines-and-columns/-/lines-and-columns-1.2.4.tgz#eca284f75d2965079309dc0ad9255abb2ebc1632" integrity sha512-7ylylesZQ/PV29jhEDl3Ufjo6ZX7gCqJr5F7PKrqc93v7fzSymt1BpwEU8nAUXs8qzzvqhbjhK5QZg6Mt/HkBg== +linkify-it@^2.0.0: + version "2.2.0" + resolved "https://registry.yarnpkg.com/linkify-it/-/linkify-it-2.2.0.tgz#e3b54697e78bf915c70a38acd78fd09e0058b1cf" + integrity sha512-GnAl/knGn+i1U/wjBz3akz2stz+HrHLsxMwHQGofCDfPvlf+gDKN58UtfmUquTY4/MXeE2x7k19KQmeoZi94Iw== + dependencies: + uc.micro "^1.0.1" + load-json-file@^1.0.0: version "1.1.0" resolved "https://registry.yarnpkg.com/load-json-file/-/load-json-file-1.1.0.tgz#956905708d58b4bab4c2261b04f59f31c99374c0" @@ -11897,7 +11931,7 @@ lodash.uniq@4.5.0, lodash.uniq@^4.5.0: resolved "https://registry.yarnpkg.com/lodash.uniq/-/lodash.uniq-4.5.0.tgz#d0225373aeb652adc1bc82e4945339a842754773" integrity sha512-xfBaXQd9ryd9dlSDvnvI0lvxfLJlYAZzXomUYzLKtUeOQvOP5piqAWuGtrhWeqaXK9hhoM/iyJc5AV+XfsX3HQ== -lodash@^4.17.15, lodash@^4.17.19, lodash@^4.17.20, lodash@^4.17.21, lodash@^4.17.4, lodash@^4.7.0: +lodash@^4.17.10, lodash@^4.17.15, lodash@^4.17.19, lodash@^4.17.20, lodash@^4.17.21, lodash@^4.17.4, lodash@^4.7.0: version "4.17.21" resolved "https://registry.yarnpkg.com/lodash/-/lodash-4.17.21.tgz#679591c564c3bffaae8454cf0b3df370c3d6911c" integrity sha512-v2kDEe57lecTulaDIuNTPy3Ry4gLGJ6Z1O3vE1krgXZNrsQ+LFTGHVxVjcXPs17LhbZVGedAJv8XZ1tvj5FvSg== @@ -12029,6 +12063,17 @@ markdown-escapes@^1.0.0: resolved "https://registry.yarnpkg.com/markdown-escapes/-/markdown-escapes-1.0.4.tgz#c95415ef451499d7602b91095f3c8e8975f78535" integrity sha512-8z4efJYk43E0upd0NbVXwgSTQs6cT3T06etieCMEg7dRbzCbxUCK/GHlX8mhHRDcp+OLlHkPKsvqQTCvsRl2cg== +markdown-it@^8.3.1: + version "8.4.2" + resolved "https://registry.yarnpkg.com/markdown-it/-/markdown-it-8.4.2.tgz#386f98998dc15a37722aa7722084f4020bdd9b54" + integrity sha512-GcRz3AWTqSUphY3vsUqQSFMbgR38a4Lh3GWlHRh/7MRwz8mcu9n2IO7HOh+bXHrR9kOPDl5RNCaEsrneb+xhHQ== + dependencies: + argparse "^1.0.7" + entities "~1.1.1" + linkify-it "^2.0.0" + mdurl "^1.0.1" + uc.micro "^1.0.5" + mathjs@^10.6.0: version "10.6.1" resolved "https://registry.yarnpkg.com/mathjs/-/mathjs-10.6.1.tgz#95b34178eed65cbf7a63d35c468ad3ac912f7ddf" @@ -12101,7 +12146,7 @@ mdn-data@2.0.4: resolved "https://registry.yarnpkg.com/mdn-data/-/mdn-data-2.0.4.tgz#699b3c38ac6f1d728091a64650b65d388502fd5b" integrity sha512-iV3XNKw06j5Q7mi6h+9vbx23Tv7JkjEVgKHW4pimwyDGWm0OIQntJJ+u1C6mg6mK1EaTv42XQ7w76yuzH7M2cA== -mdurl@^1.0.0: +mdurl@^1.0.0, mdurl@^1.0.1: version "1.0.1" resolved "https://registry.yarnpkg.com/mdurl/-/mdurl-1.0.1.tgz#fe85b2ec75a59037f2adfec100fd6c601761152e" integrity sha512-/sKlQJCBYVY9Ers9hqzKou4H6V5UWc/M59TH2dvkt+84itfnq7uFOMLpOiOS4ujvHP4etln18fmIxA5R5fll0g== @@ -12249,7 +12294,7 @@ mime-types@^2.1.12, mime-types@^2.1.27, mime-types@^2.1.30, mime-types@^2.1.31, dependencies: mime-db "1.52.0" -mime@1.6.0: +mime@1.6.0, mime@^1.3.4: version "1.6.0" resolved "https://registry.yarnpkg.com/mime/-/mime-1.6.0.tgz#32cd9e5c64553bd58d19a568af452acff04981b1" integrity sha512-x0Vn8spI+wuJ1O6S7gnbaQg8Pxh4NNHb7KSINmEWKiPE4RKOplvijn+NkmYmmRgP68mc70j2EbeTFRsrswaQeg== @@ -12318,7 +12363,7 @@ minimatch@3.0.4: dependencies: brace-expansion "^1.1.7" -minimatch@^3.0.2, minimatch@^3.0.4, minimatch@^3.1.1, minimatch@^3.1.2: +minimatch@^3.0.2, minimatch@^3.0.3, minimatch@^3.0.4, minimatch@^3.1.1, minimatch@^3.1.2: version "3.1.2" resolved "https://registry.yarnpkg.com/minimatch/-/minimatch-3.1.2.tgz#19cd194bfd3e428f049a70817c038d89ab4be35b" integrity sha512-J7p63hRiAjw1NDEww1W7i37+ByIrOWO5XQQAzZ3VOcL0PNybwpfmV/N05zFAzwQ9USyEcX6t3UO+K5aqBQOIHw== @@ -12462,6 +12507,11 @@ multicast-dns@^7.2.4: dns-packet "^5.2.2" thunky "^1.0.2" +mute-stream@~0.0.4: + version "0.0.8" + resolved "https://registry.yarnpkg.com/mute-stream/-/mute-stream-0.0.8.tgz#1630c42b2251ff81e2a283de96a5497ea92e5e0d" + integrity sha512-nnbWWOkoWyUsTjKrhgD0dcz22mdkSnpYqbEjIm2nhwhuxlSkpywJmBo8h0ZqJdkp73mb90SssHkN4rsRaBAfAA== + nan@^2.12.1: version "2.16.0" resolved "https://registry.yarnpkg.com/nan/-/nan-2.16.0.tgz#664f43e45460fb98faf00edca0bb0d7b8dce7916" @@ -12933,6 +12983,24 @@ os-homedir@^1.0.0: resolved "https://registry.yarnpkg.com/os-homedir/-/os-homedir-1.0.2.tgz#ffbc4988336e0e833de0c168c7ef152121aa7fb3" integrity sha1-/7xJiDNuDoM94MFox+8VISGqf7M= +os-tmpdir@^1.0.0, os-tmpdir@~1.0.1: + version "1.0.2" + resolved "https://registry.yarnpkg.com/os-tmpdir/-/os-tmpdir-1.0.2.tgz#bbe67406c79aa85c5cfec766fe5734555dfa1274" + integrity sha512-D2FR03Vir7FIu45XBY20mTb+/ZSWB00sjU9jdQXt83gDrI4Ztz5Fs7/yy74g2N5SVQY4xY1qDr4rNddwYRVX0g== + +os@0.1.1: + version "0.1.1" + resolved "https://registry.yarnpkg.com/os/-/os-0.1.1.tgz#208845e89e193ad4d971474b93947736a56d13f3" + integrity sha512-jg06S2xr5De63mLjZVJDf3/k37tpjppr2LR7MUOsxv8XuUCVpCnvbCksXCBcB5gQqQf/K0+87WGTRlAj5q7r1A== + +osenv@^0.1.3: + version "0.1.5" + resolved "https://registry.yarnpkg.com/osenv/-/osenv-0.1.5.tgz#85cdfafaeb28e8677f416e287592b5f3f49ea410" + integrity sha512-0CWcCECdMVc2Rw3U5w9ZjqX6ga6ubk1xDVKxtBQPK7wis/0F2r9T6k4ydGYhecl7YUBxBVxhL5oisPsNxAPe2g== + dependencies: + os-homedir "^1.0.0" + os-tmpdir "^1.0.0" + p-all@^2.1.0: version "2.1.0" resolved "https://registry.yarnpkg.com/p-all/-/p-all-2.1.0.tgz#91419be56b7dee8fe4c5db875d55e0da084244a0" @@ -13156,6 +13224,13 @@ parse-numeric-range@^1.3.0: resolved "https://registry.yarnpkg.com/parse-numeric-range/-/parse-numeric-range-1.3.0.tgz#7c63b61190d61e4d53a1197f0c83c47bb670ffa3" integrity sha512-twN+njEipszzlMJd4ONUYgSfZPDxgHhT9Ahed5uTigpQn90FggW4SA/AIPq/6a149fTbE9qBEcSwE3FAEp6wQQ== +parse-semver@^1.1.1: + version "1.1.1" + resolved "https://registry.yarnpkg.com/parse-semver/-/parse-semver-1.1.1.tgz#9a4afd6df063dc4826f93fba4a99cf223f666cb8" + integrity sha512-Eg1OuNntBMH0ojvEKSrvDSnwLmvVuUOSdylH/pSCPNMIspLlweJyIWXCE+k/5hm3cj/EBUYwmWkjhBALNP4LXQ== + dependencies: + semver "^5.1.0" + parse5-htmlparser2-tree-adapter@^7.0.0: version "7.0.0" resolved "https://registry.yarnpkg.com/parse5-htmlparser2-tree-adapter/-/parse5-htmlparser2-tree-adapter-7.0.0.tgz#23c2cc233bcf09bb7beba8b8a69d46b08c62c2f1" @@ -13318,6 +13393,11 @@ peggy@^2.0.1: commander "^9.3.0" source-map-generator "0.8.0" +pend@~1.2.0: + version "1.2.0" + resolved "https://registry.yarnpkg.com/pend/-/pend-1.2.0.tgz#7a57eb550a6783f9115331fcf4663d5c8e007a50" + integrity sha512-F3asv42UuXchdzt+xXqfW1OGlVBe+mxa2mqI0pg5yAHZPvFmY3Y6drSf/GQ1A86WgWEN9Kzh/WrgKa6iGcHXLg== + performance-now@^2.1.0: version "2.1.0" resolved "https://registry.yarnpkg.com/performance-now/-/performance-now-2.1.0.tgz#6309f4e0e5fa913ec1c69307ae364b4b377c9e7b" @@ -14841,6 +14921,13 @@ read-pkg@^5.2.0: parse-json "^5.0.0" type-fest "^0.6.0" +read@^1.0.7: + version "1.0.7" + resolved "https://registry.yarnpkg.com/read/-/read-1.0.7.tgz#b3da19bd052431a97671d44a42634adf710b40c4" + integrity sha512-rSOKNYUmaxy0om1BNjMN4ezNT6VKK+2xF4GBhc81mkH7L60i6dp8qPYrkndNLT3QPphoII3maL9PVC9XmhHwVQ== + dependencies: + mute-stream "~0.0.4" + "readable-stream@1 || 2", readable-stream@^2.0.0, readable-stream@^2.0.1, readable-stream@^2.0.2, readable-stream@^2.1.4, readable-stream@^2.1.5, readable-stream@^2.2.2, readable-stream@^2.3.3, readable-stream@^2.3.6, readable-stream@~2.3.6: version "2.3.7" resolved "https://registry.yarnpkg.com/readable-stream/-/readable-stream-2.3.7.tgz#1eca1cf711aef814c04f62252a36a62f6cb23b57" @@ -15583,7 +15670,7 @@ semver-diff@^3.1.1: dependencies: semver "^6.3.0" -"semver@2 || 3 || 4 || 5", semver@^5.4.1, semver@^5.5.0, semver@^5.6.0: +"semver@2 || 3 || 4 || 5", semver@^5.1.0, semver@^5.4.1, semver@^5.5.0, semver@^5.6.0: version "5.7.1" resolved "https://registry.yarnpkg.com/semver/-/semver-5.7.1.tgz#a954f931aeba508d307bbf069eff0c01c96116f7" integrity sha512-sauaDf/PZdVgrLTNYHRtpXa1iRiKcaebiKQ1BJdpQlWH2lCvexQdX55snPFyK7QzpudqbCI0qXFfOasHdyNDGQ== @@ -16753,6 +16840,13 @@ tiny-warning@^1.0.0, tiny-warning@^1.0.3: resolved "https://registry.yarnpkg.com/tiny-warning/-/tiny-warning-1.0.3.tgz#94a30db453df4c643d0fd566060d60a875d84754" integrity sha512-lBN9zLN/oAf68o3zNXYrdCt1kP8WsiGW8Oo2ka41b2IM5JL/S1CTyX1rW0mb/zSuJun0ZUrDxx4sqvYS2FWzPA== +tmp@0.0.29: + version "0.0.29" + resolved "https://registry.yarnpkg.com/tmp/-/tmp-0.0.29.tgz#f25125ff0dd9da3ccb0c2dd371ee1288bb9128c0" + integrity sha512-89PTqMWGDva+GqClOqBV9s3SMh7MA3Mq0pJUdAoHuF65YoE7O0LermaZkVfT5/Ngfo18H4eYiyG7zKOtnEbxsw== + dependencies: + os-tmpdir "~1.0.1" + tmpl@1.0.5: version "1.0.5" resolved "https://registry.yarnpkg.com/tmpl/-/tmpl-1.0.5.tgz#8683e0b902bb9c20c4f726e3c0b69f36518c07cc" @@ -16994,6 +17088,11 @@ tty-browserify@0.0.0: resolved "https://registry.yarnpkg.com/tty-browserify/-/tty-browserify-0.0.0.tgz#a157ba402da24e9bf957f9aa69d524eed42901a6" integrity sha1-oVe6QC2iTpv5V/mqadUk7tQpAaY= +tunnel@0.0.4: + version "0.0.4" + resolved "https://registry.yarnpkg.com/tunnel/-/tunnel-0.0.4.tgz#2d3785a158c174c9a16dc2c046ec5fc5f1742213" + integrity sha512-o9QYRJN5WgS8oCtqvwzzcfnzaTnDPr7HpUsQdSXscTyzXbjvl4wSHPTUKOKzEaDeQvOuyRtt3ui+ujM7x7TReQ== + type-check@^0.4.0, type-check@~0.4.0: version "0.4.0" resolved "https://registry.yarnpkg.com/type-check/-/type-check-0.4.0.tgz#07b8203bfa7056c0657050e3ccd2c37730bab8f1" @@ -17056,6 +17155,14 @@ typed-function@^2.1.0: resolved "https://registry.yarnpkg.com/typed-function/-/typed-function-2.1.0.tgz#ded6f8a442ba8749ff3fe75bc41419c8d46ccc3f" integrity sha512-bctQIOqx2iVbWGDGPWwIm18QScpu2XRmkC19D8rQGFsjKSgteq/o1hTZvIG/wuDq8fanpBDrLkLq+aEN/6y5XQ== +typed-rest-client@1.2.0: + version "1.2.0" + resolved "https://registry.yarnpkg.com/typed-rest-client/-/typed-rest-client-1.2.0.tgz#723085d203f38d7d147271e5ed3a75488eb44a02" + integrity sha512-FrUshzZ1yxH8YwGR29PWWnfksLEILbWJydU7zfIRkyH7kAEzB62uMAl2WY6EyolWpLpVHeJGgQm45/MaruaHpw== + dependencies: + tunnel "0.0.4" + underscore "1.8.3" + typedarray-to-buffer@^3.1.5: version "3.1.5" resolved "https://registry.yarnpkg.com/typedarray-to-buffer/-/typedarray-to-buffer-3.1.5.tgz#a97ee7a9ff42691b9f783ff1bc5112fe3fca9080" @@ -17078,6 +17185,11 @@ ua-parser-js@^0.7.30: resolved "https://registry.yarnpkg.com/ua-parser-js/-/ua-parser-js-0.7.31.tgz#649a656b191dffab4f21d5e053e27ca17cbff5c6" integrity sha512-qLK/Xe9E2uzmYI3qLeOmI0tEOt+TBBQyUIAh4aAgU05FVYzeZrKUdkAZfBNVGRaHVgV0TDkdEngJSw/SyQchkQ== +uc.micro@^1.0.1, uc.micro@^1.0.5: + version "1.0.6" + resolved "https://registry.yarnpkg.com/uc.micro/-/uc.micro-1.0.6.tgz#9c411a802a409a91fc6cf74081baba34b24499ac" + integrity sha512-8Y75pvTYkLJW2hWQHXxoqRgV7qb9B+9vFEtidML+7koHUFapnVJAZ6cKs+Qjz5Aw3aZWHMC6u0wJE3At+nSGwA== + uglify-js@^3.1.4: version "3.15.5" resolved "https://registry.yarnpkg.com/uglify-js/-/uglify-js-3.15.5.tgz#2b10f9e0bfb3f5c15a8e8404393b6361eaeb33b3" @@ -17093,6 +17205,11 @@ unbox-primitive@^1.0.2: has-symbols "^1.0.3" which-boxed-primitive "^1.0.2" +underscore@1.8.3: + version "1.8.3" + resolved "https://registry.yarnpkg.com/underscore/-/underscore-1.8.3.tgz#4f3fb53b106e6097fcf9cb4109f2a5e9bdfa5022" + integrity sha512-5WsVTFcH1ut/kkhAaHf4PVgI8c7++GiVcpCGxPouI6ZVjsqPnSDf8h/8HtVqc0t4fzRXwnMK70EcZeAs3PIddg== + unfetch@^4.2.0: version "4.2.0" resolved "https://registry.yarnpkg.com/unfetch/-/unfetch-4.2.0.tgz#7e21b0ef7d363d8d9af0fb929a5555f6ef97a3be" @@ -17332,6 +17449,11 @@ urix@^0.1.0: resolved "https://registry.yarnpkg.com/urix/-/urix-0.1.0.tgz#da937f7a62e21fec1fd18d49b35c2935067a6c72" integrity sha1-2pN/emLiH+wf0Y1Js1wpNQZ6bHI= +url-join@^1.1.0: + version "1.1.0" + resolved "https://registry.yarnpkg.com/url-join/-/url-join-1.1.0.tgz#741c6c2f4596c4830d6718460920d0c92202dc78" + integrity sha512-zz1wZk4Lb5PTVwZ3HWDmm8XnlPvmOof6/fjdDPA5yBrUcbtV64U6bV832Zf1BtU2WkBBWaUT46wCs+l0HP5nhg== + url-loader@^4.1.1: version "4.1.1" resolved "https://registry.yarnpkg.com/url-loader/-/url-loader-4.1.1.tgz#28505e905cae158cf07c92ca622d7f237e70a4e2" @@ -17893,6 +18015,89 @@ vm-browserify@^1.0.1: resolved "https://registry.yarnpkg.com/vm-browserify/-/vm-browserify-1.1.2.tgz#78641c488b8e6ca91a75f511e7a3b32a86e5dda0" integrity sha512-2ham8XPWTONajOR0ohOKOHXkm3+gaBmGut3SRuu75xLd/RRaY6vqgh8NBYYk7+RW3u5AtzPQZG8F10LHkl0lAQ== +vsce-yarn-patch@^1.66.2: + version "1.66.2" + resolved "https://registry.yarnpkg.com/vsce-yarn-patch/-/vsce-yarn-patch-1.66.2.tgz#b217a9d73ee715ad41ec44393a5d78ed0955ab44" + integrity sha512-IJjBF/WQWQvEIikI93qDEhiugjVFDgibqsBa2roawp5abeovPZ9/bzLt0b9AylBtP60q2qSMWsGtf1hZBAs7fw== + dependencies: + azure-devops-node-api "^7.2.0" + chalk "^2.4.2" + cheerio "^1.0.0-rc.1" + commander "^2.8.1" + denodeify "^1.2.1" + didyoumean "^1.2.1" + glob "^7.0.6" + lodash "^4.17.10" + markdown-it "^8.3.1" + mime "^1.3.4" + minimatch "^3.0.3" + osenv "^0.1.3" + parse-semver "^1.1.1" + read "^1.0.7" + semver "^5.1.0" + tmp "0.0.29" + typed-rest-client "1.2.0" + url-join "^1.1.0" + yauzl "^2.3.1" + yazl "^2.2.2" + +vscode-jsonrpc@6.0.0: + version "6.0.0" + resolved "https://registry.yarnpkg.com/vscode-jsonrpc/-/vscode-jsonrpc-6.0.0.tgz#108bdb09b4400705176b957ceca9e0880e9b6d4e" + integrity sha512-wnJA4BnEjOSyFMvjZdpiOwhSq9uDoK8e/kpRJDTaMYzwlkrhG1fwDIZI94CLsLzlCK5cIbMMtFlJlfR57Lavmg== + +vscode-jsonrpc@8.0.1: + version "8.0.1" + resolved "https://registry.yarnpkg.com/vscode-jsonrpc/-/vscode-jsonrpc-8.0.1.tgz#f30b0625ebafa0fb3bc53e934ca47b706445e57e" + integrity sha512-N/WKvghIajmEvXpatSzvTvOIz61ZSmOSa4BRA4pTLi+1+jozquQKP/MkaylP9iB68k73Oua1feLQvH3xQuigiQ== + +vscode-languageclient@^8.0.1: + version "8.0.1" + resolved "https://registry.yarnpkg.com/vscode-languageclient/-/vscode-languageclient-8.0.1.tgz#bf5535c4463a78daeaca0bcb4f5868aec86bb301" + integrity sha512-9XoE+HJfaWvu7Y75H3VmLo5WLCtsbxEgEhrLPqwt7eyoR49lUIyyrjb98Yfa50JCMqF2cePJAEVI6oe2o1sIhw== + dependencies: + minimatch "^3.0.4" + semver "^7.3.5" + vscode-languageserver-protocol "3.17.1" + +vscode-languageserver-protocol@3.16.0: + version "3.16.0" + resolved "https://registry.yarnpkg.com/vscode-languageserver-protocol/-/vscode-languageserver-protocol-3.16.0.tgz#34135b61a9091db972188a07d337406a3cdbe821" + integrity sha512-sdeUoAawceQdgIfTI+sdcwkiK2KU+2cbEYA0agzM2uqaUy2UpnnGHtWTHVEtS0ES4zHU0eMFRGN+oQgDxlD66A== + dependencies: + vscode-jsonrpc "6.0.0" + vscode-languageserver-types "3.16.0" + +vscode-languageserver-protocol@3.17.1: + version "3.17.1" + resolved "https://registry.yarnpkg.com/vscode-languageserver-protocol/-/vscode-languageserver-protocol-3.17.1.tgz#e801762c304f740208b6c804a0cf21f2c87509ed" + integrity sha512-BNlAYgQoYwlSgDLJhSG+DeA8G1JyECqRzM2YO6tMmMji3Ad9Mw6AW7vnZMti90qlAKb0LqAlJfSVGEdqMMNzKg== + dependencies: + vscode-jsonrpc "8.0.1" + vscode-languageserver-types "3.17.1" + +vscode-languageserver-textdocument@^1.0.5: + version "1.0.5" + resolved "https://registry.yarnpkg.com/vscode-languageserver-textdocument/-/vscode-languageserver-textdocument-1.0.5.tgz#838769940ece626176ec5d5a2aa2d0aa69f5095c" + integrity sha512-1ah7zyQjKBudnMiHbZmxz5bYNM9KKZYz+5VQLj+yr8l+9w3g+WAhCkUkWbhMEdC5u0ub4Ndiye/fDyS8ghIKQg== + +vscode-languageserver-types@3.16.0: + version "3.16.0" + resolved "https://registry.yarnpkg.com/vscode-languageserver-types/-/vscode-languageserver-types-3.16.0.tgz#ecf393fc121ec6974b2da3efb3155644c514e247" + integrity sha512-k8luDIWJWyenLc5ToFQQMaSrqCHiLwyKPHKPQZ5zz21vM+vIVUSvsRpcbiECH4WR88K2XZqc4ScRcZ7nk/jbeA== + +vscode-languageserver-types@3.17.1: + version "3.17.1" + resolved "https://registry.yarnpkg.com/vscode-languageserver-types/-/vscode-languageserver-types-3.17.1.tgz#c2d87fa7784f8cac389deb3ff1e2d9a7bef07e16" + integrity sha512-K3HqVRPElLZVVPtMeKlsyL9aK0GxGQpvtAUTfX4k7+iJ4mc1M+JM+zQwkgGy2LzY0f0IAafe8MKqIkJrxfGGjQ== + +vscode-languageserver@^7.0.0: + version "7.0.0" + resolved "https://registry.yarnpkg.com/vscode-languageserver/-/vscode-languageserver-7.0.0.tgz#49b068c87cfcca93a356969d20f5d9bdd501c6b0" + integrity sha512-60HTx5ID+fLRcgdHfmz0LDZAXYEV68fzwG0JWwEPBode9NuMYTIxuYXPg4ngO8i8+Ou0lM7y6GzaYWbiDL0drw== + dependencies: + vscode-languageserver-protocol "3.16.0" + vscode-uri@^3.0.3: version "3.0.3" resolved "https://registry.yarnpkg.com/vscode-uri/-/vscode-uri-3.0.3.tgz#a95c1ce2e6f41b7549f86279d19f47951e4f4d84" @@ -18727,6 +18932,21 @@ yargs@~17.2.1: y18n "^5.0.5" yargs-parser "^20.2.2" +yauzl@^2.3.1: + version "2.10.0" + resolved "https://registry.yarnpkg.com/yauzl/-/yauzl-2.10.0.tgz#c7eb17c93e112cb1086fa6d8e51fb0667b79a5f9" + integrity sha512-p4a9I6X6nu6IhoGmBqAcbJy1mlC4j27vEPZX9F4L4/vZT3Lyq1VkFHw/V/PUcB9Buo+DG3iHkT0x3Qya58zc3g== + dependencies: + buffer-crc32 "~0.2.3" + fd-slicer "~1.1.0" + +yazl@^2.2.2: + version "2.5.1" + resolved "https://registry.yarnpkg.com/yazl/-/yazl-2.5.1.tgz#a3d65d3dd659a5b0937850e8609f22fffa2b5c35" + integrity sha512-phENi2PLiHnHb6QBVot+dJnaAZ0xosj7p3fWl+znIjBDlnMI2PsZCJZ306BPTFOaHf5qdDEI8x5qFrSOBN5vrw== + dependencies: + buffer-crc32 "~0.2.3" + yn@3.1.1: version "3.1.1" resolved "https://registry.yarnpkg.com/yn/-/yn-3.1.1.tgz#1e87401a09d767c1d5eab26a6e4c185182d2eb50" From 840944f566df977fa316e612deb15b7793d4d5c1 Mon Sep 17 00:00:00 2001 From: Vyacheslav Matyukhin Date: Wed, 22 Jun 2022 01:47:33 +0300 Subject: [PATCH 03/12] external stdlib for rescript --- packages/squiggle-lang/bsconfig.json | 1 + packages/squiggle-lang/package.json | 5 +++-- yarn.lock | 9 +++++++-- 3 files changed, 11 insertions(+), 4 deletions(-) diff --git a/packages/squiggle-lang/bsconfig.json b/packages/squiggle-lang/bsconfig.json index 81e4e133..1fa663ac 100644 --- a/packages/squiggle-lang/bsconfig.json +++ b/packages/squiggle-lang/bsconfig.json @@ -31,6 +31,7 @@ "basic": false } }, + "external-stdlib": "@rescript/std", "refmt": 3, "warnings": { "number": "+A-42-48-9-30-4" diff --git a/packages/squiggle-lang/package.json b/packages/squiggle-lang/package.json index f338e564..388a596a 100644 --- a/packages/squiggle-lang/package.json +++ b/packages/squiggle-lang/package.json @@ -36,12 +36,12 @@ ], "author": "Quantified Uncertainty Research Institute", "dependencies": { + "@rescript/std": "^9.1.4", "@stdlib/stats": "^0.0.13", "jstat": "^1.9.5", "lodash": "^4.17.21", "mathjs": "^10.6.0", - "pdfast": "^0.2.0", - "rescript": "^9.1.4" + "pdfast": "^0.2.0" }, "devDependencies": { "@glennsl/rescript-jest": "^0.9.0", @@ -58,6 +58,7 @@ "nyc": "^15.1.0", "peggy": "^2.0.1", "reanalyze": "^2.23.0", + "rescript": "^9.1.4", "rescript-fast-check": "^1.1.1", "ts-jest": "^27.1.4", "ts-loader": "^9.3.0", diff --git a/yarn.lock b/yarn.lock index 2ce67d62..6f41979e 100644 --- a/yarn.lock +++ b/yarn.lock @@ -2336,6 +2336,11 @@ "@react-hook/passive-layout-effect" "^1.2.0" "@react-hook/resize-observer" "^1.2.1" +"@rescript/std@^9.1.4": + version "9.1.4" + resolved "https://registry.yarnpkg.com/@rescript/std/-/std-9.1.4.tgz#94971cb504b10d36d470618fa1c6f0a2d03a6b9b" + integrity sha512-OHBORysVe6vmyllL24S2sXiwLGrpVRbZW5k2FverbjY3QF81VoyCRYL6kMOSNMEn9GseO/oDubK8+nvVzCSVMA== + "@rollup/plugin-babel@^5.2.0": version "5.3.1" resolved "https://registry.yarnpkg.com/@rollup/plugin-babel/-/plugin-babel-5.3.1.tgz#04bc0608f4aa4b2e4b1aebf284344d0f68fda283" @@ -4344,7 +4349,7 @@ dependencies: "@types/react" "*" -"@types/react@*", "@types/react@^18.0.1", "@types/react@^18.0.9": +"@types/react@*", "@types/react@^18.0.9": version "18.0.14" resolved "https://registry.yarnpkg.com/@types/react/-/react-18.0.14.tgz#e016616ffff51dba01b04945610fe3671fdbe06d" integrity sha512-x4gGuASSiWmo0xjDLpm5mPb52syZHJx02VKbqUKdLmKtAwIh63XClGsiTI1K6DO5q7ox4xAsQrU+Gl3+gGXF9Q== @@ -14871,7 +14876,7 @@ react-vega@^7.5.1: prop-types "^15.8.1" vega-embed "^6.5.1" -react@^18.0.0, react@^18.1.0: +react@^18.1.0: version "18.2.0" resolved "https://registry.yarnpkg.com/react/-/react-18.2.0.tgz#555bd98592883255fa00de14f1151a917b5d77d5" integrity sha512-/3IjMdb2L9QbBdWiW5e3P2/npwMBaU9mHCSCUzNln0ZCYbcfTsGbTJrU/kGemdH2IWmB2ioZ+zkxtmq6g09fGQ== From 0cf5c47c288d9a499e627e7d73a103e3ba12f1cb Mon Sep 17 00:00:00 2001 From: Vyacheslav Matyukhin Date: Wed, 22 Jun 2022 01:52:47 +0300 Subject: [PATCH 04/12] update yarn.lock --- yarn.lock | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/yarn.lock b/yarn.lock index 6f41979e..01a0cc85 100644 --- a/yarn.lock +++ b/yarn.lock @@ -4349,7 +4349,7 @@ dependencies: "@types/react" "*" -"@types/react@*", "@types/react@^18.0.9": +"@types/react@*", "@types/react@^18.0.1", "@types/react@^18.0.9": version "18.0.14" resolved "https://registry.yarnpkg.com/@types/react/-/react-18.0.14.tgz#e016616ffff51dba01b04945610fe3671fdbe06d" integrity sha512-x4gGuASSiWmo0xjDLpm5mPb52syZHJx02VKbqUKdLmKtAwIh63XClGsiTI1K6DO5q7ox4xAsQrU+Gl3+gGXF9Q== @@ -14876,7 +14876,7 @@ react-vega@^7.5.1: prop-types "^15.8.1" vega-embed "^6.5.1" -react@^18.1.0: +react@^18.0.0, react@^18.1.0: version "18.2.0" resolved "https://registry.yarnpkg.com/react/-/react-18.2.0.tgz#555bd98592883255fa00de14f1151a917b5d77d5" integrity sha512-/3IjMdb2L9QbBdWiW5e3P2/npwMBaU9mHCSCUzNln0ZCYbcfTsGbTJrU/kGemdH2IWmB2ioZ+zkxtmq6g09fGQ== From ac9a468aa632f48706087d0d8ffcdb50c51d8e04 Mon Sep 17 00:00:00 2001 From: Umur Ozkul Date: Thu, 16 Jun 2022 14:08:59 +0200 Subject: [PATCH 05/12] Reducer InternalExpressionValue created this will allow complicated changes to execution without changing the typescript interface --- ...ducer_Category_Module_TypeChecker_test.res | 4 + .../Reducer_Dispatch_BuiltInMacros_test.res | 40 +-- .../Reducer_Dispatch_BuiltIn_test.res | 2 +- .../__tests__/Reducer/Reducer_Helpers.res | 33 ++- .../Reducer_MathJsEval_test.res | 13 +- .../Reducer_Peggy_TestHelpers.res | 4 +- .../Reducer_Peggy_ToExpression_test.res | 14 +- .../Reducer_Peggy_ToExpression_type_test.res | 26 +- .../__tests__/Reducer/Reducer_TestHelpers.res | 15 +- .../Reducer/Reducer_TestMacroHelpers.res | 36 ++- .../Reducer/Reducer_externalBindings_test.res | 13 +- .../Reducer/Reducer_functionTricks_test.res | 16 +- .../__tests__/Reducer/Reducer_test.res | 2 +- .../ReducerInterface_ExpressionValue_test.res | 2 +- packages/squiggle-lang/package.json | 1 + .../Distributions/PointSetDist/Discrete.res | 1 + .../Distributions/PointSetDist/Mixed.res | 2 + .../FunctionRegistry_Core.res | 76 ++--- .../FunctionRegistry_Helpers.res | 10 +- .../FunctionRegistry_Library.res | 11 +- .../src/rescript/Reducer/Reducer.res | 24 +- .../Reducer_Category_Bindings.res | 12 - .../Reducer_Category_Module.res | 111 ++++++-- .../Reducer_Category_Module_TypeChecker.res | 21 ++ .../Reducer_Dispatch_BuiltIn.res | 248 ++++++++--------- .../Reducer_Dispatch_BuiltInMacros.res | 46 ++-- .../Reducer_Expression/Reducer_Expression.res | 56 ++-- .../Reducer_ExpressionWithContext.res | 10 +- ...> Reducer_Expression_BindingsReplacer.res} | 32 +-- .../Reducer_Expression_ExpressionBuilder.res | 53 ++-- .../Reducer_Expression_Lambda.res | 48 ++-- .../Reducer_Expression_Macro.res | 2 +- .../Reducer_Expression_T.res | 21 +- .../Reducer/Reducer_Js/Reducer_Js_Gate.res | 10 +- .../Reducer_MathJs/Reducer_MathJs_Eval.res | 4 +- .../ReducerInterface/ReducerInterface.res | 4 +- .../ReducerInterface_Date.res | 24 +- .../ReducerInterface_Duration.res | 50 ++-- .../ReducerInterface_ExpressionValue.res | 43 +-- .../ReducerInterface_ExternalLibrary.res | 2 +- .../ReducerInterface_GenericDistribution.res | 120 ++++---- .../ReducerInterface_GenericDistribution.resi | 6 +- ...ducerInterface_InternalExpressionValue.res | 260 ++++++++++++++++++ .../ReducerInterface_Number.res | 6 +- .../ReducerInterface_StdLib.res | 7 +- .../SquiggleLibrary/SquiggleLibrary_Math.res | 4 +- 46 files changed, 951 insertions(+), 594 deletions(-) create mode 100644 packages/squiggle-lang/__tests__/Reducer/Reducer_Category/Reducer_Category_Module_TypeChecker_test.res delete mode 100644 packages/squiggle-lang/src/rescript/Reducer/Reducer_Category/Reducer_Category_Bindings.res create mode 100644 packages/squiggle-lang/src/rescript/Reducer/Reducer_Category/Reducer_Category_Module_TypeChecker.res rename packages/squiggle-lang/src/rescript/Reducer/Reducer_Expression/{Reducer_Expression_Bindings.res => Reducer_Expression_BindingsReplacer.res} (58%) create mode 100644 packages/squiggle-lang/src/rescript/ReducerInterface/ReducerInterface_InternalExpressionValue.res diff --git a/packages/squiggle-lang/__tests__/Reducer/Reducer_Category/Reducer_Category_Module_TypeChecker_test.res b/packages/squiggle-lang/__tests__/Reducer/Reducer_Category/Reducer_Category_Module_TypeChecker_test.res new file mode 100644 index 00000000..b5351787 --- /dev/null +++ b/packages/squiggle-lang/__tests__/Reducer/Reducer_Category/Reducer_Category_Module_TypeChecker_test.res @@ -0,0 +1,4 @@ +open Jest +open Expect + +test("todo", () => expect("1")->toBe("1")) diff --git a/packages/squiggle-lang/__tests__/Reducer/Reducer_Dispatch/Reducer_Dispatch_BuiltInMacros_test.res b/packages/squiggle-lang/__tests__/Reducer/Reducer_Dispatch/Reducer_Dispatch_BuiltInMacros_test.res index 4b506a15..96f80379 100644 --- a/packages/squiggle-lang/__tests__/Reducer/Reducer_Dispatch/Reducer_Dispatch_BuiltInMacros_test.res +++ b/packages/squiggle-lang/__tests__/Reducer/Reducer_Dispatch/Reducer_Dispatch_BuiltInMacros_test.res @@ -19,23 +19,23 @@ describe("bindStatement", () => { testMacro( [], eBindStatement(eBindings([]), exampleStatementY), - "Ok((:$_setBindings_$ {} :y 1) context: {})", + "Ok((:$_setBindings_$ @{} :y 1) context: @{})", ) // Then it answers the bindings for the next statement when reduced - testMacroEval([], eBindStatement(eBindings([]), exampleStatementY), "Ok({y: 1})") + testMacroEval([], eBindStatement(eBindings([]), exampleStatementY), "Ok(@{y: 1})") // Now let's feed a binding to see what happens testMacro( [], - eBindStatement(eBindings([("x", EvNumber(2.))]), exampleStatementX), - "Ok((:$_setBindings_$ {x: 2} :y 2) context: {x: 2})", + eBindStatement(eBindings([("x", IevNumber(2.))]), exampleStatementX), + "Ok((:$_setBindings_$ @{x: 2} :y 2) context: @{x: 2})", ) // An expression does not return a binding, thus error testMacro([], eBindStatement(eBindings([]), exampleExpression), "Assignment expected") // When bindings from previous statement are missing the context is injected. This must be the first statement of a block testMacro( - [("z", EvNumber(99.))], + [("z", IevNumber(99.))], eBindStatementDefault(exampleStatementY), - "Ok((:$_setBindings_$ {z: 99} :y 1) context: {z: 99})", + "Ok((:$_setBindings_$ @{z: 99} :y 1) context: @{z: 99})", ) }) @@ -43,26 +43,26 @@ describe("bindExpression", () => { // x is simply bound in the expression testMacro( [], - eBindExpression(eBindings([("x", EvNumber(2.))]), eSymbol("x")), - "Ok(2 context: {x: 2})", + eBindExpression(eBindings([("x", IevNumber(2.))]), eSymbol("x")), + "Ok(2 context: @{x: 2})", ) // When an let statement is the end expression then bindings are returned testMacro( [], - eBindExpression(eBindings([("x", EvNumber(2.))]), exampleStatementY), - "Ok((:$_exportBindings_$ (:$_setBindings_$ {x: 2} :y 1)) context: {x: 2})", + eBindExpression(eBindings([("x", IevNumber(2.))]), exampleStatementY), + "Ok((:$_exportBindings_$ (:$_setBindings_$ @{x: 2} :y 1)) context: @{x: 2})", ) // Now let's reduce that expression testMacroEval( [], - eBindExpression(eBindings([("x", EvNumber(2.))]), exampleStatementY), - "Ok({x: 2,y: 1})", + eBindExpression(eBindings([("x", IevNumber(2.))]), exampleStatementY), + "Ok(@{x: 2,y: 1})", ) // When bindings are missing the context is injected. This must be the first and last statement of a block testMacroEval( - [("z", EvNumber(99.))], + [("z", IevNumber(99.))], eBindExpressionDefault(exampleStatementY), - "Ok({y: 1,z: 99})", + "Ok(@{y: 1,z: 99})", ) }) @@ -72,7 +72,7 @@ describe("block", () => { testMacroEval([], eBlock(list{exampleExpression}), "Ok(1)") // Block with a single statement testMacro([], eBlock(list{exampleStatementY}), "Ok((:$$_bindExpression_$$ (:$_let_$ :y 1)))") - testMacroEval([], eBlock(list{exampleStatementY}), "Ok({y: 1})") + testMacroEval([], eBlock(list{exampleStatementY}), "Ok(@{y: 1})") // Block with a statement and an expression testMacro( [], @@ -86,7 +86,7 @@ describe("block", () => { eBlock(list{exampleStatementY, exampleStatementZ}), "Ok((:$$_bindExpression_$$ (:$$_bindStatement_$$ (:$_let_$ :y 1)) (:$_let_$ :z :y)))", ) - testMacroEval([], eBlock(list{exampleStatementY, exampleStatementZ}), "Ok({y: 1,z: 1})") + testMacroEval([], eBlock(list{exampleStatementY, exampleStatementZ}), "Ok(@{y: 1,z: 1})") // Block inside a block testMacro([], eBlock(list{eBlock(list{exampleExpression})}), "Ok((:$$_bindExpression_$$ {1}))") testMacroEval([], eBlock(list{eBlock(list{exampleExpression})}), "Ok(1)") @@ -99,7 +99,7 @@ describe("block", () => { testMacroEval( [], eBlock(list{eLetStatement("z", eBlock(list{eBlock(list{exampleExpressionY})}))}), - "Ok({z: :y})", + "Ok(@{z: :y})", ) // Empty block testMacro([], eBlock(list{}), "Ok(:undefined block)") //TODO: should be an error @@ -115,7 +115,7 @@ describe("block", () => { "Ok((:$$_bindExpression_$$ {(:$_let_$ :y (:add :x 1)); :y}))", ) testMacroEval( - [("x", EvNumber(1.))], + [("x", IevNumber(1.))], eBlock(list{ eBlock(list{ eLetStatement("y", eFunction("add", list{eSymbol("x"), eNumber(1.)})), @@ -135,12 +135,12 @@ describe("lambda", () => { testMacro([], callLambdaExpression, "Ok(((:$$_lambda_$$ [y] :y) 1))") testMacroEval([], callLambdaExpression, "Ok(1)") // Parameters shadow the outer scope - testMacroEval([("y", EvNumber(666.))], callLambdaExpression, "Ok(1)") + testMacroEval([("y", IevNumber(666.))], callLambdaExpression, "Ok(1)") // When not shadowed by the parameters, the outer scope variables are available let lambdaExpression = eFunction( "$$_lambda_$$", list{eArrayString(["z"]), eFunction("add", list{eSymbol("y"), eSymbol("z")})}, ) let callLambdaExpression = eList(list{lambdaExpression, eNumber(1.)}) - testMacroEval([("y", EvNumber(666.))], callLambdaExpression, "Ok(667)") + testMacroEval([("y", IevNumber(666.))], callLambdaExpression, "Ok(667)") }) diff --git a/packages/squiggle-lang/__tests__/Reducer/Reducer_Dispatch/Reducer_Dispatch_BuiltIn_test.res b/packages/squiggle-lang/__tests__/Reducer/Reducer_Dispatch/Reducer_Dispatch_BuiltIn_test.res index fb891bb3..98192d31 100644 --- a/packages/squiggle-lang/__tests__/Reducer/Reducer_Dispatch/Reducer_Dispatch_BuiltIn_test.res +++ b/packages/squiggle-lang/__tests__/Reducer/Reducer_Dispatch/Reducer_Dispatch_BuiltIn_test.res @@ -1,4 +1,4 @@ -module ExpressionValue = ReducerInterface.ExpressionValue +module ExpressionValue = ReducerInterface.ExternalExpressionValue open Jest open Expect diff --git a/packages/squiggle-lang/__tests__/Reducer/Reducer_Helpers.res b/packages/squiggle-lang/__tests__/Reducer/Reducer_Helpers.res index 47fd5895..afeff706 100644 --- a/packages/squiggle-lang/__tests__/Reducer/Reducer_Helpers.res +++ b/packages/squiggle-lang/__tests__/Reducer/Reducer_Helpers.res @@ -1,19 +1,24 @@ -module ExpressionT = Reducer_Expression_T -module ExpressionValue = ReducerInterface.ExpressionValue +// Reducer_Helpers module ErrorValue = Reducer_ErrorValue -module Bindings = Reducer_Category_Bindings +module ExternalExpressionValue = ReducerInterface.ExternalExpressionValue +module InternalExpressionValue = ReducerInterface.InternalExpressionValue +module Module = Reducer_Category_Module -let removeDefaults = (ev: ExpressionT.expressionValue): ExpressionT.expressionValue => - switch ev { - | EvRecord(extbindings) => { - let bindings: Bindings.t = Bindings.fromRecord(extbindings) - let keys = Js.Dict.keys(Reducer.defaultExternalBindings) - Belt.Map.String.keep(bindings, (key, _value) => { - let removeThis = Js.Array2.includes(keys, key) - !removeThis - })->Bindings.toExpressionValue - } +let removeDefaultsInternal = (iev: InternalExpressionValue.expressionValue) => { + switch iev { + | InternalExpressionValue.IevModule(nameSpace) => + Module.removeOther( + nameSpace, + ReducerInterface.StdLib.internalStdLib, + )->InternalExpressionValue.IevModule | value => value } +} -let rRemoveDefaults = r => Belt.Result.map(r, ev => removeDefaults(ev)) +let removeDefaultsExternal = ( + ev: ExternalExpressionValue.expressionValue, +): ExternalExpressionValue.expressionValue => + ev->InternalExpressionValue.toInternal->removeDefaultsInternal->InternalExpressionValue.toExternal + +let rRemoveDefaultsInternal = r => Belt.Result.map(r, removeDefaultsInternal) +let rRemoveDefaultsExternal = r => Belt.Result.map(r, removeDefaultsExternal) diff --git a/packages/squiggle-lang/__tests__/Reducer/Reducer_MathJs/Reducer_MathJsEval_test.res b/packages/squiggle-lang/__tests__/Reducer/Reducer_MathJs/Reducer_MathJsEval_test.res index 6f232d0e..8e5bdef6 100644 --- a/packages/squiggle-lang/__tests__/Reducer/Reducer_MathJs/Reducer_MathJsEval_test.res +++ b/packages/squiggle-lang/__tests__/Reducer/Reducer_MathJs/Reducer_MathJsEval_test.res @@ -1,4 +1,3 @@ -open ReducerInterface.ExpressionValue module MathJs = Reducer_MathJs module ErrorValue = Reducer.ErrorValue @@ -6,14 +5,14 @@ open Jest open ExpectJs describe("eval", () => { - test("Number", () => expect(MathJs.Eval.eval("1"))->toEqual(Ok(EvNumber(1.)))) - test("Number expr", () => expect(MathJs.Eval.eval("1-1"))->toEqual(Ok(EvNumber(0.)))) - test("String", () => expect(MathJs.Eval.eval("'hello'"))->toEqual(Ok(EvString("hello")))) + test("Number", () => expect(MathJs.Eval.eval("1"))->toEqual(Ok(IevNumber(1.)))) + test("Number expr", () => expect(MathJs.Eval.eval("1-1"))->toEqual(Ok(IevNumber(0.)))) + test("String", () => expect(MathJs.Eval.eval("'hello'"))->toEqual(Ok(IevString("hello")))) test("String expr", () => - expect(MathJs.Eval.eval("concat('hello ','world')"))->toEqual(Ok(EvString("hello world"))) + expect(MathJs.Eval.eval("concat('hello ','world')"))->toEqual(Ok(IevString("hello world"))) ) - test("Boolean", () => expect(MathJs.Eval.eval("true"))->toEqual(Ok(EvBool(true)))) - test("Boolean expr", () => expect(MathJs.Eval.eval("2>1"))->toEqual(Ok(EvBool(true)))) + test("Boolean", () => expect(MathJs.Eval.eval("true"))->toEqual(Ok(IevBool(true)))) + test("Boolean expr", () => expect(MathJs.Eval.eval("2>1"))->toEqual(Ok(IevBool(true)))) }) describe("errors", () => { diff --git a/packages/squiggle-lang/__tests__/Reducer/Reducer_Peggy/Reducer_Peggy_TestHelpers.res b/packages/squiggle-lang/__tests__/Reducer/Reducer_Peggy/Reducer_Peggy_TestHelpers.res index 39c3492e..6d3ce663 100644 --- a/packages/squiggle-lang/__tests__/Reducer/Reducer_Peggy/Reducer_Peggy_TestHelpers.res +++ b/packages/squiggle-lang/__tests__/Reducer/Reducer_Peggy/Reducer_Peggy_TestHelpers.res @@ -1,6 +1,6 @@ module Expression = Reducer_Expression module ExpressionT = Reducer_Expression_T -module ExpressionValue = ReducerInterface_ExpressionValue +module ExpressionValue = ReducerInterface.InternalExpressionValue module Parse = Reducer_Peggy_Parse module Result = Belt.Result module ToExpression = Reducer_Peggy_ToExpression @@ -29,7 +29,7 @@ let expectToExpressionToBe = (expr, answer, ~v="_", ()) => { ExpressionValue.defaultEnvironment, ) ) - ->Reducer_Helpers.rRemoveDefaults + ->Reducer_Helpers.rRemoveDefaultsInternal ->ExpressionValue.toStringResultOkless (a1, a2)->expect->toEqual((answer, v)) } diff --git a/packages/squiggle-lang/__tests__/Reducer/Reducer_Peggy/Reducer_Peggy_ToExpression_test.res b/packages/squiggle-lang/__tests__/Reducer/Reducer_Peggy/Reducer_Peggy_ToExpression_test.res index 92491e8f..18e8121d 100644 --- a/packages/squiggle-lang/__tests__/Reducer/Reducer_Peggy/Reducer_Peggy_ToExpression_test.res +++ b/packages/squiggle-lang/__tests__/Reducer/Reducer_Peggy/Reducer_Peggy_ToExpression_test.res @@ -22,11 +22,11 @@ describe("Peggy to Expression", () => { describe("multi-line", () => { testToExpression("x=1; 2", "{(:$_let_$ :x {1}); 2}", ~v="2", ()) - testToExpression("x=1; y=2", "{(:$_let_$ :x {1}); (:$_let_$ :y {2})}", ~v="{x: 1,y: 2}", ()) + testToExpression("x=1; y=2", "{(:$_let_$ :x {1}); (:$_let_$ :y {2})}", ~v="@{x: 1,y: 2}", ()) }) describe("variables", () => { - testToExpression("x = 1", "{(:$_let_$ :x {1})}", ~v="{x: 1}", ()) + testToExpression("x = 1", "{(:$_let_$ :x {1})}", ~v="@{x: 1}", ()) testToExpression("x", "{:x}", ~v=":x", ()) //TODO: value should return error testToExpression("x = 1; x", "{(:$_let_$ :x {1}); :x}", ~v="1", ()) }) @@ -35,7 +35,7 @@ describe("Peggy to Expression", () => { testToExpression( "identity(x) = x", "{(:$_let_$ :identity (:$$_lambda_$$ [x] {:x}))}", - ~v="{identity: lambda(x=>internal code)}", + ~v="@{identity: lambda(x=>internal code)}", (), ) // Function definitions become lambda assignments testToExpression("identity(x)", "{(:identity :x)}", ()) // Note value returns error properly @@ -155,7 +155,7 @@ describe("Peggy to Expression", () => { testToExpression( "y=99; x={y=1; y}", "{(:$_let_$ :y {99}); (:$_let_$ :x {(:$_let_$ :y {1}); :y})}", - ~v="{x: 1,y: 99}", + ~v="@{x: 1,y: 99}", (), ) }) @@ -165,19 +165,19 @@ describe("Peggy to Expression", () => { testToExpression( "f={|x| x}", "{(:$_let_$ :f {(:$$_lambda_$$ [x] {:x})})}", - ~v="{f: lambda(x=>internal code)}", + ~v="@{f: lambda(x=>internal code)}", (), ) testToExpression( "f(x)=x", "{(:$_let_$ :f (:$$_lambda_$$ [x] {:x}))}", - ~v="{f: lambda(x=>internal code)}", + ~v="@{f: lambda(x=>internal code)}", (), ) // Function definitions are lambda assignments testToExpression( "f(x)=x ? 1 : 0", "{(:$_let_$ :f (:$$_lambda_$$ [x] {(:$$_ternary_$$ :x 1 0)}))}", - ~v="{f: lambda(x=>internal code)}", + ~v="@{f: lambda(x=>internal code)}", (), ) }) diff --git a/packages/squiggle-lang/__tests__/Reducer/Reducer_Peggy/Reducer_Peggy_ToExpression_type_test.res b/packages/squiggle-lang/__tests__/Reducer/Reducer_Peggy/Reducer_Peggy_ToExpression_type_test.res index e5609aea..12d2d62b 100644 --- a/packages/squiggle-lang/__tests__/Reducer/Reducer_Peggy/Reducer_Peggy_ToExpression_type_test.res +++ b/packages/squiggle-lang/__tests__/Reducer/Reducer_Peggy/Reducer_Peggy_ToExpression_type_test.res @@ -6,7 +6,7 @@ describe("Peggy Types to Expression", () => { testToExpression( "p: number", "{(:$_typeOf_$ :p #number)}", - ~v="{_typeReferences_: {p: #number}}", + ~v="@{_typeReferences_: {p: #number}}", (), ) }) @@ -14,7 +14,7 @@ describe("Peggy Types to Expression", () => { testToExpression( "type index=number", "{(:$_typeAlias_$ #index #number)}", - ~v="{_typeAliases_: {index: #number}}", + ~v="@{_typeAliases_: {index: #number}}", (), ) }) @@ -22,7 +22,7 @@ describe("Peggy Types to Expression", () => { testToExpression( "answer: number|string|distribution", "{(:$_typeOf_$ :answer (:$_typeOr_$ (:$_constructArray_$ (#number #string #distribution))))}", - ~v="{_typeReferences_: {answer: {typeTag: 'typeOr',typeOr: [#number,#string,#distribution]}}}", + ~v="@{_typeReferences_: {answer: {typeOr: [#number,#string,#distribution],typeTag: 'typeOr'}}}", (), ) }) @@ -30,13 +30,13 @@ describe("Peggy Types to Expression", () => { testToExpression( "f: number=>number=>number", "{(:$_typeOf_$ :f (:$_typeFunction_$ (:$_constructArray_$ (#number #number #number))))}", - ~v="{_typeReferences_: {f: {typeTag: 'typeFunction',inputs: [#number,#number],output: #number}}}", + ~v="@{_typeReferences_: {f: {inputs: [#number,#number],output: #number,typeTag: 'typeFunction'}}}", (), ) testToExpression( "f: number=>number", "{(:$_typeOf_$ :f (:$_typeFunction_$ (:$_constructArray_$ (#number #number))))}", - ~v="{_typeReferences_: {f: {typeTag: 'typeFunction',inputs: [#number],output: #number}}}", + ~v="@{_typeReferences_: {f: {inputs: [#number],output: #number,typeTag: 'typeFunction'}}}", (), ) }) @@ -44,37 +44,37 @@ describe("Peggy Types to Expression", () => { testToExpression( "answer: number<-min(1)<-max(100)|string", "{(:$_typeOf_$ :answer (:$_typeOr_$ (:$_constructArray_$ ((:$_typeModifier_max_$ (:$_typeModifier_min_$ #number 1) 100) #string))))}", - ~v="{_typeReferences_: {answer: {typeTag: 'typeOr',typeOr: [{typeTag: 'typeIdentifier',typeIdentifier: #number,min: 1,max: 100},#string]}}}", + ~v="@{_typeReferences_: {answer: {typeOr: [{max: 100,min: 1,typeIdentifier: #number,typeTag: 'typeIdentifier'},#string],typeTag: 'typeOr'}}}", (), ) testToExpression( "answer: number<-memberOf([1,3,5])", "{(:$_typeOf_$ :answer (:$_typeModifier_memberOf_$ #number (:$_constructArray_$ (1 3 5))))}", - ~v="{_typeReferences_: {answer: {typeTag: 'typeIdentifier',typeIdentifier: #number,memberOf: [1,3,5]}}}", + ~v="@{_typeReferences_: {answer: {memberOf: [1,3,5],typeIdentifier: #number,typeTag: 'typeIdentifier'}}}", (), ) testToExpression( "answer: number<-min(1)", "{(:$_typeOf_$ :answer (:$_typeModifier_min_$ #number 1))}", - ~v="{_typeReferences_: {answer: {typeTag: 'typeIdentifier',typeIdentifier: #number,min: 1}}}", + ~v="@{_typeReferences_: {answer: {min: 1,typeIdentifier: #number,typeTag: 'typeIdentifier'}}}", (), ) testToExpression( "answer: number<-max(10)", "{(:$_typeOf_$ :answer (:$_typeModifier_max_$ #number 10))}", - ~v="{_typeReferences_: {answer: {typeTag: 'typeIdentifier',typeIdentifier: #number,max: 10}}}", + ~v="@{_typeReferences_: {answer: {max: 10,typeIdentifier: #number,typeTag: 'typeIdentifier'}}}", (), ) testToExpression( "answer: number<-min(1)<-max(10)", "{(:$_typeOf_$ :answer (:$_typeModifier_max_$ (:$_typeModifier_min_$ #number 1) 10))}", - ~v="{_typeReferences_: {answer: {typeTag: 'typeIdentifier',typeIdentifier: #number,min: 1,max: 10}}}", + ~v="@{_typeReferences_: {answer: {max: 10,min: 1,typeIdentifier: #number,typeTag: 'typeIdentifier'}}}", (), ) testToExpression( "answer: number<-max(10)<-min(1)", "{(:$_typeOf_$ :answer (:$_typeModifier_min_$ (:$_typeModifier_max_$ #number 10) 1))}", - ~v="{_typeReferences_: {answer: {typeTag: 'typeIdentifier',typeIdentifier: #number,max: 10,min: 1}}}", + ~v="@{_typeReferences_: {answer: {max: 10,min: 1,typeIdentifier: #number,typeTag: 'typeIdentifier'}}}", (), ) }) @@ -82,7 +82,7 @@ describe("Peggy Types to Expression", () => { testToExpression( "answer: number | string $ opaque", "{(:$_typeOf_$ :answer (:$_typeModifier_opaque_$ (:$_typeOr_$ (:$_constructArray_$ (#number #string)))))}", - ~v="{_typeReferences_: {answer: {typeTag: 'typeOr',typeOr: [#number,#string],opaque: true}}}", + ~v="@{_typeReferences_: {answer: {opaque: true,typeOr: [#number,#string],typeTag: 'typeOr'}}}", (), ) }) @@ -90,7 +90,7 @@ describe("Peggy Types to Expression", () => { testToExpression( "odds1 = [1,3,5]; odds2 = [7, 9]; type odds = number<-memberOf(concat(odds1, odds2))", "{(:$_let_$ :odds1 {(:$_constructArray_$ (1 3 5))}); (:$_let_$ :odds2 {(:$_constructArray_$ (7 9))}); (:$_typeAlias_$ #odds (:$_typeModifier_memberOf_$ #number (:concat :odds1 :odds2)))}", - ~v="{_typeAliases_: {odds: {typeTag: 'typeIdentifier',typeIdentifier: #number,memberOf: [1,3,5,7,9]}},odds1: [1,3,5],odds2: [7,9]}", + ~v="@{_typeAliases_: {odds: {memberOf: [1,3,5,7,9],typeIdentifier: #number,typeTag: 'typeIdentifier'}},odds1: [1,3,5],odds2: [7,9]}", (), ) }) diff --git a/packages/squiggle-lang/__tests__/Reducer/Reducer_TestHelpers.res b/packages/squiggle-lang/__tests__/Reducer/Reducer_TestHelpers.res index 2c7dfb21..736c9c2f 100644 --- a/packages/squiggle-lang/__tests__/Reducer/Reducer_TestHelpers.res +++ b/packages/squiggle-lang/__tests__/Reducer/Reducer_TestHelpers.res @@ -1,7 +1,6 @@ module ExpressionT = Reducer_Expression_T -module ExpressionValue = ReducerInterface.ExpressionValue +module ExternalExpressionValue = ReducerInterface.ExternalExpressionValue module ErrorValue = Reducer_ErrorValue -module Bindings = Reducer_Category_Bindings open Jest open Expect @@ -9,7 +8,7 @@ open Expect let unwrapRecord = rValue => rValue->Belt.Result.flatMap(value => switch value { - | ExpressionValue.EvRecord(aRecord) => Ok(aRecord) + | ExternalExpressionValue.EvRecord(aRecord) => Ok(aRecord) | _ => ErrorValue.RETodo("TODO: External bindings must be returned")->Error } ) @@ -19,18 +18,18 @@ let expectParseToBe = (expr: string, answer: string) => let expectEvalToBe = (expr: string, answer: string) => Reducer.evaluate(expr) - ->Reducer_Helpers.rRemoveDefaults - ->ExpressionValue.toStringResult + ->Reducer_Helpers.rRemoveDefaultsExternal + ->ExternalExpressionValue.toStringResult ->expect ->toBe(answer) let expectEvalError = (expr: string) => - Reducer.evaluate(expr)->ExpressionValue.toStringResult->expect->toMatch("Error\(") + Reducer.evaluate(expr)->ExternalExpressionValue.toStringResult->expect->toMatch("Error\(") let expectEvalBindingsToBe = (expr: string, bindings: Reducer.externalBindings, answer: string) => Reducer.evaluateUsingOptions(expr, ~externalBindings=Some(bindings), ~environment=None) - ->Reducer_Helpers.rRemoveDefaults - ->ExpressionValue.toStringResult + ->Reducer_Helpers.rRemoveDefaultsExternal + ->ExternalExpressionValue.toStringResult ->expect ->toBe(answer) diff --git a/packages/squiggle-lang/__tests__/Reducer/Reducer_TestMacroHelpers.res b/packages/squiggle-lang/__tests__/Reducer/Reducer_TestMacroHelpers.res index 330f7da0..1383d45e 100644 --- a/packages/squiggle-lang/__tests__/Reducer/Reducer_TestMacroHelpers.res +++ b/packages/squiggle-lang/__tests__/Reducer/Reducer_TestMacroHelpers.res @@ -1,25 +1,27 @@ open Jest open Expect -module Bindings = Reducer_Expression_Bindings +module BindingsReplacer = Reducer_Expression_BindingsReplacer module Expression = Reducer_Expression -module ExpressionValue = ReducerInterface_ExpressionValue +// module ExpressionValue = ReducerInterface.ExpressionValue +module InternalExpressionValue = ReducerInterface.InternalExpressionValue module ExpressionWithContext = Reducer_ExpressionWithContext module Macro = Reducer_Expression_Macro module T = Reducer_Expression_T +module Module = Reducer_Category_Module let testMacro_ = ( tester, - bindArray: array<(string, ExpressionValue.expressionValue)>, + bindArray: array<(string, InternalExpressionValue.expressionValue)>, expr: T.expression, expectedCode: string, ) => { - let bindings = Belt.Map.String.fromArray(bindArray) + let bindings = Module.fromArray(bindArray) tester(expr->T.toString, () => expr ->Macro.expandMacroCall( bindings, - ExpressionValue.defaultEnvironment, + InternalExpressionValue.defaultEnvironment, Expression.reduceExpression, ) ->ExpressionWithContext.toStringResult @@ -30,39 +32,43 @@ let testMacro_ = ( let testMacroEval_ = ( tester, - bindArray: array<(string, ExpressionValue.expressionValue)>, + bindArray: array<(string, InternalExpressionValue.expressionValue)>, expr: T.expression, expectedValue: string, ) => { - let bindings = Belt.Map.String.fromArray(bindArray) + let bindings = Module.fromArray(bindArray) tester(expr->T.toString, () => expr - ->Macro.doMacroCall(bindings, ExpressionValue.defaultEnvironment, Expression.reduceExpression) - ->ExpressionValue.toStringResult + ->Macro.doMacroCall( + bindings, + InternalExpressionValue.defaultEnvironment, + Expression.reduceExpression, + ) + ->InternalExpressionValue.toStringResult ->expect ->toEqual(expectedValue) ) } let testMacro = ( - bindArray: array<(string, ExpressionValue.expressionValue)>, + bindArray: array<(string, InternalExpressionValue.expressionValue)>, expr: T.expression, expectedExpr: string, ) => testMacro_(test, bindArray, expr, expectedExpr) let testMacroEval = ( - bindArray: array<(string, ExpressionValue.expressionValue)>, + bindArray: array<(string, InternalExpressionValue.expressionValue)>, expr: T.expression, expectedValue: string, ) => testMacroEval_(test, bindArray, expr, expectedValue) module MySkip = { let testMacro = ( - bindArray: array<(string, ExpressionValue.expressionValue)>, + bindArray: array<(string, InternalExpressionValue.expressionValue)>, expr: T.expression, expectedExpr: string, ) => testMacro_(Skip.test, bindArray, expr, expectedExpr) let testMacroEval = ( - bindArray: array<(string, ExpressionValue.expressionValue)>, + bindArray: array<(string, InternalExpressionValue.expressionValue)>, expr: T.expression, expectedValue: string, ) => testMacroEval_(Skip.test, bindArray, expr, expectedValue) @@ -70,12 +76,12 @@ module MySkip = { module MyOnly = { let testMacro = ( - bindArray: array<(string, ExpressionValue.expressionValue)>, + bindArray: array<(string, InternalExpressionValue.expressionValue)>, expr: T.expression, expectedExpr: string, ) => testMacro_(Only.test, bindArray, expr, expectedExpr) let testMacroEval = ( - bindArray: array<(string, ExpressionValue.expressionValue)>, + bindArray: array<(string, InternalExpressionValue.expressionValue)>, expr: T.expression, expectedValue: string, ) => testMacroEval_(Only.test, bindArray, expr, expectedValue) diff --git a/packages/squiggle-lang/__tests__/Reducer/Reducer_externalBindings_test.res b/packages/squiggle-lang/__tests__/Reducer/Reducer_externalBindings_test.res index 1fcd3fbf..bb1a4d35 100644 --- a/packages/squiggle-lang/__tests__/Reducer/Reducer_externalBindings_test.res +++ b/packages/squiggle-lang/__tests__/Reducer/Reducer_externalBindings_test.res @@ -1,11 +1,14 @@ -// TODO: Reimplement with usual parse open Jest open Reducer_TestHelpers describe("Eval with Bindings", () => { - testEvalBindingsToBe("x", list{("x", ExpressionValue.EvNumber(1.))}, "Ok(1)") - testEvalBindingsToBe("x+1", list{("x", ExpressionValue.EvNumber(1.))}, "Ok(2)") + testEvalBindingsToBe("x", list{("x", ExternalExpressionValue.EvNumber(1.))}, "Ok(1)") + testEvalBindingsToBe("x+1", list{("x", ExternalExpressionValue.EvNumber(1.))}, "Ok(2)") testParseToBe("y = x+1; y", "Ok({(:$_let_$ :y {(:add :x 1)}); :y})") - testEvalBindingsToBe("y = x+1; y", list{("x", ExpressionValue.EvNumber(1.))}, "Ok(2)") - testEvalBindingsToBe("y = x+1", list{("x", ExpressionValue.EvNumber(1.))}, "Ok({x: 1,y: 2})") + testEvalBindingsToBe("y = x+1; y", list{("x", ExternalExpressionValue.EvNumber(1.))}, "Ok(2)") + testEvalBindingsToBe( + "y = x+1", + list{("x", ExternalExpressionValue.EvNumber(1.))}, + "Ok(@{x: 1,y: 2})", + ) }) diff --git a/packages/squiggle-lang/__tests__/Reducer/Reducer_functionTricks_test.res b/packages/squiggle-lang/__tests__/Reducer/Reducer_functionTricks_test.res index ca6f0399..68614f89 100644 --- a/packages/squiggle-lang/__tests__/Reducer/Reducer_functionTricks_test.res +++ b/packages/squiggle-lang/__tests__/Reducer/Reducer_functionTricks_test.res @@ -39,15 +39,15 @@ describe("symbol not defined", () => { }) describe("call and bindings", () => { - testEvalToBe("f(x)=x+1", "Ok({f: lambda(x=>internal code)})") + testEvalToBe("f(x)=x+1", "Ok(@{f: lambda(x=>internal code)})") testEvalToBe("f(x)=x+1; f(1)", "Ok(2)") - testEvalToBe("f=1;y=2", "Ok({f: 1,y: 2})") - testEvalToBe("f(x)=x+1; y=f(1)", "Ok({f: lambda(x=>internal code),y: 2})") + testEvalToBe("f=1;y=2", "Ok(@{f: 1,y: 2})") + testEvalToBe("f(x)=x+1; y=f(1)", "Ok(@{f: lambda(x=>internal code),y: 2})") testEvalToBe("f(x)=x+1; y=f(1); f(1)", "Ok(2)") - testEvalToBe("f(x)=x+1; y=f(1); z=f(1)", "Ok({f: lambda(x=>internal code),y: 2,z: 2})") + testEvalToBe("f(x)=x+1; y=f(1); z=f(1)", "Ok(@{f: lambda(x=>internal code),y: 2,z: 2})") testEvalToBe( "f(x)=x+1; g(x)=f(x)+1", - "Ok({f: lambda(x=>internal code),g: lambda(x=>internal code)})", + "Ok(@{f: lambda(x=>internal code),g: lambda(x=>internal code)})", ) testParseToBe( "f=99; g(x)=f; g(2)", @@ -57,7 +57,7 @@ describe("call and bindings", () => { testEvalToBe("f(x)=x; g(x)=f(x); g(2)", "Ok(2)") testEvalToBe( "f(x)=x+1; g(x)=f(x)+1; y=g(2)", - "Ok({f: lambda(x=>internal code),g: lambda(x=>internal code),y: 4})", + "Ok(@{f: lambda(x=>internal code),g: lambda(x=>internal code),y: 4})", ) testEvalToBe("f(x)=x+1; g(x)=f(x)+1; g(2)", "Ok(4)") }) @@ -65,7 +65,7 @@ describe("call and bindings", () => { describe("function tricks", () => { testEvalError("f(x)=f(y)=2; f(2)") //Error because chain assignment is not allowed testEvalToBe("y=2;g(x)=y+1;g(2)", "Ok(3)") - testEvalToBe("y=2;g(x)=inspect(y)+1", "Ok({g: lambda(x=>internal code),y: 2})") + testEvalToBe("y=2;g(x)=inspect(y)+1", "Ok(@{g: lambda(x=>internal code),y: 2})") MySkip.testEvalToBe("f(x) = x(x); f(f)", "????") // TODO: Infinite loop. Any solution? Catching proper exception or timeout? MySkip.testEvalToBe("f(x, x)=x+x; f(1,2)", "????") // TODO: Duplicate parameters testEvalToBe("myadd(x,y)=x+y; z=myadd; z", "Ok(lambda(x,y=>internal code))") @@ -75,7 +75,7 @@ describe("function tricks", () => { describe("lambda in structures", () => { testEvalToBe( "myadd(x,y)=x+y; z=[myadd]", - "Ok({myadd: lambda(x,y=>internal code),z: [lambda(x,y=>internal code)]})", + "Ok(@{myadd: lambda(x,y=>internal code),z: [lambda(x,y=>internal code)]})", ) testEvalToBe("myadd(x,y)=x+y; z=[myadd]; z[0]", "Ok(lambda(x,y=>internal code))") testEvalToBe("myadd(x,y)=x+y; z=[myadd]; z[0](3,2)", "Ok(5)") diff --git a/packages/squiggle-lang/__tests__/Reducer/Reducer_test.res b/packages/squiggle-lang/__tests__/Reducer/Reducer_test.res index 32aad5d3..39f387a1 100644 --- a/packages/squiggle-lang/__tests__/Reducer/Reducer_test.res +++ b/packages/squiggle-lang/__tests__/Reducer/Reducer_test.res @@ -39,7 +39,7 @@ describe("eval", () => { testEvalToBe("x=1; y=x+1; y+1", "Ok(3)") testEvalError("1; x=1") testEvalError("1; 1") - testEvalToBe("x=1; x=1", "Ok({x: 1})") + testEvalToBe("x=1; x=1", "Ok(@{x: 1})") }) }) diff --git a/packages/squiggle-lang/__tests__/ReducerInterface/ReducerInterface_ExpressionValue_test.res b/packages/squiggle-lang/__tests__/ReducerInterface/ReducerInterface_ExpressionValue_test.res index 888aca7e..b09e20ae 100644 --- a/packages/squiggle-lang/__tests__/ReducerInterface/ReducerInterface_ExpressionValue_test.res +++ b/packages/squiggle-lang/__tests__/ReducerInterface/ReducerInterface_ExpressionValue_test.res @@ -1,4 +1,4 @@ -open ReducerInterface.ExpressionValue +open ReducerInterface.ExternalExpressionValue open Jest open Expect diff --git a/packages/squiggle-lang/package.json b/packages/squiggle-lang/package.json index abc9f239..45b22d98 100644 --- a/packages/squiggle-lang/package.json +++ b/packages/squiggle-lang/package.json @@ -5,6 +5,7 @@ "license": "MIT", "scripts": { "peggy": "peggy --cache", + "rescript": "rescript", "build": "yarn build:peggy && yarn build:rescript && yarn build:typescript", "build:peggy": "find . -type f -name *.peggy -exec yarn peggy {} \\;", "build:rescript": "rescript build -with-deps", diff --git a/packages/squiggle-lang/src/rescript/Distributions/PointSetDist/Discrete.res b/packages/squiggle-lang/src/rescript/Distributions/PointSetDist/Discrete.res index fea5db6f..08874121 100644 --- a/packages/squiggle-lang/src/rescript/Distributions/PointSetDist/Discrete.res +++ b/packages/squiggle-lang/src/rescript/Distributions/PointSetDist/Discrete.res @@ -1,3 +1,4 @@ +@@warning("-27") //TODO: Remove and fix the warning open Distributions type t = PointSetTypes.discreteShape diff --git a/packages/squiggle-lang/src/rescript/Distributions/PointSetDist/Mixed.res b/packages/squiggle-lang/src/rescript/Distributions/PointSetDist/Mixed.res index 42a88909..4d8542f4 100644 --- a/packages/squiggle-lang/src/rescript/Distributions/PointSetDist/Mixed.res +++ b/packages/squiggle-lang/src/rescript/Distributions/PointSetDist/Mixed.res @@ -1,3 +1,5 @@ +@@warning("-27") //TODO: Remove and fix the warning +@@warning("-32") //TODO: Remove and fix the warning open Distributions type t = PointSetTypes.mixedShape diff --git a/packages/squiggle-lang/src/rescript/FunctionRegistry/FunctionRegistry_Core.res b/packages/squiggle-lang/src/rescript/FunctionRegistry/FunctionRegistry_Core.res index 22323e80..cf19fd63 100644 --- a/packages/squiggle-lang/src/rescript/FunctionRegistry/FunctionRegistry_Core.res +++ b/packages/squiggle-lang/src/rescript/FunctionRegistry/FunctionRegistry_Core.res @@ -1,4 +1,4 @@ -type expressionValue = ReducerInterface_ExpressionValue.expressionValue +type expressionValue = ReducerInterface_InternalExpressionValue.expressionValue /* Function Registry "Type". A type, without any other information. @@ -28,7 +28,7 @@ type rec frValue = | FRValueArray(array) | FRValueDistOrNumber(frValueDistOrNumber) | FRValueRecord(frValueRecord) - | FRValueLambda(ReducerInterface_ExpressionValue.lambdaValue) + | FRValueLambda(ReducerInterface_InternalExpressionValue.lambdaValue) | FRValueString(string) | FRValueVariant(string) | FRValueAny(frValue) @@ -75,14 +75,14 @@ module FRType = { let rec toFrValue = (r: expressionValue): option => switch r { - | EvNumber(f) => Some(FRValueNumber(f)) - | EvString(f) => Some(FRValueString(f)) - | EvDistribution(f) => Some(FRValueDistOrNumber(FRValueDist(f))) - | EvLambda(f) => Some(FRValueLambda(f)) - | EvArray(elements) => + | IevNumber(f) => Some(FRValueNumber(f)) + | IevString(f) => Some(FRValueString(f)) + | IevDistribution(f) => Some(FRValueDistOrNumber(FRValueDist(f))) + | IevLambda(f) => Some(FRValueLambda(f)) + | IevArray(elements) => elements->E.A2.fmap(toFrValue)->E.A.O.openIfAllSome->E.O2.fmap(r => FRValueArray(r)) - | EvRecord(record) => - Js.Dict.entries(record) + | IevRecord(map) => + Belt.Map.String.toArray(map) ->E.A2.fmap(((key, item)) => item->toFrValue->E.O2.fmap(o => (key, o))) ->E.A.O.openIfAllSome ->E.O2.fmap(r => FRValueRecord(r)) @@ -92,28 +92,28 @@ module FRType = { let rec matchWithExpressionValue = (t: t, r: expressionValue): option => switch (t, r) { | (FRTypeAny, f) => toFrValue(f) - | (FRTypeString, EvString(f)) => Some(FRValueString(f)) - | (FRTypeNumber, EvNumber(f)) => Some(FRValueNumber(f)) - | (FRTypeDistOrNumber, EvNumber(f)) => Some(FRValueDistOrNumber(FRValueNumber(f))) - | (FRTypeDistOrNumber, EvDistribution(Symbolic(#Float(f)))) => + | (FRTypeString, IevString(f)) => Some(FRValueString(f)) + | (FRTypeNumber, IevNumber(f)) => Some(FRValueNumber(f)) + | (FRTypeDistOrNumber, IevNumber(f)) => Some(FRValueDistOrNumber(FRValueNumber(f))) + | (FRTypeDistOrNumber, IevDistribution(Symbolic(#Float(f)))) => Some(FRValueDistOrNumber(FRValueNumber(f))) - | (FRTypeDistOrNumber, EvDistribution(f)) => Some(FRValueDistOrNumber(FRValueDist(f))) - | (FRTypeNumeric, EvNumber(f)) => Some(FRValueNumber(f)) - | (FRTypeNumeric, EvDistribution(Symbolic(#Float(f)))) => Some(FRValueNumber(f)) - | (FRTypeLambda, EvLambda(f)) => Some(FRValueLambda(f)) - | (FRTypeArray(intendedType), EvArray(elements)) => { + | (FRTypeDistOrNumber, IevDistribution(f)) => Some(FRValueDistOrNumber(FRValueDist(f))) + | (FRTypeNumeric, IevNumber(f)) => Some(FRValueNumber(f)) + | (FRTypeNumeric, IevDistribution(Symbolic(#Float(f)))) => Some(FRValueNumber(f)) + | (FRTypeLambda, IevLambda(f)) => Some(FRValueLambda(f)) + | (FRTypeArray(intendedType), IevArray(elements)) => { let el = elements->E.A2.fmap(matchWithExpressionValue(intendedType)) E.A.O.openIfAllSome(el)->E.O2.fmap(r => FRValueArray(r)) } - | (FRTypeDict(r), EvRecord(record)) => - record - ->Js.Dict.entries + | (FRTypeDict(r), IevRecord(map)) => + map + ->Belt.Map.String.toArray ->E.A2.fmap(((key, item)) => matchWithExpressionValue(r, item)->E.O2.fmap(o => (key, o))) ->E.A.O.openIfAllSome ->E.O2.fmap(r => FRValueDict(Js.Dict.fromArray(r))) - | (FRTypeRecord(recordParams), EvRecord(record)) => { + | (FRTypeRecord(recordParams), IevRecord(map)) => { let getAndMatch = (name, input) => - E.Dict.get(record, name)->E.O.bind(matchWithExpressionValue(input)) + Belt.Map.String.get(map, name)->E.O.bind(matchWithExpressionValue(input)) //All names in the type must be present. If any are missing, the corresponding //value will be None, and this function would return None. let namesAndValues: array> = @@ -127,27 +127,29 @@ module FRType = { let rec matchReverse = (e: frValue): expressionValue => switch e { - | FRValueNumber(f) => EvNumber(f) - | FRValueDistOrNumber(FRValueNumber(n)) => EvNumber(n) - | FRValueDistOrNumber(FRValueDist(n)) => EvDistribution(n) - | FRValueDist(dist) => EvDistribution(dist) - | FRValueArray(elements) => EvArray(elements->E.A2.fmap(matchReverse)) + | FRValueNumber(f) => IevNumber(f) + | FRValueDistOrNumber(FRValueNumber(n)) => IevNumber(n) + | FRValueDistOrNumber(FRValueDist(n)) => IevDistribution(n) + | FRValueDist(dist) => IevDistribution(dist) + | FRValueArray(elements) => IevArray(elements->E.A2.fmap(matchReverse)) | FRValueRecord(frValueRecord) => { - let record = - frValueRecord->E.A2.fmap(((name, value)) => (name, matchReverse(value)))->E.Dict.fromArray - EvRecord(record) + let map = + frValueRecord + ->E.A2.fmap(((name, value)) => (name, matchReverse(value))) + ->Belt.Map.String.fromArray + IevRecord(map) } | FRValueDict(frValueRecord) => { - let record = + let map = frValueRecord ->Js.Dict.entries ->E.A2.fmap(((name, value)) => (name, matchReverse(value))) - ->E.Dict.fromArray - EvRecord(record) + ->Belt.Map.String.fromArray + IevRecord(map) } - | FRValueLambda(l) => EvLambda(l) - | FRValueString(string) => EvString(string) - | FRValueVariant(string) => EvString(string) + | FRValueLambda(l) => IevLambda(l) + | FRValueString(string) => IevString(string) + | FRValueVariant(string) => IevString(string) | FRValueAny(f) => matchReverse(f) } diff --git a/packages/squiggle-lang/src/rescript/FunctionRegistry/FunctionRegistry_Helpers.res b/packages/squiggle-lang/src/rescript/FunctionRegistry/FunctionRegistry_Helpers.res index 7d0240eb..6da4d819 100644 --- a/packages/squiggle-lang/src/rescript/FunctionRegistry/FunctionRegistry_Helpers.res +++ b/packages/squiggle-lang/src/rescript/FunctionRegistry/FunctionRegistry_Helpers.res @@ -4,11 +4,11 @@ let impossibleError = "Wrong inputs / Logically impossible" module Wrappers = { let symbolic = r => DistributionTypes.Symbolic(r) - let evDistribution = r => ReducerInterface_ExpressionValue.EvDistribution(r) - let evNumber = r => ReducerInterface_ExpressionValue.EvNumber(r) - let evArray = r => ReducerInterface_ExpressionValue.EvArray(r) - let evRecord = r => ReducerInterface_ExpressionValue.EvRecord(r) - let evString = r => ReducerInterface_ExpressionValue.EvString(r) + let evDistribution = r => ReducerInterface_InternalExpressionValue.IevDistribution(r) + let evNumber = r => ReducerInterface_InternalExpressionValue.IevNumber(r) + let evArray = r => ReducerInterface_InternalExpressionValue.IevArray(r) + let evRecord = r => ReducerInterface_InternalExpressionValue.IevRecord(r) + let evString = r => ReducerInterface_InternalExpressionValue.IevString(r) let symbolicEvDistribution = r => r->DistributionTypes.Symbolic->evDistribution } diff --git a/packages/squiggle-lang/src/rescript/FunctionRegistry/FunctionRegistry_Library.res b/packages/squiggle-lang/src/rescript/FunctionRegistry/FunctionRegistry_Library.res index 74929c0b..53c9fdde 100644 --- a/packages/squiggle-lang/src/rescript/FunctionRegistry/FunctionRegistry_Library.res +++ b/packages/squiggle-lang/src/rescript/FunctionRegistry/FunctionRegistry_Library.res @@ -20,7 +20,7 @@ module Declaration = { inputs ->E.A2.fmap(getMinMax) ->E.A.R.firstErrorOrOpen - ->E.R2.fmap(args => ReducerInterface_ExpressionValue.EvDeclaration( + ->E.R2.fmap(args => ReducerInterface_InternalExpressionValue.IevDeclaration( Declaration.make(lambda, args), )) } @@ -43,7 +43,9 @@ let inputsTodist = (inputs: array, makeDist) => { let expressionValue = xyCoords ->E.R.bind(r => r->XYShape.T.makeFromZipped->E.R2.errMap(XYShape.Error.toString)) - ->E.R2.fmap(r => ReducerInterface_ExpressionValue.EvDistribution(PointSet(makeDist(r)))) + ->E.R2.fmap(r => ReducerInterface_InternalExpressionValue.IevDistribution( + PointSet(makeDist(r)), + )) expressionValue } @@ -369,7 +371,7 @@ to(5,10) E.Dict.concat(d1, d2) |> Js.Dict.map((. r) => FunctionRegistry_Core.FRType.matchReverse(r) ) - newDict->Wrappers.evRecord->Ok + newDict->Js.Dict.entries->Belt.Map.String.fromArray->Wrappers.evRecord->Ok } | _ => Error(impossibleError) } @@ -390,6 +392,7 @@ to(5,10) ->Prepare.ToTypedArray.dicts ->E.R2.fmap(E.Dict.concatMany) ->E.R2.fmap(Js.Dict.map((. r) => FunctionRegistry_Core.FRType.matchReverse(r))) + ->E.R2.fmap(r => r->Js.Dict.entries->Belt.Map.String.fromArray) ->E.R2.fmap(Wrappers.evRecord) ), ], @@ -462,7 +465,7 @@ to(5,10) } }) ->E.A.R.firstErrorOrOpen - ->E.R2.fmap(Js.Dict.fromArray) + ->E.R2.fmap(Belt.Map.String.fromArray) ->E.R2.fmap(Wrappers.evRecord) inputs->getOrError(0)->E.R.bind(Prepare.ToValueArray.Array.arrayOfArrays) |> E.R2.bind(convertInternalItems) diff --git a/packages/squiggle-lang/src/rescript/Reducer/Reducer.res b/packages/squiggle-lang/src/rescript/Reducer/Reducer.res index dfedffc7..34ca2595 100644 --- a/packages/squiggle-lang/src/rescript/Reducer/Reducer.res +++ b/packages/squiggle-lang/src/rescript/Reducer/Reducer.res @@ -1,13 +1,14 @@ module ErrorValue = Reducer_ErrorValue module Expression = Reducer_Expression -module ExpressionValue = ReducerInterface_ExpressionValue +module ExternalExpressionValue = ReducerInterface_ExpressionValue +module InternalExpressionValue = ReducerInterface_InternalExpressionValue module Lambda = Reducer_Expression_Lambda -type environment = ReducerInterface_ExpressionValue.environment +type environment = ReducerInterface_InternalExpressionValue.environment type errorValue = Reducer_ErrorValue.errorValue -type expressionValue = ReducerInterface_ExpressionValue.expressionValue +type expressionValue = ExternalExpressionValue.expressionValue type externalBindings = ReducerInterface_ExpressionValue.externalBindings -type lambdaValue = ExpressionValue.lambdaValue +type lambdaValue = ExternalExpressionValue.lambdaValue let evaluate = Expression.evaluate let evaluateUsingOptions = Expression.evaluateUsingOptions @@ -15,13 +16,20 @@ let evaluatePartialUsingExternalBindings = Expression.evaluatePartialUsingExtern let parse = Expression.parse let foreignFunctionInterface = ( - lambdaValue: lambdaValue, + lambdaValue: ExternalExpressionValue.lambdaValue, argArray: array, - environment: ExpressionValue.environment, + environment: ExternalExpressionValue.environment, ) => { - Lambda.foreignFunctionInterface(lambdaValue, argArray, environment, Expression.reduceExpression) + let internallambdaValue = InternalExpressionValue.lambdaValueToInternal(lambdaValue) + let internalArgArray = argArray->Js.Array2.map(InternalExpressionValue.toInternal) + Lambda.foreignFunctionInterface( + internallambdaValue, + internalArgArray, + environment, + Expression.reduceExpression, + )->Belt.Result.map(InternalExpressionValue.toExternal) } -let defaultEnvironment = ExpressionValue.defaultEnvironment +let defaultEnvironment = ExternalExpressionValue.defaultEnvironment let defaultExternalBindings = ReducerInterface_StdLib.externalStdLib diff --git a/packages/squiggle-lang/src/rescript/Reducer/Reducer_Category/Reducer_Category_Bindings.res b/packages/squiggle-lang/src/rescript/Reducer/Reducer_Category/Reducer_Category_Bindings.res deleted file mode 100644 index 5a8e570d..00000000 --- a/packages/squiggle-lang/src/rescript/Reducer/Reducer_Category/Reducer_Category_Bindings.res +++ /dev/null @@ -1,12 +0,0 @@ -include Reducer_Category_Module // Bindings inherit from Module - -open ReducerInterface_ExpressionValue - -let emptyBindings = emptyModule - -let toExpressionValue = (container: t): expressionValue => EvRecord(toRecord(container)) -let fromExpressionValue = (aValue: expressionValue): t => - switch aValue { - | EvRecord(r) => fromRecord(r) - | _ => emptyBindings - } diff --git a/packages/squiggle-lang/src/rescript/Reducer/Reducer_Category/Reducer_Category_Module.res b/packages/squiggle-lang/src/rescript/Reducer/Reducer_Category/Reducer_Category_Module.res index 092d0690..b8056449 100644 --- a/packages/squiggle-lang/src/rescript/Reducer/Reducer_Category/Reducer_Category_Module.res +++ b/packages/squiggle-lang/src/rescript/Reducer/Reducer_Category/Reducer_Category_Module.res @@ -1,33 +1,112 @@ module ExpressionT = Reducer_Expression_T -open ReducerInterface_ExpressionValue +open ReducerInterface_InternalExpressionValue let expressionValueToString = toString -type t = ExpressionT.bindings +type t = ReducerInterface_InternalExpressionValue.nameSpace let typeAliasesKey = "_typeAliases_" let typeReferencesKey = "_typeReferences_" -let emptyModule: t = Belt.Map.String.empty +let getType = (nameSpace: t, id: string) => { + let NameSpace(container) = nameSpace + Belt.Map.String.get(container, typeAliasesKey)->Belt.Option.flatMap(aliases => + switch aliases { + | IevRecord(r) => Belt.Map.String.get(r, id) + | _ => None + } + ) +} -let cloneRecord = (r: record): record => r->Js.Dict.entries->Js.Dict.fromArray -let fromRecord = (r: record): t => Js.Dict.entries(r)->Belt.Map.String.fromArray -let toRecord = (container: t): record => Belt.Map.String.toArray(container)->Js.Dict.fromArray +let getTypeOf = (nameSpace: t, id: string) => { + let NameSpace(container) = nameSpace + Belt.Map.String.get(container, typeReferencesKey)->Belt.Option.flatMap(defs => + switch defs { + | IevRecord(r) => Belt.Map.String.get(r, id) + | _ => None + } + ) +} -let toExpressionValue = (container: t): expressionValue => EvModule(toRecord(container)) +let getWithDefault = (nameSpace: t, id: string, default) => { + let NameSpace(container) = nameSpace + Belt.Map.String.getWithDefault(container, id, default) +} + +let get = (nameSpace: t, id: string) => { + let NameSpace(container) = nameSpace + Belt.Map.String.get(container, id) +} + +let emptyMap: map = Belt.Map.String.empty + +let setTypeAlias = (nameSpace: t, id: string, value): t => { + let NameSpace(container) = nameSpace + let rValue = Belt.Map.String.getWithDefault(container, typeAliasesKey, IevRecord(emptyMap)) + let r = switch rValue { + | IevRecord(r) => r + | _ => emptyMap + } + let r2 = Belt.Map.String.set(r, id, value)->IevRecord + Belt.Map.String.set(container, typeAliasesKey, r2)->NameSpace +} + +let setTypeOf = (nameSpace: t, id: string, value): t => { + let NameSpace(container) = nameSpace + let rValue = Belt.Map.String.getWithDefault(container, typeReferencesKey, IevRecord(emptyMap)) + let r = switch rValue { + | IevRecord(r) => r + | _ => emptyMap + } + let r2 = Belt.Map.String.set(r, id, value)->IevRecord + Belt.Map.String.set(container, typeReferencesKey, r2)->NameSpace +} + +let set = (nameSpace: t, id: string, value): t => { + let NameSpace(container) = nameSpace + Belt.Map.String.set(container, id, value)->NameSpace +} + +let emptyModule: t = NameSpace(Belt.Map.String.empty) + +let fromTypeScriptBindings = ReducerInterface_InternalExpressionValue.nameSpaceFromTypeScriptBindings +let toTypeScriptBindings = ReducerInterface_InternalExpressionValue.nameSpaceToTypeScriptBindings + +let toExpressionValue = (nameSpace: t): expressionValue => IevModule(nameSpace) let fromExpressionValue = (aValue: expressionValue): t => switch aValue { - | EvModule(r) => fromRecord(r) + | IevModule(nameSpace) => nameSpace | _ => emptyModule } -let toString = (container: t): string => container->toRecord->EvRecord->expressionValueToString +let fromArray = a => Belt.Map.String.fromArray(a)->NameSpace + +let merge = (nameSpace: t, other: t): t => { + let NameSpace(container) = nameSpace + let NameSpace(otherContainer) = other + otherContainer + ->Belt.Map.String.reduce(container, (container, key, value) => + Belt.Map.String.set(container, key, value) + ) + ->NameSpace +} + +let removeOther = (nameSpace: t, other: t): t => { + let NameSpace(container) = nameSpace + let NameSpace(otherContainer) = other + let keys = Belt.Map.String.keysToArray(otherContainer) + Belt.Map.String.keep(container, (key, _value) => { + let removeThis = Js.Array2.includes(keys, key) + !removeThis + })->NameSpace +} // -- Module definition -let define = (container: t, identifier: string, ev: expressionValue): t => - Belt.Map.String.set(container, identifier, ev) // TODO build lambda for polymorphic functions here +let define = (nameSpace: t, identifier: string, ev: expressionValue): t => { + let NameSpace(container) = nameSpace + Belt.Map.String.set(container, identifier, ev)->NameSpace // TODO build lambda for polymorphic functions here +} +let defineNumber = (nameSpace: t, identifier: string, value: float): t => + nameSpace->define(identifier, IevNumber(value)) -let defineNumber = (container: t, identifier: string, value: float): t => - container->define(identifier, EvNumber(value)) - -let defineModule = (container: t, identifier: string, value: t): t => - container->define(identifier, toExpressionValue(value)) +let defineModule = (nameSpace: t, identifier: string, value: t): t => + nameSpace->define(identifier, toExpressionValue(value)) diff --git a/packages/squiggle-lang/src/rescript/Reducer/Reducer_Category/Reducer_Category_Module_TypeChecker.res b/packages/squiggle-lang/src/rescript/Reducer/Reducer_Category/Reducer_Category_Module_TypeChecker.res new file mode 100644 index 00000000..61dbfbb8 --- /dev/null +++ b/packages/squiggle-lang/src/rescript/Reducer/Reducer_Category/Reducer_Category_Module_TypeChecker.res @@ -0,0 +1,21 @@ +module ExpressionValue = ReducerInterface_InternalExpressionValue +module ExpressionT = Reducer_Expression_T +open ExpressionValue + +let isOfResolvedType = (aType, aValue) => { + let caseTypeIdentifier = (aTypeIdentifier0, aValue) => { + let valueType = aValue->valueToValueType->valueTypeToString->Js.String2.toLowerCase + let aTypeIdentifier = aTypeIdentifier0->Js.String2.toLowerCase + aTypeIdentifier === valueType + } + + switch aType { + | IevTypeIdentifier(aTypeIdentifier) => caseTypeIdentifier(aTypeIdentifier, aValue) + | _ => false + } +} + +// let compileTypeExpression = (typeExpression: string, bindings: ExpressionT.bindings, reducerFn: ExpressionT.reducerFn) => { +// statement = `type compiled=${typeExpression}` + +// } diff --git a/packages/squiggle-lang/src/rescript/Reducer/Reducer_Dispatch/Reducer_Dispatch_BuiltIn.res b/packages/squiggle-lang/src/rescript/Reducer/Reducer_Dispatch/Reducer_Dispatch_BuiltIn.res index 5d1ee5f3..847c290a 100644 --- a/packages/squiggle-lang/src/rescript/Reducer/Reducer_Dispatch/Reducer_Dispatch_BuiltIn.res +++ b/packages/squiggle-lang/src/rescript/Reducer/Reducer_Dispatch/Reducer_Dispatch_BuiltIn.res @@ -1,10 +1,11 @@ -module Bindings = Reducer_Expression_Bindings +module BindingsReplacer = Reducer_Expression_BindingsReplacer module ExpressionT = Reducer_Expression_T module ExternalLibrary = ReducerInterface.ExternalLibrary module Lambda = Reducer_Expression_Lambda module MathJs = Reducer_MathJs +module Module = Reducer_Category_Module module Result = Belt.Result -open ReducerInterface.ExpressionValue +open ReducerInterface_InternalExpressionValue open Reducer_ErrorValue /* @@ -31,12 +32,12 @@ let callInternal = (call: functionCall, environment, reducer: ExpressionT.reduce let constructRecord = arrayOfPairs => { Belt.Array.map(arrayOfPairs, pairValue => switch pairValue { - | EvArray([EvString(key), valueValue]) => (key, valueValue) - | _ => ("wrong key type", pairValue->toStringWithType->EvString) + | IevArray([IevString(key), valueValue]) => (key, valueValue) + | _ => ("wrong key type", pairValue->toStringWithType->IevString) } ) - ->Js.Dict.fromArray - ->EvRecord + ->Belt.Map.String.fromArray + ->IevRecord ->Ok } @@ -46,8 +47,14 @@ let callInternal = (call: functionCall, environment, reducer: ExpressionT.reduce | None => REArrayIndexNotFound("Array index not found", Belt.Int.fromFloat(fIndex))->Error } - let recordAtIndex = (dict: Js.Dict.t, sIndex) => - switch Js.Dict.get(dict, sIndex) { + let moduleAtIndex = (nameSpace: nameSpace, sIndex) => + switch Module.get(nameSpace, sIndex) { + | Some(value) => value->Ok + | None => RERecordPropertyNotFound("Module property not found", sIndex)->Error + } + + let recordAtIndex = (dict: Belt.Map.String.t, sIndex) => + switch Belt.Map.String.get(dict, sIndex) { | Some(value) => value->Ok | None => RERecordPropertyNotFound("Record property not found", sIndex)->Error } @@ -55,11 +62,11 @@ let callInternal = (call: functionCall, environment, reducer: ExpressionT.reduce let doAddArray = (originalA, b) => { let a = originalA->Js.Array2.copy let _ = Js.Array2.pushMany(a, b) - a->EvArray->Ok + a->IevArray->Ok } let doAddString = (a, b) => { let answer = Js.String2.concat(a, b) - answer->EvString->Ok + answer->IevString->Ok } let inspect = (value: expressionValue) => { @@ -72,53 +79,17 @@ let callInternal = (call: functionCall, environment, reducer: ExpressionT.reduce value->Ok } - let doSetBindings = ( - externalBindings: externalBindings, - symbol: string, - value: expressionValue, - ) => { - Bindings.fromExternalBindings(externalBindings) - ->Belt.Map.String.set(symbol, value) - ->Bindings.toExternalBindings - ->EvRecord - ->Ok + let doSetBindings = (bindings: nameSpace, symbol: string, value: expressionValue) => { + Module.set(bindings, symbol, value)->IevModule->Ok } - let doSetBindingsInNamespace = ( - externalBindings: externalBindings, - symbol: string, - value: expressionValue, - namespace: string, - ) => { - let bindings = Bindings.fromExternalBindings(externalBindings) - let evAliases = bindings->Belt.Map.String.getWithDefault(namespace, EvRecord(Js.Dict.empty())) - let newEvAliases = switch evAliases { - | EvRecord(dict) => { - Js.Dict.set(dict, symbol, value) - dict->EvRecord - } - | _ => Js.Dict.empty()->EvRecord - } - bindings - ->Belt.Map.String.set(namespace, newEvAliases) - ->Bindings.toExternalBindings - ->EvRecord - ->Ok - } + let doSetTypeAliasBindings = (bindings: nameSpace, symbol: string, value: expressionValue) => + Module.setTypeAlias(bindings, symbol, value)->IevModule->Ok - let doSetTypeAliasBindings = ( - externalBindings: externalBindings, - symbol: string, - value: expressionValue, - ) => doSetBindingsInNamespace(externalBindings, symbol, value, Bindings.typeAliasesKey) + let doSetTypeOfBindings = (bindings: nameSpace, symbol: string, value: expressionValue) => + Module.setTypeOf(bindings, symbol, value)->IevModule->Ok - let doSetTypeOfBindings = ( - externalBindings: externalBindings, - symbol: string, - value: expressionValue, - ) => doSetBindingsInNamespace(externalBindings, symbol, value, Bindings.typeReferencesKey) - - let doExportBindings = (externalBindings: externalBindings) => EvRecord(externalBindings)->Ok + let doExportBindings = (bindings: nameSpace) => bindings->Module.toExpressionValue->Ok let doKeepArray = (aValueArray, aLambdaValue) => { let rMappedList = aValueArray->Belt.Array.reduceReverse(Ok(list{}), (rAcc, elem) => @@ -126,13 +97,13 @@ let callInternal = (call: functionCall, environment, reducer: ExpressionT.reduce let rNewElem = Lambda.doLambdaCall(aLambdaValue, list{elem}, environment, reducer) rNewElem->Result.map(newElem => switch newElem { - | EvBool(true) => list{elem, ...acc} + | IevBool(true) => list{elem, ...acc} | _ => acc } ) }) ) - rMappedList->Result.map(mappedList => mappedList->Belt.List.toArray->EvArray) + rMappedList->Result.map(mappedList => mappedList->Belt.List.toArray->IevArray) } let doMapArray = (aValueArray, aLambdaValue) => { @@ -142,35 +113,36 @@ let callInternal = (call: functionCall, environment, reducer: ExpressionT.reduce rNewElem->Result.map(newElem => list{newElem, ...acc}) }) ) - rMappedList->Result.map(mappedList => mappedList->Belt.List.toArray->EvArray) + rMappedList->Result.map(mappedList => mappedList->Belt.List.toArray->IevArray) } module SampleMap = { type t = SampleSetDist.t let doLambdaCall = (aLambdaValue, list) => switch Lambda.doLambdaCall(aLambdaValue, list, environment, reducer) { - | Ok(EvNumber(f)) => Ok(f) + | Ok(IevNumber(f)) => Ok(f) | _ => Error(Operation.SampleMapNeedsNtoNFunction) } let toType = r => switch r { - | Ok(r) => Ok(EvDistribution(SampleSet(r))) + | Ok(r) => Ok(IevDistribution(SampleSet(r))) | Error(r) => Error(REDistributionError(SampleSetError(r))) } let map1 = (sampleSetDist: t, aLambdaValue) => { - let fn = r => doLambdaCall(aLambdaValue, list{EvNumber(r)}) + let fn = r => doLambdaCall(aLambdaValue, list{IevNumber(r)}) toType(SampleSetDist.samplesMap(~fn, sampleSetDist)) } let map2 = (t1: t, t2: t, aLambdaValue) => { - let fn = (a, b) => doLambdaCall(aLambdaValue, list{EvNumber(a), EvNumber(b)}) + let fn = (a, b) => doLambdaCall(aLambdaValue, list{IevNumber(a), IevNumber(b)}) SampleSetDist.map2(~fn, ~t1, ~t2)->toType } let map3 = (t1: t, t2: t, t3: t, aLambdaValue) => { - let fn = (a, b, c) => doLambdaCall(aLambdaValue, list{EvNumber(a), EvNumber(b), EvNumber(c)}) + let fn = (a, b, c) => + doLambdaCall(aLambdaValue, list{IevNumber(a), IevNumber(b), IevNumber(c)}) SampleSetDist.map3(~fn, ~t1, ~t2, ~t3)->toType } } @@ -192,132 +164,128 @@ let callInternal = (call: functionCall, environment, reducer: ExpressionT.reduce } let typeModifier_memberOf = (aType, anArray) => { - let newRecord = Js.Dict.fromArray([ - ("typeTag", EvString("typeIdentifier")), + let newRecord = Belt.Map.String.fromArray([ + ("typeTag", IevString("typeIdentifier")), ("typeIdentifier", aType), ]) - newRecord->Js.Dict.set("memberOf", anArray) - newRecord->EvRecord->Ok + newRecord->Belt.Map.String.set("memberOf", anArray)->IevRecord->Ok } let typeModifier_memberOf_update = (aRecord, anArray) => { - let newRecord = aRecord->Js.Dict.entries->Js.Dict.fromArray - newRecord->Js.Dict.set("memberOf", anArray) - newRecord->EvRecord->Ok + aRecord->Belt.Map.String.set("memberOf", anArray)->IevRecord->Ok } let typeModifier_min = (aType, value) => { - let newRecord = Js.Dict.fromArray([ - ("typeTag", EvString("typeIdentifier")), + let newRecord = Belt.Map.String.fromArray([ + ("typeTag", IevString("typeIdentifier")), ("typeIdentifier", aType), ]) - newRecord->Js.Dict.set("min", value) - newRecord->EvRecord->Ok + newRecord->Belt.Map.String.set("min", value)->IevRecord->Ok } let typeModifier_min_update = (aRecord, value) => { - let newRecord = aRecord->Js.Dict.entries->Js.Dict.fromArray - newRecord->Js.Dict.set("min", value) - newRecord->EvRecord->Ok + aRecord->Belt.Map.String.set("min", value)->IevRecord->Ok } let typeModifier_max = (aType, value) => { - let newRecord = Js.Dict.fromArray([ - ("typeTag", EvString("typeIdentifier")), + let newRecord = Belt.Map.String.fromArray([ + ("typeTag", IevString("typeIdentifier")), ("typeIdentifier", aType), ]) - newRecord->Js.Dict.set("max", value) - newRecord->EvRecord->Ok - } - let typeModifier_max_update = (aRecord, value) => { - let newRecord = aRecord->Js.Dict.entries->Js.Dict.fromArray - newRecord->Js.Dict.set("max", value) - newRecord->EvRecord->Ok + newRecord->Belt.Map.String.set("max", value)->IevRecord->Ok } + let typeModifier_max_update = (aRecord, value) => + aRecord->Belt.Map.String.set("max", value)->IevRecord->Ok - let typeModifier_opaque_update = aRecord => { - let newRecord = aRecord->Js.Dict.entries->Js.Dict.fromArray - newRecord->Js.Dict.set("opaque", EvBool(true)) - newRecord->EvRecord->Ok - } + let typeModifier_opaque_update = aRecord => + aRecord->Belt.Map.String.set("opaque", IevBool(true))->IevRecord->Ok let typeOr = evArray => { - let newRecord = Js.Dict.fromArray([("typeTag", EvString("typeOr")), ("typeOr", evArray)]) - newRecord->EvRecord->Ok + let newRecord = Belt.Map.String.fromArray([ + ("typeTag", IevString("typeOr")), + ("typeOr", evArray), + ]) + newRecord->IevRecord->Ok } let typeFunction = anArray => { let output = Belt.Array.getUnsafe(anArray, Js.Array2.length(anArray) - 1) let inputs = Js.Array2.slice(anArray, ~start=0, ~end_=-1) - let newRecord = Js.Dict.fromArray([ - ("typeTag", EvString("typeFunction")), - ("inputs", EvArray(inputs)), + let newRecord = Belt.Map.String.fromArray([ + ("typeTag", IevString("typeFunction")), + ("inputs", IevArray(inputs)), ("output", output), ]) - newRecord->EvRecord->Ok + newRecord->IevRecord->Ok } switch call { - | ("$_atIndex_$", [EvArray(aValueArray), EvNumber(fIndex)]) => arrayAtIndex(aValueArray, fIndex) - | ("$_atIndex_$", [EvModule(dict), EvString(sIndex)]) => recordAtIndex(dict, sIndex) - | ("$_atIndex_$", [EvRecord(dict), EvString(sIndex)]) => recordAtIndex(dict, sIndex) - | ("$_constructArray_$", [EvArray(aValueArray)]) => EvArray(aValueArray)->Ok - | ("$_constructRecord_$", [EvArray(arrayOfPairs)]) => constructRecord(arrayOfPairs) - | ("$_exportBindings_$", [EvRecord(externalBindings)]) => doExportBindings(externalBindings) - | ("$_setBindings_$", [EvRecord(externalBindings), EvSymbol(symbol), value]) => - doSetBindings(externalBindings, symbol, value) - | ("$_setTypeAliasBindings_$", [EvRecord(externalBindings), EvTypeIdentifier(symbol), value]) => - doSetTypeAliasBindings(externalBindings, symbol, value) - | ("$_setTypeOfBindings_$", [EvRecord(externalBindings), EvSymbol(symbol), value]) => - doSetTypeOfBindings(externalBindings, symbol, value) - | ("$_typeModifier_memberOf_$", [EvTypeIdentifier(typeIdentifier), EvArray(arr)]) => - typeModifier_memberOf(EvTypeIdentifier(typeIdentifier), EvArray(arr)) - | ("$_typeModifier_memberOf_$", [EvRecord(typeRecord), EvArray(arr)]) => - typeModifier_memberOf_update(typeRecord, EvArray(arr)) - | ("$_typeModifier_min_$", [EvTypeIdentifier(typeIdentifier), value]) => - typeModifier_min(EvTypeIdentifier(typeIdentifier), value) - | ("$_typeModifier_min_$", [EvRecord(typeRecord), value]) => + | ("$_atIndex_$", [IevArray(aValueArray), IevNumber(fIndex)]) => arrayAtIndex(aValueArray, fIndex) + | ("$_atIndex_$", [IevModule(dict), IevString(sIndex)]) => moduleAtIndex(dict, sIndex) + | ("$_atIndex_$", [IevRecord(dict), IevString(sIndex)]) => recordAtIndex(dict, sIndex) + | ("$_constructArray_$", [IevArray(aValueArray)]) => IevArray(aValueArray)->Ok + | ("$_constructRecord_$", [IevArray(arrayOfPairs)]) => constructRecord(arrayOfPairs) + | ("$_exportBindings_$", [IevModule(nameSpace)]) => doExportBindings(nameSpace) + | ("$_setBindings_$", [IevModule(nameSpace), IevSymbol(symbol), value]) => + doSetBindings(nameSpace, symbol, value) + | ("$_setTypeAliasBindings_$", [IevModule(nameSpace), IevTypeIdentifier(symbol), value]) => + doSetTypeAliasBindings(nameSpace, symbol, value) + | ("$_setTypeOfBindings_$", [IevModule(nameSpace), IevSymbol(symbol), value]) => + doSetTypeOfBindings(nameSpace, symbol, value) + | ("$_typeModifier_memberOf_$", [IevTypeIdentifier(typeIdentifier), IevArray(arr)]) => + typeModifier_memberOf(IevTypeIdentifier(typeIdentifier), IevArray(arr)) + | ("$_typeModifier_memberOf_$", [IevRecord(typeRecord), IevArray(arr)]) => + typeModifier_memberOf_update(typeRecord, IevArray(arr)) + | ("$_typeModifier_min_$", [IevTypeIdentifier(typeIdentifier), value]) => + typeModifier_min(IevTypeIdentifier(typeIdentifier), value) + | ("$_typeModifier_min_$", [IevRecord(typeRecord), value]) => typeModifier_min_update(typeRecord, value) - | ("$_typeModifier_max_$", [EvTypeIdentifier(typeIdentifier), value]) => - typeModifier_max(EvTypeIdentifier(typeIdentifier), value) - | ("$_typeModifier_max_$", [EvRecord(typeRecord), value]) => + | ("$_typeModifier_max_$", [IevTypeIdentifier(typeIdentifier), value]) => + typeModifier_max(IevTypeIdentifier(typeIdentifier), value) + | ("$_typeModifier_max_$", [IevRecord(typeRecord), value]) => typeModifier_max_update(typeRecord, value) - | ("$_typeModifier_opaque_$", [EvRecord(typeRecord)]) => typeModifier_opaque_update(typeRecord) - | ("$_typeOr_$", [EvArray(arr)]) => typeOr(EvArray(arr)) - | ("$_typeFunction_$", [EvArray(arr)]) => typeFunction(arr) - | ("concat", [EvArray(aValueArray), EvArray(bValueArray)]) => doAddArray(aValueArray, bValueArray) - | ("concat", [EvString(aValueString), EvString(bValueString)]) => + | ("$_typeModifier_opaque_$", [IevRecord(typeRecord)]) => typeModifier_opaque_update(typeRecord) + | ("$_typeOr_$", [IevArray(arr)]) => typeOr(IevArray(arr)) + | ("$_typeFunction_$", [IevArray(arr)]) => typeFunction(arr) + | ("concat", [IevArray(aValueArray), IevArray(bValueArray)]) => + doAddArray(aValueArray, bValueArray) + | ("concat", [IevString(aValueString), IevString(bValueString)]) => doAddString(aValueString, bValueString) - | ("inspect", [value, EvString(label)]) => inspectLabel(value, label) + | ("inspect", [value, IevString(label)]) => inspectLabel(value, label) | ("inspect", [value]) => inspect(value) - | ("filter", [EvArray(aValueArray), EvLambda(aLambdaValue)]) => + | ("filter", [IevArray(aValueArray), IevLambda(aLambdaValue)]) => doKeepArray(aValueArray, aLambdaValue) - | ("map", [EvArray(aValueArray), EvLambda(aLambdaValue)]) => doMapArray(aValueArray, aLambdaValue) - | ("mapSamples", [EvDistribution(SampleSet(dist)), EvLambda(aLambdaValue)]) => + | ("map", [IevArray(aValueArray), IevLambda(aLambdaValue)]) => + doMapArray(aValueArray, aLambdaValue) + | ("mapSamples", [IevDistribution(SampleSet(dist)), IevLambda(aLambdaValue)]) => SampleMap.map1(dist, aLambdaValue) | ( "mapSamples2", - [EvDistribution(SampleSet(dist1)), EvDistribution(SampleSet(dist2)), EvLambda(aLambdaValue)], + [ + IevDistribution(SampleSet(dist1)), + IevDistribution(SampleSet(dist2)), + IevLambda(aLambdaValue), + ], ) => SampleMap.map2(dist1, dist2, aLambdaValue) | ( "mapSamples3", [ - EvDistribution(SampleSet(dist1)), - EvDistribution(SampleSet(dist2)), - EvDistribution(SampleSet(dist3)), - EvLambda(aLambdaValue), + IevDistribution(SampleSet(dist1)), + IevDistribution(SampleSet(dist2)), + IevDistribution(SampleSet(dist3)), + IevLambda(aLambdaValue), ], ) => SampleMap.map3(dist1, dist2, dist3, aLambdaValue) - | ("reduce", [EvArray(aValueArray), initialValue, EvLambda(aLambdaValue)]) => + | ("reduce", [IevArray(aValueArray), initialValue, IevLambda(aLambdaValue)]) => doReduceArray(aValueArray, initialValue, aLambdaValue) - | ("reduceReverse", [EvArray(aValueArray), initialValue, EvLambda(aLambdaValue)]) => + | ("reduceReverse", [IevArray(aValueArray), initialValue, IevLambda(aLambdaValue)]) => doReduceReverseArray(aValueArray, initialValue, aLambdaValue) - | ("reverse", [EvArray(aValueArray)]) => aValueArray->Belt.Array.reverse->EvArray->Ok - | (_, [EvBool(_)]) - | (_, [EvNumber(_)]) - | (_, [EvString(_)]) - | (_, [EvBool(_), EvBool(_)]) - | (_, [EvNumber(_), EvNumber(_)]) - | (_, [EvString(_), EvString(_)]) => + | ("reverse", [IevArray(aValueArray)]) => aValueArray->Belt.Array.reverse->IevArray->Ok + | (_, [IevBool(_)]) + | (_, [IevNumber(_)]) + | (_, [IevString(_)]) + | (_, [IevBool(_), IevBool(_)]) + | (_, [IevNumber(_), IevNumber(_)]) + | (_, [IevString(_), IevString(_)]) => callMathJs(call) | call => Error(REFunctionNotFound(call->functionCallToCallSignature->functionCallSignatureToString)) // Report full type signature as error diff --git a/packages/squiggle-lang/src/rescript/Reducer/Reducer_Dispatch/Reducer_Dispatch_BuiltInMacros.res b/packages/squiggle-lang/src/rescript/Reducer/Reducer_Dispatch/Reducer_Dispatch_BuiltInMacros.res index cb2ce425..1a91b28c 100644 --- a/packages/squiggle-lang/src/rescript/Reducer/Reducer_Dispatch/Reducer_Dispatch_BuiltInMacros.res +++ b/packages/squiggle-lang/src/rescript/Reducer/Reducer_Dispatch/Reducer_Dispatch_BuiltInMacros.res @@ -3,12 +3,13 @@ they take expressions as parameters and return a new expression. Macros are used to define language building blocks. They are like Lisp macros. */ -module Bindings = Reducer_Expression_Bindings +module BindingsReplacer = Reducer_Expression_BindingsReplacer module ErrorValue = Reducer_ErrorValue module ExpressionBuilder = Reducer_Expression_ExpressionBuilder module ExpressionT = Reducer_Expression_T -module ExpressionValue = ReducerInterface.ExpressionValue +module ExpressionValue = ReducerInterface_InternalExpressionValue module ExpressionWithContext = Reducer_ExpressionWithContext +module Module = Reducer_Category_Module module Result = Belt.Result open Reducer_Expression_ExpressionBuilder @@ -27,13 +28,13 @@ let dispatchMacroCall = ( let useExpressionToSetBindings = (bindingExpr: expression, environment, statement, newCode) => { let rExternalBindingsValue = reduceExpression(bindingExpr, bindings, environment) - rExternalBindingsValue->Result.flatMap(externalBindingsValue => { - let newBindings = Bindings.fromValue(externalBindingsValue) + rExternalBindingsValue->Result.flatMap(nameSpaceValue => { + let newBindings = Module.fromExpressionValue(nameSpaceValue) - let rNewStatement = Bindings.replaceSymbols(newBindings, statement) + let rNewStatement = BindingsReplacer.replaceSymbols(newBindings, statement) rNewStatement->Result.map(boundStatement => ExpressionWithContext.withContext( - newCode(newBindings->Bindings.toExternalBindings->eRecord, boundStatement), + newCode(newBindings->eModule, boundStatement), newBindings, ) ) @@ -51,7 +52,7 @@ let dispatchMacroCall = ( let doBindStatement = (bindingExpr: expression, statement: expression, environment) => { let defaultStatement = ErrorValue.REAssignmentExpected->Error switch statement { - | ExpressionT.EList(list{ExpressionT.EValue(EvCall(callName)), symbolExpr, statement}) => { + | ExpressionT.EList(list{ExpressionT.EValue(IevCall(callName)), symbolExpr, statement}) => { let setBindingsFn = correspondingSetBindingsFn(callName) if setBindingsFn !== "" { useExpressionToSetBindings(bindingExpr, environment, statement, ( @@ -77,7 +78,7 @@ let dispatchMacroCall = ( ) => boundStatement) switch statement { - | ExpressionT.EList(list{ExpressionT.EValue(EvCall(callName)), symbolExpr, statement}) => { + | ExpressionT.EList(list{ExpressionT.EValue(IevCall(callName)), symbolExpr, statement}) => { let setBindingsFn = correspondingSetBindingsFn(callName) if setBindingsFn !== "" { useExpressionToSetBindings(bindingExpr, environment, statement, ( @@ -123,10 +124,7 @@ let dispatchMacroCall = ( bindings: ExpressionT.bindings, parameters: array, lambdaDefinition: ExpressionT.expression, - ) => - ExpressionWithContext.noContext( - eLambda(parameters, bindings->Bindings.toExternalBindings, lambdaDefinition), - )->Ok + ) => ExpressionWithContext.noContext(eLambda(parameters, bindings, lambdaDefinition))->Ok let doTernary = ( condition: expression, @@ -139,11 +137,11 @@ let dispatchMacroCall = ( let rCondition = reduceExpression(blockCondition, bindings, environment) rCondition->Result.flatMap(conditionValue => switch conditionValue { - | ExpressionValue.EvBool(false) => { + | ExpressionValue.IevBool(false) => { let ifFalseBlock = eBlock(list{ifFalse}) ExpressionWithContext.withContext(ifFalseBlock, bindings)->Ok } - | ExpressionValue.EvBool(true) => { + | ExpressionValue.IevBool(true) => { let ifTrueBlock = eBlock(list{ifTrue}) ExpressionWithContext.withContext(ifTrueBlock, bindings)->Ok } @@ -158,32 +156,32 @@ let dispatchMacroCall = ( > => switch aList { | list{ - ExpressionT.EValue(EvCall("$$_bindStatement_$$")), + ExpressionT.EValue(IevCall("$$_bindStatement_$$")), bindingExpr: ExpressionT.expression, statement, } => doBindStatement(bindingExpr, statement, environment) - | list{ExpressionT.EValue(EvCall("$$_bindStatement_$$")), statement} => + | list{ExpressionT.EValue(IevCall("$$_bindStatement_$$")), statement} => // bindings of the context are used when there is no binding expression - doBindStatement(eRecord(Bindings.toExternalBindings(bindings)), statement, environment) + doBindStatement(eModule(bindings), statement, environment) | list{ - ExpressionT.EValue(EvCall("$$_bindExpression_$$")), + ExpressionT.EValue(IevCall("$$_bindExpression_$$")), bindingExpr: ExpressionT.expression, expression, } => doBindExpression(bindingExpr, expression, environment) - | list{ExpressionT.EValue(EvCall("$$_bindExpression_$$")), expression} => + | list{ExpressionT.EValue(IevCall("$$_bindExpression_$$")), expression} => // bindings of the context are used when there is no binding expression - doBindExpression(eRecord(Bindings.toExternalBindings(bindings)), expression, environment) - | list{ExpressionT.EValue(EvCall("$$_block_$$")), ...exprs} => + doBindExpression(eModule(bindings), expression, environment) + | list{ExpressionT.EValue(IevCall("$$_block_$$")), ...exprs} => doBlock(exprs, bindings, environment) | list{ - ExpressionT.EValue(EvCall("$$_lambda_$$")), - ExpressionT.EValue(EvArrayString(parameters)), + ExpressionT.EValue(IevCall("$$_lambda_$$")), + ExpressionT.EValue(IevArrayString(parameters)), lambdaDefinition, } => doLambdaDefinition(bindings, parameters, lambdaDefinition) - | list{ExpressionT.EValue(EvCall("$$_ternary_$$")), condition, ifTrue, ifFalse} => + | list{ExpressionT.EValue(IevCall("$$_ternary_$$")), condition, ifTrue, ifFalse} => doTernary(condition, ifTrue, ifFalse, bindings, environment) | _ => ExpressionWithContext.noContext(ExpressionT.EList(aList))->Ok } diff --git a/packages/squiggle-lang/src/rescript/Reducer/Reducer_Expression/Reducer_Expression.res b/packages/squiggle-lang/src/rescript/Reducer/Reducer_Expression/Reducer_Expression.res index 6b4168c3..2f634709 100644 --- a/packages/squiggle-lang/src/rescript/Reducer/Reducer_Expression/Reducer_Expression.res +++ b/packages/squiggle-lang/src/rescript/Reducer/Reducer_Expression/Reducer_Expression.res @@ -1,20 +1,21 @@ -module Bindings = Reducer_Expression_Bindings +module BindingsReplacer = Reducer_Expression_BindingsReplacer module BuiltIn = Reducer_Dispatch_BuiltIn module ExpressionBuilder = Reducer_Expression_ExpressionBuilder -module ExpressionValue = ReducerInterface.ExpressionValue module Extra = Reducer_Extra +module InternalExpressionValue = ReducerInterface_InternalExpressionValue module Lambda = Reducer_Expression_Lambda module Macro = Reducer_Expression_Macro module MathJs = Reducer_MathJs +module Module = Reducer_Category_Module module Result = Belt.Result module T = Reducer_Expression_T -type environment = ReducerInterface_ExpressionValue.environment +type environment = InternalExpressionValue.environment type errorValue = Reducer_ErrorValue.errorValue type expression = T.expression -type expressionValue = ReducerInterface_ExpressionValue.expressionValue -type externalBindings = ReducerInterface_ExpressionValue.externalBindings -type internalCode = ReducerInterface_ExpressionValue.internalCode +type expressionValue = InternalExpressionValue.expressionValue +type externalExpressionValue = ReducerInterface_ExpressionValue.expressionValue +type tmpExternalBindings = InternalExpressionValue.tmpExternalBindings type t = expression /* @@ -35,7 +36,7 @@ let rec reduceExpression = (expression: t, bindings: T.bindings, environment: en | T.EValue(value) => value->Ok | T.EList(list) => switch list { - | list{EValue(EvCall(fName)), ..._args} => + | list{EValue(IevCall(fName)), ..._args} => switch Macro.isMacroName(fName) { // A macro expands then reduces itself | true => Macro.doMacroCall(expression, bindings, environment, reduceExpression) @@ -74,7 +75,7 @@ and reduceValueList = (valueList: list, environment): result< 'e, > => switch valueList { - | list{EvCall(fName), ...args} => { + | list{IevCall(fName), ...args} => { let rCheckedArgs = switch fName { | "$_setBindings_$" | "$_setTypeOfBindings_$" | "$_setTypeAliasBindings_$" => args->Ok | _ => args->Lambda.checkIfReduced @@ -84,14 +85,14 @@ and reduceValueList = (valueList: list, environment): result< (fName, checkedArgs->Belt.List.toArray)->BuiltIn.dispatch(environment, reduceExpression) ) } - | list{EvLambda(_)} => + | list{IevLambda(_)} => // TODO: remove on solving issue#558 valueList ->Lambda.checkIfReduced ->Result.flatMap(reducedValueList => - reducedValueList->Belt.List.toArray->ExpressionValue.EvArray->Ok + reducedValueList->Belt.List.toArray->InternalExpressionValue.IevArray->Ok ) - | list{EvLambda(lamdaCall), ...args} => + | list{IevLambda(lamdaCall), ...args} => args ->Lambda.checkIfReduced ->Result.flatMap(checkedArgs => @@ -102,7 +103,7 @@ and reduceValueList = (valueList: list, environment): result< valueList ->Lambda.checkIfReduced ->Result.flatMap(reducedValueList => - reducedValueList->Belt.List.toArray->ExpressionValue.EvArray->Ok + reducedValueList->Belt.List.toArray->InternalExpressionValue.IevArray->Ok ) } @@ -115,40 +116,35 @@ let evaluateUsingOptions = ( ~environment: option, ~externalBindings: option, code: string, -): result => { +): result => { let anEnvironment = Belt.Option.getWithDefault( environment, ReducerInterface_ExpressionValue.defaultEnvironment, ) - let anExternalBindings = switch externalBindings { - | Some(bindings) => { - let cloneLib = ReducerInterface_StdLib.externalStdLib->Reducer_Category_Bindings.cloneRecord - Js.Dict.entries(bindings)->Js.Array2.reduce((acc, (key, value)) => { - acc->Js.Dict.set(key, value) - acc - }, cloneLib) - } - | None => ReducerInterface_StdLib.externalStdLib - } + let mergedBindings: InternalExpressionValue.nameSpace = Module.merge( + ReducerInterface_StdLib.internalStdLib, + Belt.Option.map(externalBindings, Module.fromTypeScriptBindings)->Belt.Option.getWithDefault( + Module.emptyModule, + ), + ) - let bindings = anExternalBindings->Bindings.fromExternalBindings - - parse(code)->Result.flatMap(expr => evalUsingBindingsExpression_(expr, bindings, anEnvironment)) + parse(code) + ->Result.flatMap(expr => evalUsingBindingsExpression_(expr, mergedBindings, anEnvironment)) + ->Result.map(ReducerInterface_InternalExpressionValue.toExternal) } /* - Evaluates Squiggle code and bindings via Reducer and answers the result + Ievaluates Squiggle code and bindings via Reducer and answers the result */ -let evaluate = (code: string): result => { +let evaluate = (code: string): result => { evaluateUsingOptions(~environment=None, ~externalBindings=None, code) } -let eval = evaluate let evaluatePartialUsingExternalBindings = ( code: string, externalBindings: ReducerInterface_ExpressionValue.externalBindings, environment: ReducerInterface_ExpressionValue.environment, -): result => { +): result => { let rAnswer = evaluateUsingOptions( ~environment=Some(environment), ~externalBindings=Some(externalBindings), diff --git a/packages/squiggle-lang/src/rescript/Reducer/Reducer_Expression/Reducer_ExpressionWithContext.res b/packages/squiggle-lang/src/rescript/Reducer/Reducer_Expression/Reducer_ExpressionWithContext.res index 372b07ad..defc6d02 100644 --- a/packages/squiggle-lang/src/rescript/Reducer/Reducer_Expression/Reducer_ExpressionWithContext.res +++ b/packages/squiggle-lang/src/rescript/Reducer/Reducer_Expression/Reducer_ExpressionWithContext.res @@ -1,8 +1,9 @@ -module Bindings = Reducer_Expression_Bindings +module BindingsReplacer = Reducer_Expression_BindingsReplacer module ErrorValue = Reducer_ErrorValue module ExpressionT = Reducer_Expression_T -module ExpressionValue = ReducerInterface.ExpressionValue +module ExpressionValue = ReducerInterface_InternalExpressionValue module Result = Belt.Result +module Module = Reducer_Category_Module type bindings = ExpressionT.bindings type context = bindings @@ -10,7 +11,6 @@ type environment = ExpressionValue.environment type errorValue = Reducer_ErrorValue.errorValue type expression = ExpressionT.expression type expressionValue = ExpressionValue.expressionValue -type externalBindings = ReducerInterface_ExpressionValue.externalBindings type reducerFn = ExpressionT.reducerFn type expressionWithContext = @@ -40,7 +40,9 @@ let toString = expressionWithContext => switch expressionWithContext { | ExpressionNoContext(expr) => ExpressionT.toString(expr) | ExpressionWithContext(expr, context) => - `${ExpressionT.toString(expr)} context: ${Bindings.toString(context)}` + `${ExpressionT.toString(expr)} context: ${context + ->Module.toExpressionValue + ->ExpressionValue.toString}` } let toStringResult = rExpressionWithContext => diff --git a/packages/squiggle-lang/src/rescript/Reducer/Reducer_Expression/Reducer_Expression_Bindings.res b/packages/squiggle-lang/src/rescript/Reducer/Reducer_Expression/Reducer_Expression_BindingsReplacer.res similarity index 58% rename from packages/squiggle-lang/src/rescript/Reducer/Reducer_Expression/Reducer_Expression_Bindings.res rename to packages/squiggle-lang/src/rescript/Reducer/Reducer_Expression/Reducer_Expression_BindingsReplacer.res index c637581f..1a1350c3 100644 --- a/packages/squiggle-lang/src/rescript/Reducer/Reducer_Expression/Reducer_Expression_Bindings.res +++ b/packages/squiggle-lang/src/rescript/Reducer/Reducer_Expression/Reducer_Expression_BindingsReplacer.res @@ -1,27 +1,15 @@ module ErrorValue = Reducer_ErrorValue module ExpressionT = Reducer_Expression_T -module ExpressionValue = ReducerInterface.ExpressionValue +module ExpressionValue = ReducerInterface_InternalExpressionValue module Result = Belt.Result -module Bindings = Reducer_Category_Bindings +module Module = Reducer_Category_Module type errorValue = Reducer_ErrorValue.errorValue type expression = ExpressionT.expression type expressionValue = ExpressionValue.expressionValue +type tmpExternalBindings = ReducerInterface_InternalExpressionValue.tmpExternalBindings type externalBindings = ReducerInterface_ExpressionValue.externalBindings -let emptyBindings = Reducer_Category_Bindings.emptyBindings - -let typeAliasesKey = Bindings.typeAliasesKey -let typeReferencesKey = Bindings.typeReferencesKey - -let toExternalBindings = (bindings: ExpressionT.bindings): externalBindings => - Bindings.toRecord(bindings) - -let fromExternalBindings = (externalBindings: externalBindings): ExpressionT.bindings => - Bindings.fromRecord(externalBindings) - -let fromValue = (aValue: expressionValue) => Bindings.fromExpressionValue(aValue) - let isMacroName = (fName: string): bool => fName->Js.String2.startsWith("$$") let rec replaceSymbols = (bindings: ExpressionT.bindings, expression: expression): result< @@ -33,7 +21,7 @@ let rec replaceSymbols = (bindings: ExpressionT.bindings, expression: expression replaceSymbolOnValue(bindings, value)->Result.map(evValue => evValue->ExpressionT.EValue) | ExpressionT.EList(list) => switch list { - | list{EValue(EvCall(fName)), ..._args} => + | list{EValue(IevCall(fName)), ..._args} => switch isMacroName(fName) { // A macro reduces itself so we dont dive in it | true => expression->Ok @@ -55,18 +43,12 @@ and replaceSymbolsOnExpressionList = (bindings, list) => { } and replaceSymbolOnValue = (bindings, evValue: expressionValue) => switch evValue { - | EvSymbol(symbol) => Belt.Map.String.getWithDefault(bindings, symbol, evValue)->Ok - | EvCall(symbol) => Belt.Map.String.getWithDefault(bindings, symbol, evValue)->checkIfCallable + | IevSymbol(symbol) => Module.getWithDefault(bindings, symbol, evValue)->Ok + | IevCall(symbol) => Module.getWithDefault(bindings, symbol, evValue)->checkIfCallable | _ => evValue->Ok } and checkIfCallable = (evValue: expressionValue) => switch evValue { - | EvCall(_) | EvLambda(_) => evValue->Ok + | IevCall(_) | IevLambda(_) => evValue->Ok | _ => ErrorValue.RENotAFunction(ExpressionValue.toString(evValue))->Error } - -let toString = (bindings: ExpressionT.bindings) => - bindings->toExternalBindings->ExpressionValue.EvRecord->ExpressionValue.toString - -let externalBindingsToString = (externalBindings: externalBindings) => - externalBindings->ExpressionValue.EvRecord->ExpressionValue.toString diff --git a/packages/squiggle-lang/src/rescript/Reducer/Reducer_Expression/Reducer_Expression_ExpressionBuilder.res b/packages/squiggle-lang/src/rescript/Reducer/Reducer_Expression/Reducer_Expression_ExpressionBuilder.res index 22afadba..0fda62db 100644 --- a/packages/squiggle-lang/src/rescript/Reducer/Reducer_Expression/Reducer_Expression_ExpressionBuilder.res +++ b/packages/squiggle-lang/src/rescript/Reducer/Reducer_Expression/Reducer_Expression_ExpressionBuilder.res @@ -1,24 +1,27 @@ -module BBindings = Reducer_Expression_Bindings +module BBindingsReplacer = Reducer_Expression_BindingsReplacer module BErrorValue = Reducer_ErrorValue module BExpressionT = Reducer_Expression_T -module BExpressionValue = ReducerInterface.ExpressionValue +module BExpressionValue = ReducerInterface_InternalExpressionValue +module BModule = Reducer_Category_Module type errorValue = BErrorValue.errorValue type expression = BExpressionT.expression -type internalCode = ReducerInterface_ExpressionValue.internalCode +type expressionOrFFI = BExpressionT.expressionOrFFI +type ffiFn = BExpressionT.ffiFn +type internalCode = ReducerInterface_InternalExpressionValue.internalCode -external castExpressionToInternalCode: expression => internalCode = "%identity" +external castExpressionToInternalCode: expressionOrFFI => internalCode = "%identity" -let eArray = anArray => anArray->BExpressionValue.EvArray->BExpressionT.EValue +let eArray = anArray => anArray->BExpressionValue.IevArray->BExpressionT.EValue -let eArrayString = anArray => anArray->BExpressionValue.EvArrayString->BExpressionT.EValue +let eArrayString = anArray => anArray->BExpressionValue.IevArrayString->BExpressionT.EValue let eBindings = (anArray: array<(string, BExpressionValue.expressionValue)>) => - anArray->Js.Dict.fromArray->BExpressionValue.EvRecord->BExpressionT.EValue + anArray->BModule.fromArray->BModule.toExpressionValue->BExpressionT.EValue -let eBool = aBool => aBool->BExpressionValue.EvBool->BExpressionT.EValue +let eBool = aBool => aBool->BExpressionValue.IevBool->BExpressionT.EValue -let eCall = (name: string): expression => name->BExpressionValue.EvCall->BExpressionT.EValue +let eCall = (name: string): expression => name->BExpressionValue.IevCall->BExpressionT.EValue let eFunction = (fName: string, lispArgs: list): expression => { let fn = fName->eCall @@ -27,29 +30,40 @@ let eFunction = (fName: string, lispArgs: list): expression => { let eLambda = ( parameters: array, - context: BExpressionValue.externalBindings, + context: BExpressionValue.nameSpace, expr: expression, ) => { - // Js.log(`eLambda context ${BBindings.externalBindingsToString(context)}`) - BExpressionValue.EvLambda({ + BExpressionValue.IevLambda({ parameters: parameters, context: context, - body: expr->castExpressionToInternalCode, + body: NotFFI(expr)->castExpressionToInternalCode, })->BExpressionT.EValue } -let eNumber = aNumber => aNumber->BExpressionValue.EvNumber->BExpressionT.EValue +let eLambdaFFI = (parameters: array, ffiFn: ffiFn) => { + let context = BModule.emptyModule + BExpressionValue.IevLambda({ + parameters: parameters, + context: context, + body: FFI(ffiFn)->castExpressionToInternalCode, + })->BExpressionT.EValue +} -let eRecord = aRecord => aRecord->BExpressionValue.EvRecord->BExpressionT.EValue +let eNumber = aNumber => aNumber->BExpressionValue.IevNumber->BExpressionT.EValue -let eString = aString => aString->BExpressionValue.EvString->BExpressionT.EValue +let eRecord = aMap => aMap->BExpressionValue.IevRecord->BExpressionT.EValue -let eSymbol = (name: string): expression => name->BExpressionValue.EvSymbol->BExpressionT.EValue +let eString = aString => aString->BExpressionValue.IevString->BExpressionT.EValue + +let eSymbol = (name: string): expression => name->BExpressionValue.IevSymbol->BExpressionT.EValue let eList = (list: list): expression => list->BExpressionT.EList let eBlock = (exprs: list): expression => eFunction("$$_block_$$", exprs) +let eModule = (nameSpace: BExpressionValue.nameSpace): expression => + nameSpace->BExpressionValue.IevModule->BExpressionT.EValue + let eLetStatement = (symbol: string, valueExpression: expression): expression => eFunction("$_let_$", list{eSymbol(symbol), valueExpression}) @@ -65,7 +79,8 @@ let eBindExpression = (bindingExpr: expression, expression: expression): express let eBindExpressionDefault = (expression: expression): expression => eFunction("$$_bindExpression_$$", list{expression}) -let eIdentifier = (name: string): expression => name->BExpressionValue.EvSymbol->BExpressionT.EValue +let eIdentifier = (name: string): expression => + name->BExpressionValue.IevSymbol->BExpressionT.EValue let eTypeIdentifier = (name: string): expression => - name->BExpressionValue.EvTypeIdentifier->BExpressionT.EValue + name->BExpressionValue.IevTypeIdentifier->BExpressionT.EValue diff --git a/packages/squiggle-lang/src/rescript/Reducer/Reducer_Expression/Reducer_Expression_Lambda.res b/packages/squiggle-lang/src/rescript/Reducer/Reducer_Expression/Reducer_Expression_Lambda.res index dc4920f3..7376c392 100644 --- a/packages/squiggle-lang/src/rescript/Reducer/Reducer_Expression/Reducer_Expression_Lambda.res +++ b/packages/squiggle-lang/src/rescript/Reducer/Reducer_Expression/Reducer_Expression_Lambda.res @@ -1,17 +1,19 @@ -module Bindings = Reducer_Expression_Bindings +module BindingsReplacer = Reducer_Expression_BindingsReplacer module ErrorValue = Reducer_ErrorValue module ExpressionBuilder = Reducer_Expression_ExpressionBuilder module ExpressionT = Reducer_Expression_T -module ExpressionValue = ReducerInterface.ExpressionValue +module ExpressionValue = ReducerInterface_InternalExpressionValue +module Module = Reducer_Category_Module module Result = Belt.Result -type environment = ReducerInterface_ExpressionValue.environment +type environment = ReducerInterface_InternalExpressionValue.environment type expression = ExpressionT.expression -type expressionValue = ReducerInterface_ExpressionValue.expressionValue -type externalBindings = ReducerInterface_ExpressionValue.externalBindings -type internalCode = ReducerInterface_ExpressionValue.internalCode +type expressionOrFFI = ExpressionT.expressionOrFFI +type expressionValue = ReducerInterface_InternalExpressionValue.expressionValue +// type tmpExternalBindings = ReducerInterface_InternalExpressionValue.tmpExternalBindings +type internalCode = ReducerInterface_InternalExpressionValue.internalCode -external castInternalCodeToExpression: internalCode => expression = "%identity" +external castInternalCodeToExpression: internalCode => expressionOrFFI = "%identity" let checkArity = (lambdaValue: ExpressionValue.lambdaValue, args: list) => { let argsLength = Belt.List.length(args) @@ -27,12 +29,27 @@ let checkIfReduced = (args: list) => args->Belt.List.reduceReverse(Ok(list{}), (rAcc, arg) => rAcc->Result.flatMap(acc => switch arg { - | EvSymbol(symbol) => ErrorValue.RESymbolNotFound(symbol)->Error + | IevSymbol(symbol) => ErrorValue.RESymbolNotFound(symbol)->Error | _ => list{arg, ...acc}->Ok } ) ) +let caseNotFFI = (lambdaValue: ExpressionValue.lambdaValue, expr, args, environment, reducer) => { + let parameterList = lambdaValue.parameters->Belt.List.fromArray + let zippedParameterList = parameterList->Belt.List.zip(args) + let bindings = Belt.List.reduce(zippedParameterList, lambdaValue.context, ( + acc, + (variable, variableValue), + ) => acc->Module.set(variable, variableValue)) + let newExpression = ExpressionBuilder.eBlock(list{expr}) + reducer(newExpression, bindings, environment) +} + +let caseFFI = (ffiFn: ExpressionT.ffiFn, args, environment) => { + ffiFn(args->Belt.List.toArray, environment) +} + let applyParametersToLambda = ( lambdaValue: ExpressionValue.lambdaValue, args, @@ -41,16 +58,11 @@ let applyParametersToLambda = ( ): result => { checkArity(lambdaValue, args)->Result.flatMap(args => checkIfReduced(args)->Result.flatMap(args => { - let expr = castInternalCodeToExpression(lambdaValue.body) - let parameterList = lambdaValue.parameters->Belt.List.fromArray - let zippedParameterList = parameterList->Belt.List.zip(args) - let bindings = Belt.List.reduce( - zippedParameterList, - lambdaValue.context->Bindings.fromExternalBindings, - (acc, (variable, variableValue)) => acc->Belt.Map.String.set(variable, variableValue), - ) - let newExpression = ExpressionBuilder.eBlock(list{expr}) - reducer(newExpression, bindings, environment) + let exprOrFFI = castInternalCodeToExpression(lambdaValue.body) + switch exprOrFFI { + | NotFFI(expr) => caseNotFFI(lambdaValue, expr, args, environment, reducer) + | FFI(ffiFn) => caseFFI(ffiFn, args, environment) + } }) ) } diff --git a/packages/squiggle-lang/src/rescript/Reducer/Reducer_Expression/Reducer_Expression_Macro.res b/packages/squiggle-lang/src/rescript/Reducer/Reducer_Expression/Reducer_Expression_Macro.res index 23fb70f8..4ac95bd5 100644 --- a/packages/squiggle-lang/src/rescript/Reducer/Reducer_Expression/Reducer_Expression_Macro.res +++ b/packages/squiggle-lang/src/rescript/Reducer/Reducer_Expression/Reducer_Expression_Macro.res @@ -1,5 +1,5 @@ module ExpressionT = Reducer_Expression_T -module ExpressionValue = ReducerInterface.ExpressionValue +module ExpressionValue = ReducerInterface_InternalExpressionValue module ExpressionWithContext = Reducer_ExpressionWithContext module Result = Belt.Result diff --git a/packages/squiggle-lang/src/rescript/Reducer/Reducer_Expression/Reducer_Expression_T.res b/packages/squiggle-lang/src/rescript/Reducer/Reducer_Expression/Reducer_Expression_T.res index 512e08ea..efc6e639 100644 --- a/packages/squiggle-lang/src/rescript/Reducer/Reducer_Expression/Reducer_Expression_T.res +++ b/packages/squiggle-lang/src/rescript/Reducer/Reducer_Expression/Reducer_Expression_T.res @@ -7,15 +7,15 @@ The act of defining the semantics of a functional language is to write it in terms of Lisp AST. */ module Extra = Reducer_Extra -module ExpressionValue = ReducerInterface.ExpressionValue +module InternalExpressionValue = ReducerInterface_InternalExpressionValue -type expressionValue = ExpressionValue.expressionValue -type environment = ExpressionValue.environment +type expressionValue = InternalExpressionValue.expressionValue +type environment = ReducerInterface_InternalExpressionValue.environment type rec expression = | EList(list) // A list to map-reduce | EValue(expressionValue) // Irreducible built-in value. Reducer should not know the internals. External libraries are responsible -and bindings = Belt.Map.String.t +and bindings = InternalExpressionValue.nameSpace type reducerFn = ( expression, @@ -28,7 +28,7 @@ type reducerFn = ( */ let rec toString = expression => switch expression { - | EList(list{EValue(EvCall("$$_block_$$")), ...statements}) => + | EList(list{EValue(IevCall("$$_block_$$")), ...statements}) => `{${Belt.List.map(statements, aValue => toString(aValue)) ->Extra.List.interperse("; ") ->Belt.List.toArray @@ -38,7 +38,7 @@ let rec toString = expression => ->Extra.List.interperse(" ") ->Belt.List.toArray ->Js.String.concatMany("")})` - | EValue(aValue) => ExpressionValue.toString(aValue) + | EValue(aValue) => InternalExpressionValue.toString(aValue) } let toStringResult = codeResult => @@ -65,3 +65,12 @@ let inspectResult = (r: result): resu Js.log(toStringResult(r)) r } + +type ffiFn = ( + array, + environment, +) => result + +type expressionOrFFI = + | NotFFI(expression) + | FFI(ffiFn) diff --git a/packages/squiggle-lang/src/rescript/Reducer/Reducer_Js/Reducer_Js_Gate.res b/packages/squiggle-lang/src/rescript/Reducer/Reducer_Js/Reducer_Js_Gate.res index 7cd220bc..b1e8c4b3 100644 --- a/packages/squiggle-lang/src/rescript/Reducer/Reducer_Js/Reducer_Js_Gate.res +++ b/packages/squiggle-lang/src/rescript/Reducer/Reducer_Js/Reducer_Js_Gate.res @@ -1,4 +1,4 @@ -open ReducerInterface.ExpressionValue +open ReducerInterface_InternalExpressionValue open Reducer_ErrorValue external castBool: unit => bool = "%identity" @@ -8,10 +8,10 @@ external castString: unit => string = "%identity" /* As JavaScript returns us any type, we need to type check and cast type propertype before using it */ -let jsToEv = (jsValue): result => +let jsToIev = (jsValue): result => switch Js.typeof(jsValue) { - | "boolean" => jsValue->castBool->EvBool->Ok - | "number" => jsValue->castNumber->EvNumber->Ok - | "string" => jsValue->castString->EvString->Ok + | "boolean" => jsValue->castBool->IevBool->Ok + | "number" => jsValue->castNumber->IevNumber->Ok + | "string" => jsValue->castString->IevString->Ok | other => RETodo(`Unhandled MathJs literal type: ${Js.String.make(other)}`)->Error } diff --git a/packages/squiggle-lang/src/rescript/Reducer/Reducer_MathJs/Reducer_MathJs_Eval.res b/packages/squiggle-lang/src/rescript/Reducer/Reducer_MathJs/Reducer_MathJs_Eval.res index ab9fb711..1fe54e86 100644 --- a/packages/squiggle-lang/src/rescript/Reducer/Reducer_MathJs/Reducer_MathJs_Eval.res +++ b/packages/squiggle-lang/src/rescript/Reducer/Reducer_MathJs/Reducer_MathJs_Eval.res @@ -1,5 +1,5 @@ module JavaScript = Reducer_Js -open ReducerInterface.ExpressionValue +open ReducerInterface_InternalExpressionValue open Reducer_ErrorValue @module("mathjs") external dummy_: string => unit = "evaluate" @@ -20,7 +20,7 @@ let eval__: string => 'a = %raw(`function (expr) { return {value: Mathjs.evaluat let eval = (expr: string): result => { try { let answer = eval__(expr) - answer["value"]->JavaScript.Gate.jsToEv + answer["value"]->JavaScript.Gate.jsToIev } catch { | Js.Exn.Error(obj) => REJavaScriptExn(Js.Exn.message(obj), Js.Exn.name(obj))->Error } diff --git a/packages/squiggle-lang/src/rescript/ReducerInterface/ReducerInterface.res b/packages/squiggle-lang/src/rescript/ReducerInterface/ReducerInterface.res index 9c87f57e..4ab6fd35 100644 --- a/packages/squiggle-lang/src/rescript/ReducerInterface/ReducerInterface.res +++ b/packages/squiggle-lang/src/rescript/ReducerInterface/ReducerInterface.res @@ -1,2 +1,4 @@ -module ExpressionValue = ReducerInterface_ExpressionValue +module ExternalExpressionValue = ReducerInterface_ExpressionValue module ExternalLibrary = ReducerInterface_ExternalLibrary +module InternalExpressionValue = ReducerInterface_InternalExpressionValue +module StdLib = ReducerInterface_StdLib diff --git a/packages/squiggle-lang/src/rescript/ReducerInterface/ReducerInterface_Date.res b/packages/squiggle-lang/src/rescript/ReducerInterface/ReducerInterface_Date.res index 02c3affc..fcb207d2 100644 --- a/packages/squiggle-lang/src/rescript/ReducerInterface/ReducerInterface_Date.res +++ b/packages/squiggle-lang/src/rescript/ReducerInterface/ReducerInterface_Date.res @@ -1,27 +1,27 @@ -module EV = ReducerInterface_ExpressionValue +module EV = ReducerInterface_InternalExpressionValue type expressionValue = EV.expressionValue let dispatch = (call: EV.functionCall, _: DistributionOperation.env): option< result, > => { switch call { - | ("toString", [EvDate(t)]) => EV.EvString(DateTime.Date.toString(t))->Ok->Some - | ("makeDateFromYear", [EvNumber(year)]) => + | ("toString", [IevDate(t)]) => EV.IevString(DateTime.Date.toString(t))->Ok->Some + | ("makeDateFromYear", [IevNumber(year)]) => switch DateTime.Date.makeFromYear(year) { - | Ok(t) => EV.EvDate(t)->Ok->Some + | Ok(t) => EV.IevDate(t)->Ok->Some | Error(e) => Reducer_ErrorValue.RETodo(e)->Error->Some } - | ("dateFromNumber", [EvNumber(f)]) => EV.EvDate(DateTime.Date.fromFloat(f))->Ok->Some - | ("toNumber", [EvDate(f)]) => EV.EvNumber(DateTime.Date.toFloat(f))->Ok->Some - | ("subtract", [EvDate(d1), EvDate(d2)]) => + | ("dateFromNumber", [IevNumber(f)]) => EV.IevDate(DateTime.Date.fromFloat(f))->Ok->Some + | ("toNumber", [IevDate(f)]) => EV.IevNumber(DateTime.Date.toFloat(f))->Ok->Some + | ("subtract", [IevDate(d1), IevDate(d2)]) => switch DateTime.Date.subtract(d1, d2) { - | Ok(d) => EV.EvTimeDuration(d)->Ok + | Ok(d) => EV.IevTimeDuration(d)->Ok | Error(e) => Error(RETodo(e)) }->Some - | ("subtract", [EvDate(d1), EvTimeDuration(d2)]) => - EV.EvDate(DateTime.Date.subtractDuration(d1, d2))->Ok->Some - | ("add", [EvDate(d1), EvTimeDuration(d2)]) => - EV.EvDate(DateTime.Date.addDuration(d1, d2))->Ok->Some + | ("subtract", [IevDate(d1), IevTimeDuration(d2)]) => + EV.IevDate(DateTime.Date.subtractDuration(d1, d2))->Ok->Some + | ("add", [IevDate(d1), IevTimeDuration(d2)]) => + EV.IevDate(DateTime.Date.addDuration(d1, d2))->Ok->Some | _ => None } } diff --git a/packages/squiggle-lang/src/rescript/ReducerInterface/ReducerInterface_Duration.res b/packages/squiggle-lang/src/rescript/ReducerInterface/ReducerInterface_Duration.res index b11eda89..bff0a693 100644 --- a/packages/squiggle-lang/src/rescript/ReducerInterface/ReducerInterface_Duration.res +++ b/packages/squiggle-lang/src/rescript/ReducerInterface/ReducerInterface_Duration.res @@ -1,33 +1,35 @@ -module EV = ReducerInterface_ExpressionValue +module EV = ReducerInterface_InternalExpressionValue type expressionValue = EV.expressionValue let dispatch = (call: EV.functionCall, _: DistributionOperation.env): option< result, > => { switch call { - | ("toString", [EvTimeDuration(t)]) => EV.EvString(DateTime.Duration.toString(t))->Ok->Some - | ("minutes", [EvNumber(f)]) => EV.EvTimeDuration(DateTime.Duration.fromMinutes(f))->Ok->Some - | ("fromUnit_minutes", [EvNumber(f)]) => - EV.EvTimeDuration(DateTime.Duration.fromMinutes(f))->Ok->Some - | ("hours", [EvNumber(f)]) => EV.EvTimeDuration(DateTime.Duration.fromHours(f))->Ok->Some - | ("fromUnit_hours", [EvNumber(f)]) => EV.EvTimeDuration(DateTime.Duration.fromHours(f))->Ok->Some - | ("days", [EvNumber(f)]) => EV.EvTimeDuration(DateTime.Duration.fromDays(f))->Ok->Some - | ("fromUnit_days", [EvNumber(f)]) => EV.EvTimeDuration(DateTime.Duration.fromDays(f))->Ok->Some - | ("years", [EvNumber(f)]) => EV.EvTimeDuration(DateTime.Duration.fromYears(f))->Ok->Some - | ("fromUnit_years", [EvNumber(f)]) => EV.EvTimeDuration(DateTime.Duration.fromYears(f))->Ok->Some - | ("toHours", [EvTimeDuration(f)]) => EV.EvNumber(DateTime.Duration.toHours(f))->Ok->Some - | ("toMinutes", [EvTimeDuration(f)]) => EV.EvNumber(DateTime.Duration.toMinutes(f))->Ok->Some - | ("toDays", [EvTimeDuration(f)]) => EV.EvNumber(DateTime.Duration.toDays(f))->Ok->Some - | ("toYears", [EvTimeDuration(f)]) => EV.EvNumber(DateTime.Duration.toYears(f))->Ok->Some - | ("add", [EvTimeDuration(d1), EvTimeDuration(d2)]) => - EV.EvTimeDuration(DateTime.Duration.add(d1, d2))->Ok->Some - | ("subtract", [EvTimeDuration(d1), EvTimeDuration(d2)]) => - EV.EvTimeDuration(DateTime.Duration.subtract(d1, d2))->Ok->Some - | ("multiply", [EvTimeDuration(d1), EvNumber(d2)]) => - EV.EvTimeDuration(DateTime.Duration.multiply(d1, d2))->Ok->Some - | ("divide", [EvTimeDuration(d1), EvNumber(d2)]) => - EV.EvTimeDuration(DateTime.Duration.divide(d1, d2))->Ok->Some - | ("divide", [EvTimeDuration(d1), EvTimeDuration(d2)]) => EV.EvNumber(d1 /. d2)->Ok->Some + | ("toString", [IevTimeDuration(t)]) => EV.IevString(DateTime.Duration.toString(t))->Ok->Some + | ("minutes", [IevNumber(f)]) => EV.IevTimeDuration(DateTime.Duration.fromMinutes(f))->Ok->Some + | ("fromUnit_minutes", [IevNumber(f)]) => + EV.IevTimeDuration(DateTime.Duration.fromMinutes(f))->Ok->Some + | ("hours", [IevNumber(f)]) => EV.IevTimeDuration(DateTime.Duration.fromHours(f))->Ok->Some + | ("fromUnit_hours", [IevNumber(f)]) => + EV.IevTimeDuration(DateTime.Duration.fromHours(f))->Ok->Some + | ("days", [IevNumber(f)]) => EV.IevTimeDuration(DateTime.Duration.fromDays(f))->Ok->Some + | ("fromUnit_days", [IevNumber(f)]) => EV.IevTimeDuration(DateTime.Duration.fromDays(f))->Ok->Some + | ("years", [IevNumber(f)]) => EV.IevTimeDuration(DateTime.Duration.fromYears(f))->Ok->Some + | ("fromUnit_years", [IevNumber(f)]) => + EV.IevTimeDuration(DateTime.Duration.fromYears(f))->Ok->Some + | ("toHours", [IevTimeDuration(f)]) => EV.IevNumber(DateTime.Duration.toHours(f))->Ok->Some + | ("toMinutes", [IevTimeDuration(f)]) => EV.IevNumber(DateTime.Duration.toMinutes(f))->Ok->Some + | ("toDays", [IevTimeDuration(f)]) => EV.IevNumber(DateTime.Duration.toDays(f))->Ok->Some + | ("toYears", [IevTimeDuration(f)]) => EV.IevNumber(DateTime.Duration.toYears(f))->Ok->Some + | ("add", [IevTimeDuration(d1), IevTimeDuration(d2)]) => + EV.IevTimeDuration(DateTime.Duration.add(d1, d2))->Ok->Some + | ("subtract", [IevTimeDuration(d1), IevTimeDuration(d2)]) => + EV.IevTimeDuration(DateTime.Duration.subtract(d1, d2))->Ok->Some + | ("multiply", [IevTimeDuration(d1), IevNumber(d2)]) => + EV.IevTimeDuration(DateTime.Duration.multiply(d1, d2))->Ok->Some + | ("divide", [IevTimeDuration(d1), IevNumber(d2)]) => + EV.IevTimeDuration(DateTime.Duration.divide(d1, d2))->Ok->Some + | ("divide", [IevTimeDuration(d1), IevTimeDuration(d2)]) => EV.IevNumber(d1 /. d2)->Ok->Some | _ => None } } diff --git a/packages/squiggle-lang/src/rescript/ReducerInterface/ReducerInterface_ExpressionValue.res b/packages/squiggle-lang/src/rescript/ReducerInterface/ReducerInterface_ExpressionValue.res index 1313207a..0f8b0249 100644 --- a/packages/squiggle-lang/src/rescript/ReducerInterface/ReducerInterface_ExpressionValue.res +++ b/packages/squiggle-lang/src/rescript/ReducerInterface/ReducerInterface_ExpressionValue.res @@ -68,25 +68,6 @@ and toStringRecord = aRecord => { `{${pairs}}` } -let toStringWithType = aValue => - switch aValue { - | EvArray(_) => `Array::${toString(aValue)}` - | EvArrayString(_) => `ArrayString::${toString(aValue)}` - | EvBool(_) => `Bool::${toString(aValue)}` - | EvCall(_) => `Call::${toString(aValue)}` - | EvDistribution(_) => `Distribution::${toString(aValue)}` - | EvLambda(_) => `Lambda::${toString(aValue)}` - | EvNumber(_) => `Number::${toString(aValue)}` - | EvRecord(_) => `Record::${toString(aValue)}` - | EvString(_) => `String::${toString(aValue)}` - | EvSymbol(_) => `Symbol::${toString(aValue)}` - | EvDate(_) => `Date::${toString(aValue)}` - | EvTimeDuration(_) => `Date::${toString(aValue)}` - | EvDeclaration(_) => `Declaration::${toString(aValue)}` - | EvTypeIdentifier(_) => `TypeIdentifier::${toString(aValue)}` - | EvModule(_) => `Module::${toString(aValue)}` - } - let argsToString = (args: array): string => { args->Js.Array2.map(arg => arg->toString)->Js.Array2.toString } @@ -99,17 +80,17 @@ let toStringResult = x => | Error(m) => `Error(${ErrorValue.errorToString(m)})` } -let toStringResultOkless = (codeResult: result): string => - switch codeResult { - | Ok(a) => toString(a) - | Error(m) => `Error(${ErrorValue.errorToString(m)})` - } +// let toStringResultOkless = (codeResult: result): string => +// switch codeResult { +// | Ok(a) => toString(a) +// | Error(m) => `Error(${ErrorValue.errorToString(m)})` +// } -let toStringResultRecord = x => - switch x { - | Ok(a) => `Ok(${toStringRecord(a)})` - | Error(m) => `Error(${ErrorValue.errorToString(m)})` - } +// let toStringResultRecord = x => +// switch x { +// | Ok(a) => `Ok(${toStringRecord(a)})` +// | Error(m) => `Error(${ErrorValue.errorToString(m)})` +// } @genType type environment = DistributionOperation.env @@ -141,14 +122,14 @@ type functionDefinitionSignature = let valueToValueType = value => switch value { | EvArray(_) => EvtArray - | EvArrayString(_) => EvtArray + | EvArrayString(_) => EvtArrayString | EvBool(_) => EvtBool | EvCall(_) => EvtCall | EvDistribution(_) => EvtDistribution | EvLambda(_) => EvtLambda | EvNumber(_) => EvtNumber | EvRecord(_) => EvtRecord - | EvString(_) => EvtArray + | EvString(_) => EvtString | EvSymbol(_) => EvtSymbol | EvDate(_) => EvtDate | EvTimeDuration(_) => EvtTimeDuration diff --git a/packages/squiggle-lang/src/rescript/ReducerInterface/ReducerInterface_ExternalLibrary.res b/packages/squiggle-lang/src/rescript/ReducerInterface/ReducerInterface_ExternalLibrary.res index d045040a..a003f7b5 100644 --- a/packages/squiggle-lang/src/rescript/ReducerInterface/ReducerInterface_ExternalLibrary.res +++ b/packages/squiggle-lang/src/rescript/ReducerInterface/ReducerInterface_ExternalLibrary.res @@ -1,4 +1,4 @@ -module ExpressionValue = ReducerInterface_ExpressionValue +module ExpressionValue = ReducerInterface_InternalExpressionValue type expressionValue = ExpressionValue.expressionValue diff --git a/packages/squiggle-lang/src/rescript/ReducerInterface/ReducerInterface_GenericDistribution.res b/packages/squiggle-lang/src/rescript/ReducerInterface/ReducerInterface_GenericDistribution.res index 6ef3f7a6..2582cbe0 100644 --- a/packages/squiggle-lang/src/rescript/ReducerInterface/ReducerInterface_GenericDistribution.res +++ b/packages/squiggle-lang/src/rescript/ReducerInterface/ReducerInterface_GenericDistribution.res @@ -1,4 +1,4 @@ -module ExpressionValue = ReducerInterface_ExpressionValue +module ExpressionValue = ReducerInterface_InternalExpressionValue type expressionValue = ExpressionValue.expressionValue module Helpers = { @@ -23,9 +23,9 @@ module Helpers = { DistributionTypes.genericDist, )> => switch args { - | [EvDistribution(a), EvDistribution(b)] => Some((a, b)) - | [EvNumber(a), EvDistribution(b)] => Some((GenericDist.fromFloat(a), b)) - | [EvDistribution(a), EvNumber(b)] => Some((a, GenericDist.fromFloat(b))) + | [IevDistribution(a), IevDistribution(b)] => Some((a, b)) + | [IevNumber(a), IevDistribution(b)] => Some((GenericDist.fromFloat(a), b)) + | [IevDistribution(a), IevNumber(b)] => Some((a, GenericDist.fromFloat(b))) | _ => None } @@ -82,7 +82,7 @@ module Helpers = { let parseNumber = (args: expressionValue): Belt.Result.t => switch args { - | EvNumber(x) => Ok(x) + | IevNumber(x) => Ok(x) | _ => Error("Not a number") } @@ -91,8 +91,8 @@ module Helpers = { let parseDist = (args: expressionValue): Belt.Result.t => switch args { - | EvDistribution(x) => Ok(x) - | EvNumber(x) => Ok(GenericDist.fromFloat(x)) + | IevDistribution(x) => Ok(x) + | IevNumber(x) => Ok(GenericDist.fromFloat(x)) | _ => Error("Not a distribution") } @@ -128,12 +128,12 @@ module Helpers = { let error = (err: string): DistributionOperation.outputType => err->DistributionTypes.ArgumentError->GenDistError switch args { - | [EvArray(distributions)] => + | [IevArray(distributions)] => switch parseDistributionArray(distributions) { | Ok(distrs) => mixtureWithDefaultWeights(distrs, ~env) | Error(err) => error(err) } - | [EvArray(distributions), EvArray(weights)] => + | [IevArray(distributions), IevArray(weights)] => switch (parseDistributionArray(distributions), parseNumberArray(weights)) { | (Ok(distrs), Ok(wghts)) => mixtureWithGivenWeights(distrs, wghts, ~env) | (Error(err), Ok(_)) => error(err) @@ -142,7 +142,7 @@ module Helpers = { } | _ => switch E.A.last(args) { - | Some(EvArray(b)) => { + | Some(IevArray(b)) => { let weights = parseNumberArray(b) let distributions = parseDistributionArray( Belt.Array.slice(args, ~offset=0, ~len=E.A.length(args) - 1), @@ -152,8 +152,8 @@ module Helpers = { | Error(err) => error(err) } } - | Some(EvNumber(_)) - | Some(EvDistribution(_)) => + | Some(IevNumber(_)) + | Some(IevDistribution(_)) => switch parseDistributionArray(args) { | Ok(distributions) => mixtureWithDefaultWeights(distributions, ~env) | Error(err) => error(err) @@ -200,14 +200,14 @@ let dispatchToGenericOutput = ( ): option => { let (fnName, args) = call switch (fnName, args) { - | ("triangular" as fnName, [EvNumber(f1), EvNumber(f2), EvNumber(f3)]) => + | ("triangular" as fnName, [IevNumber(f1), IevNumber(f2), IevNumber(f3)]) => SymbolicConstructors.threeFloat(fnName) ->E.R.bind(r => r(f1, f2, f3)) ->SymbolicConstructors.symbolicResultToOutput - | ("sample", [EvDistribution(dist)]) => Helpers.toFloatFn(#Sample, dist, ~env) - | ("sampleN", [EvDistribution(dist), EvNumber(n)]) => + | ("sample", [IevDistribution(dist)]) => Helpers.toFloatFn(#Sample, dist, ~env) + | ("sampleN", [IevDistribution(dist), IevNumber(n)]) => Some(FloatArray(GenericDist.sampleN(dist, Belt.Int.fromFloat(n)))) - | (("mean" | "stdev" | "variance" | "min" | "max" | "mode") as op, [EvDistribution(dist)]) => { + | (("mean" | "stdev" | "variance" | "min" | "max" | "mode") as op, [IevDistribution(dist)]) => { let fn = switch op { | "mean" => #Mean | "stdev" => #Stdev @@ -219,13 +219,13 @@ let dispatchToGenericOutput = ( } Helpers.toFloatFn(fn, dist, ~env) } - | ("integralSum", [EvDistribution(dist)]) => Helpers.toFloatFn(#IntegralSum, dist, ~env) - | ("toString", [EvDistribution(dist)]) => Helpers.toStringFn(ToString, dist, ~env) - | ("toSparkline", [EvDistribution(dist)]) => + | ("integralSum", [IevDistribution(dist)]) => Helpers.toFloatFn(#IntegralSum, dist, ~env) + | ("toString", [IevDistribution(dist)]) => Helpers.toStringFn(ToString, dist, ~env) + | ("toSparkline", [IevDistribution(dist)]) => Helpers.toStringFn(ToSparkline(MagicNumbers.Environment.sparklineLength), dist, ~env) - | ("toSparkline", [EvDistribution(dist), EvNumber(n)]) => + | ("toSparkline", [IevDistribution(dist), IevNumber(n)]) => Helpers.toStringFn(ToSparkline(Belt.Float.toInt(n)), dist, ~env) - | ("exp", [EvDistribution(a)]) => + | ("exp", [IevDistribution(a)]) => // https://mathjs.org/docs/reference/functions/exp.html Helpers.twoDiststoDistFn( Algebraic(AsDefault), @@ -234,51 +234,58 @@ let dispatchToGenericOutput = ( a, ~env, )->Some - | ("normalize", [EvDistribution(dist)]) => Helpers.toDistFn(Normalize, dist, ~env) - | ("klDivergence", [EvDistribution(prediction), EvDistribution(answer)]) => + | ("normalize", [IevDistribution(dist)]) => Helpers.toDistFn(Normalize, dist, ~env) + | ("klDivergence", [IevDistribution(prediction), IevDistribution(answer)]) => Some(DistributionOperation.run(FromDist(ToScore(KLDivergence(answer)), prediction), ~env)) - | ("klDivergence", [EvDistribution(prediction), EvDistribution(answer), EvDistribution(prior)]) => + | ( + "klDivergence", + [IevDistribution(prediction), IevDistribution(answer), IevDistribution(prior)], + ) => Helpers.klDivergenceWithPrior(prediction, answer, prior, env) | ( "logScoreWithPointAnswer", - [EvDistribution(prediction), EvNumber(answer), EvDistribution(prior)], + [IevDistribution(prediction), IevNumber(answer), IevDistribution(prior)], ) | ( "logScoreWithPointAnswer", - [EvDistribution(prediction), EvDistribution(Symbolic(#Float(answer))), EvDistribution(prior)], + [ + IevDistribution(prediction), + IevDistribution(Symbolic(#Float(answer))), + IevDistribution(prior), + ], ) => DistributionOperation.run( FromDist(ToScore(LogScore(answer, prior->Some)), prediction), ~env, )->Some - | ("logScoreWithPointAnswer", [EvDistribution(prediction), EvNumber(answer)]) + | ("logScoreWithPointAnswer", [IevDistribution(prediction), IevNumber(answer)]) | ( "logScoreWithPointAnswer", - [EvDistribution(prediction), EvDistribution(Symbolic(#Float(answer)))], + [IevDistribution(prediction), IevDistribution(Symbolic(#Float(answer)))], ) => DistributionOperation.run(FromDist(ToScore(LogScore(answer, None)), prediction), ~env)->Some - | ("isNormalized", [EvDistribution(dist)]) => Helpers.toBoolFn(IsNormalized, dist, ~env) - | ("toPointSet", [EvDistribution(dist)]) => Helpers.toDistFn(ToPointSet, dist, ~env) - | ("scaleLog", [EvDistribution(dist)]) => + | ("isNormalized", [IevDistribution(dist)]) => Helpers.toBoolFn(IsNormalized, dist, ~env) + | ("toPointSet", [IevDistribution(dist)]) => Helpers.toDistFn(ToPointSet, dist, ~env) + | ("scaleLog", [IevDistribution(dist)]) => Helpers.toDistFn(Scale(#Logarithm, MagicNumbers.Math.e), dist, ~env) - | ("scaleLog10", [EvDistribution(dist)]) => Helpers.toDistFn(Scale(#Logarithm, 10.0), dist, ~env) - | ("scaleLog", [EvDistribution(dist), EvNumber(float)]) => + | ("scaleLog10", [IevDistribution(dist)]) => Helpers.toDistFn(Scale(#Logarithm, 10.0), dist, ~env) + | ("scaleLog", [IevDistribution(dist), IevNumber(float)]) => Helpers.toDistFn(Scale(#Logarithm, float), dist, ~env) - | ("scaleLogWithThreshold", [EvDistribution(dist), EvNumber(base), EvNumber(eps)]) => + | ("scaleLogWithThreshold", [IevDistribution(dist), IevNumber(base), IevNumber(eps)]) => Helpers.toDistFn(Scale(#LogarithmWithThreshold(eps), base), dist, ~env) - | ("scalePow", [EvDistribution(dist), EvNumber(float)]) => + | ("scalePow", [IevDistribution(dist), IevNumber(float)]) => Helpers.toDistFn(Scale(#Power, float), dist, ~env) - | ("scaleExp", [EvDistribution(dist)]) => + | ("scaleExp", [IevDistribution(dist)]) => Helpers.toDistFn(Scale(#Power, MagicNumbers.Math.e), dist, ~env) - | ("cdf", [EvDistribution(dist), EvNumber(float)]) => Helpers.toFloatFn(#Cdf(float), dist, ~env) - | ("pdf", [EvDistribution(dist), EvNumber(float)]) => Helpers.toFloatFn(#Pdf(float), dist, ~env) - | ("inv", [EvDistribution(dist), EvNumber(float)]) => Helpers.toFloatFn(#Inv(float), dist, ~env) - | ("toSampleSet", [EvDistribution(dist), EvNumber(float)]) => + | ("cdf", [IevDistribution(dist), IevNumber(float)]) => Helpers.toFloatFn(#Cdf(float), dist, ~env) + | ("pdf", [IevDistribution(dist), IevNumber(float)]) => Helpers.toFloatFn(#Pdf(float), dist, ~env) + | ("inv", [IevDistribution(dist), IevNumber(float)]) => Helpers.toFloatFn(#Inv(float), dist, ~env) + | ("toSampleSet", [IevDistribution(dist), IevNumber(float)]) => Helpers.toDistFn(ToSampleSet(Belt.Int.fromFloat(float)), dist, ~env) - | ("toSampleSet", [EvDistribution(dist)]) => + | ("toSampleSet", [IevDistribution(dist)]) => Helpers.toDistFn(ToSampleSet(env.sampleCount), dist, ~env) - | ("toList", [EvDistribution(SampleSet(dist))]) => Some(FloatArray(SampleSetDist.T.get(dist))) - | ("fromSamples", [EvArray(inputArray)]) => { + | ("toList", [IevDistribution(SampleSet(dist))]) => Some(FloatArray(SampleSetDist.T.get(dist))) + | ("fromSamples", [IevArray(inputArray)]) => { let _wrapInputErrors = x => SampleSetDist.NonNumericInput(x) let parsedArray = Helpers.parseNumberArray(inputArray)->E.R2.errMap(_wrapInputErrors) switch parsedArray { @@ -286,15 +293,15 @@ let dispatchToGenericOutput = ( | Error(e) => GenDistError(SampleSetError(e)) }->Some } - | ("inspect", [EvDistribution(dist)]) => Helpers.toDistFn(Inspect, dist, ~env) - | ("truncateLeft", [EvDistribution(dist), EvNumber(float)]) => + | ("inspect", [IevDistribution(dist)]) => Helpers.toDistFn(Inspect, dist, ~env) + | ("truncateLeft", [IevDistribution(dist), IevNumber(float)]) => Helpers.toDistFn(Truncate(Some(float), None), dist, ~env) - | ("truncateRight", [EvDistribution(dist), EvNumber(float)]) => + | ("truncateRight", [IevDistribution(dist), IevNumber(float)]) => Helpers.toDistFn(Truncate(None, Some(float)), dist, ~env) - | ("truncate", [EvDistribution(dist), EvNumber(float1), EvNumber(float2)]) => + | ("truncate", [IevDistribution(dist), IevNumber(float1), IevNumber(float2)]) => Helpers.toDistFn(Truncate(Some(float1), Some(float2)), dist, ~env) | ("mx" | "mixture", args) => Helpers.mixture(args, ~env)->Some - | ("log", [EvDistribution(a)]) => + | ("log", [IevDistribution(a)]) => Helpers.twoDiststoDistFn( Algebraic(AsDefault), "log", @@ -302,7 +309,7 @@ let dispatchToGenericOutput = ( GenericDist.fromFloat(MagicNumbers.Math.e), ~env, )->Some - | ("log10", [EvDistribution(a)]) => + | ("log10", [IevDistribution(a)]) => Helpers.twoDiststoDistFn( Algebraic(AsDefault), "log", @@ -310,7 +317,7 @@ let dispatchToGenericOutput = ( GenericDist.fromFloat(10.0), ~env, )->Some - | ("unaryMinus", [EvDistribution(a)]) => + | ("unaryMinus", [IevDistribution(a)]) => Helpers.twoDiststoDistFn( Algebraic(AsDefault), "multiply", @@ -333,7 +340,7 @@ let dispatchToGenericOutput = ( Helpers.catchAndConvertTwoArgsToDists(args)->E.O2.fmap(((fst, snd)) => Helpers.twoDiststoDistFn(Pointwise, arithmetic, fst, snd, ~env) ) - | ("dotExp", [EvDistribution(a)]) => + | ("dotExp", [IevDistribution(a)]) => Helpers.twoDiststoDistFn( Pointwise, "dotPow", @@ -350,11 +357,12 @@ let genericOutputToReducerValue = (o: DistributionOperation.outputType): result< Reducer_ErrorValue.errorValue, > => switch o { - | Dist(d) => Ok(ReducerInterface_ExpressionValue.EvDistribution(d)) - | Float(d) => Ok(EvNumber(d)) - | String(d) => Ok(EvString(d)) - | Bool(d) => Ok(EvBool(d)) - | FloatArray(d) => Ok(EvArray(d |> E.A.fmap(r => ReducerInterface_ExpressionValue.EvNumber(r)))) + | Dist(d) => Ok(ReducerInterface_InternalExpressionValue.IevDistribution(d)) + | Float(d) => Ok(IevNumber(d)) + | String(d) => Ok(IevString(d)) + | Bool(d) => Ok(IevBool(d)) + | FloatArray(d) => + Ok(IevArray(d |> E.A.fmap(r => ReducerInterface_InternalExpressionValue.IevNumber(r)))) | GenDistError(err) => Error(REDistributionError(err)) } diff --git a/packages/squiggle-lang/src/rescript/ReducerInterface/ReducerInterface_GenericDistribution.resi b/packages/squiggle-lang/src/rescript/ReducerInterface/ReducerInterface_GenericDistribution.resi index 7f26a610..1c7948ad 100644 --- a/packages/squiggle-lang/src/rescript/ReducerInterface/ReducerInterface_GenericDistribution.resi +++ b/packages/squiggle-lang/src/rescript/ReducerInterface/ReducerInterface_GenericDistribution.resi @@ -1,4 +1,6 @@ let dispatch: ( - ReducerInterface_ExpressionValue.functionCall, + ReducerInterface_InternalExpressionValue.functionCall, ReducerInterface_ExpressionValue.environment, -) => option> +) => option< + result, +> diff --git a/packages/squiggle-lang/src/rescript/ReducerInterface/ReducerInterface_InternalExpressionValue.res b/packages/squiggle-lang/src/rescript/ReducerInterface/ReducerInterface_InternalExpressionValue.res new file mode 100644 index 00000000..b912dde2 --- /dev/null +++ b/packages/squiggle-lang/src/rescript/ReducerInterface/ReducerInterface_InternalExpressionValue.res @@ -0,0 +1,260 @@ +module ErrorValue = Reducer_ErrorValue +module ExternalExpressionValue = ReducerInterface_ExpressionValue +module Extra_Array = Reducer_Extra_Array +type internalCode = ExternalExpressionValue.internalCode +type environment = ExternalExpressionValue.environment + +let defaultEnvironment = ExternalExpressionValue.defaultEnvironment + +type rec expressionValue = + | IevArray(array) // FIXME: Convert + | IevArrayString(array) // FIXME: Convert + | IevBool(bool) + | IevCall(string) // External function call + | IevDate(Js.Date.t) + | IevDeclaration(lambdaDeclaration) + | IevDistribution(DistributionTypes.genericDist) + | IevLambda(lambdaValue) + | IevModule(nameSpace) // FIXME: Convert + | IevNumber(float) + | IevRecord(map) + | IevString(string) + | IevSymbol(string) + | IevTimeDuration(float) + | IevTypeIdentifier(string) +and map = Belt.Map.String.t +and nameSpace = NameSpace(Belt.Map.String.t) +and tmpExternalBindings = Js.Dict.t // FIXME: Remove +and lambdaValue = { + parameters: array, + context: nameSpace, + body: internalCode, +} +and lambdaDeclaration = Declaration.declaration + +type t = expressionValue + +type functionCall = (string, array) + +let rec toString = aValue => + switch aValue { + | IevArray(anArray) => { + let args = anArray->Js.Array2.map(each => toString(each))->Js.Array2.toString + `[${args}]` + } + | IevArrayString(anArray) => { + let args = anArray->Js.Array2.toString + `[${args}]` + } + | IevBool(aBool) => Js.String.make(aBool) + | IevCall(fName) => `:${fName}` + | IevDate(date) => DateTime.Date.toString(date) + | IevDeclaration(d) => Declaration.toString(d, r => toString(IevLambda(r))) + | IevDistribution(dist) => GenericDist.toString(dist) + | IevLambda(lambdaValue) => `lambda(${Js.Array2.toString(lambdaValue.parameters)}=>internal code)` + | IevModule(m) => `@${m->toStringNameSpace}` + | IevNumber(aNumber) => Js.String.make(aNumber) + | IevRecord(aMap) => aMap->toStringMap + | IevString(aString) => `'${aString}'` + | IevSymbol(aString) => `:${aString}` + | IevTimeDuration(t) => DateTime.Duration.toString(t) + | IevTypeIdentifier(id) => `#${id}` + } +and toStringMap = aMap => { + let pairs = + aMap + ->Belt.Map.String.toArray + ->Js.Array2.map(((eachKey, eachValue)) => `${eachKey}: ${toString(eachValue)}`) + ->Js.Array2.toString + `{${pairs}}` +} +and toStringNameSpace = nameSpace => { + let NameSpace(container) = nameSpace + container->toStringMap +} + +let toStringWithType = aValue => + switch aValue { + | IevArray(_) => `Array::${toString(aValue)}` + | IevArrayString(_) => `ArrayString::${toString(aValue)}` + | IevBool(_) => `Bool::${toString(aValue)}` + | IevCall(_) => `Call::${toString(aValue)}` + | IevDistribution(_) => `Distribution::${toString(aValue)}` + | IevLambda(_) => `Lambda::${toString(aValue)}` + | IevNumber(_) => `Number::${toString(aValue)}` + | IevRecord(_) => `Record::${toString(aValue)}` + | IevString(_) => `String::${toString(aValue)}` + | IevSymbol(_) => `Symbol::${toString(aValue)}` + | IevDate(_) => `Date::${toString(aValue)}` + | IevTimeDuration(_) => `Date::${toString(aValue)}` + | IevDeclaration(_) => `Declaration::${toString(aValue)}` + | IevTypeIdentifier(_) => `TypeIdentifier::${toString(aValue)}` + | IevModule(_) => `Module::${toString(aValue)}` + } + +let argsToString = (args: array): string => { + args->Js.Array2.map(arg => arg->toString)->Js.Array2.toString +} + +let toStringFunctionCall = ((fn, args)): string => `${fn}(${argsToString(args)})` + +let toStringResult = x => + switch x { + | Ok(a) => `Ok(${toString(a)})` + | Error(m) => `Error(${ErrorValue.errorToString(m)})` + } + +let toStringResultOkless = (codeResult: result): string => + switch codeResult { + | Ok(a) => toString(a) + | Error(m) => `Error(${ErrorValue.errorToString(m)})` + } + +let toStringResultRecord = x => + switch x { + | Ok(a) => `Ok(${ExternalExpressionValue.toStringRecord(a)})` + | Error(m) => `Error(${ErrorValue.errorToString(m)})` + } + +type expressionValueType = + | EvtArray + | EvtArrayString + | EvtBool + | EvtCall + | EvtDistribution + | EvtLambda + | EvtNumber + | EvtRecord + | EvtString + | EvtSymbol + | EvtDate + | EvtTimeDuration + | EvtDeclaration + | EvtTypeIdentifier + | EvtModule + +type functionCallSignature = CallSignature(string, array) +type functionDefinitionSignature = + FunctionDefinitionSignature(functionCallSignature, expressionValueType) + +let valueToValueType = value => + switch value { + | IevArray(_) => EvtArray + | IevArrayString(_) => EvtArrayString + | IevBool(_) => EvtBool + | IevCall(_) => EvtCall + | IevDistribution(_) => EvtDistribution + | IevLambda(_) => EvtLambda + | IevNumber(_) => EvtNumber + | IevRecord(_) => EvtRecord + | IevString(_) => EvtString + | IevSymbol(_) => EvtSymbol + | IevDate(_) => EvtDate + | IevTimeDuration(_) => EvtTimeDuration + | IevDeclaration(_) => EvtDeclaration + | IevTypeIdentifier(_) => EvtTypeIdentifier + | IevModule(_) => EvtModule + } + +let functionCallToCallSignature = (functionCall: functionCall): functionCallSignature => { + let (fn, args) = functionCall + CallSignature(fn, args->Js.Array2.map(valueToValueType)) +} + +let valueTypeToString = (valueType: expressionValueType): string => + switch valueType { + | EvtArray => `Array` + | EvtArrayString => `ArrayString` + | EvtBool => `Bool` + | EvtCall => `Call` + | EvtDistribution => `Distribution` + | EvtLambda => `Lambda` + | EvtNumber => `Number` + | EvtRecord => `Record` + | EvtString => `String` + | EvtSymbol => `Symbol` + | EvtDate => `Date` + | EvtTimeDuration => `Duration` + | EvtDeclaration => `Declaration` + | EvtTypeIdentifier => `TypeIdentifier` + | EvtModule => `Module` + } + +let functionCallSignatureToString = (functionCallSignature: functionCallSignature): string => { + let CallSignature(fn, args) = functionCallSignature + `${fn}(${args->Js.Array2.map(valueTypeToString)->Js.Array2.toString})` +} + +let rec toExternal = (iev: expressionValue): ExternalExpressionValue.expressionValue => { + switch iev { + | IevArray(v) => v->Belt.Array.map(e => toExternal(e))->EvArray + | IevArrayString(v) => EvArrayString(v) + | IevBool(v) => EvBool(v) + | IevCall(v) => EvCall(v) + | IevDistribution(v) => EvDistribution(v) + | IevLambda(v) => EvLambda(lambdaValueToExternal(v)) + | IevNumber(v) => EvNumber(v) + | IevRecord(v) => v->mapToExternal->EvRecord + | IevString(v) => EvString(v) + | IevSymbol(v) => EvSymbol(v) + | IevDate(v) => EvDate(v) + | IevTimeDuration(v) => EvTimeDuration(v) + | IevDeclaration(v) => { + let fn = lambdaValueToExternal(v.fn) + let args = v.args + EvDeclaration({fn: fn, args: args}) + } + | IevTypeIdentifier(v) => EvTypeIdentifier(v) + | IevModule(v) => v->nameSpaceToTypeScriptBindings->EvModule + } +} +and mapToExternal = v => + v->Belt.Map.String.map(e => toExternal(e))->Belt.Map.String.toArray->Js.Dict.fromArray +and lambdaValueToExternal = v => { + let p = v.parameters + let c = v.context->nameSpaceToTypeScriptBindings + let b = v.body + {parameters: p, context: c, body: b} +} +and nameSpaceToTypeScriptBindings = ( + nameSpace: nameSpace, +): ReducerInterface_ExpressionValue.externalBindings => { + let NameSpace(container) = nameSpace + Belt.Map.String.map(container, e => toExternal(e))->Belt.Map.String.toArray->Js.Dict.fromArray +} + +let rec toInternal = (ev: ExternalExpressionValue.expressionValue): expressionValue => { + switch ev { + | EvArray(v) => v->Belt.Array.map(e => toInternal(e))->IevArray + | EvArrayString(v) => IevArrayString(v) + | EvBool(v) => IevBool(v) + | EvCall(v) => IevCall(v) + | EvDistribution(v) => IevDistribution(v) + | EvLambda(v) => IevLambda(lambdaValueToInternal(v)) + | EvNumber(v) => IevNumber(v) + | EvRecord(v) => v->recordToInternal->IevRecord + | EvString(v) => IevString(v) + | EvSymbol(v) => IevSymbol(v) + | EvDate(v) => IevDate(v) + | EvTimeDuration(v) => IevTimeDuration(v) + | EvDeclaration(v) => { + let fn = lambdaValueToInternal(v.fn) + let args = v.args + IevDeclaration({fn: fn, args: args}) + } + | EvTypeIdentifier(v) => IevTypeIdentifier(v) + | EvModule(v) => v->nameSpaceFromTypeScriptBindings->IevModule + } +} +and recordToInternal = v => + v->Js.Dict.entries->Belt.Map.String.fromArray->Belt.Map.String.map(e => toInternal(e)) +and lambdaValueToInternal = v => { + let p = v.parameters + let c = v.context->nameSpaceFromTypeScriptBindings + let b = v.body + {parameters: p, context: c, body: b} +} +and nameSpaceFromTypeScriptBindings = ( + r: ReducerInterface_ExpressionValue.externalBindings, +): nameSpace => + r->Js.Dict.entries->Belt.Map.String.fromArray->Belt.Map.String.map(e => toInternal(e))->NameSpace diff --git a/packages/squiggle-lang/src/rescript/ReducerInterface/ReducerInterface_Number.res b/packages/squiggle-lang/src/rescript/ReducerInterface/ReducerInterface_Number.res index 5cef930e..8d5b008f 100644 --- a/packages/squiggle-lang/src/rescript/ReducerInterface/ReducerInterface_Number.res +++ b/packages/squiggle-lang/src/rescript/ReducerInterface/ReducerInterface_Number.res @@ -1,4 +1,4 @@ -module EV = ReducerInterface_ExpressionValue +module EV = ReducerInterface_InternalExpressionValue type expressionValue = EV.expressionValue module ScientificUnit = { @@ -37,9 +37,9 @@ let dispatch = (call: EV.functionCall, _: DistributionOperation.env): option< | "fromUnit_G" | "fromUnit_T" | "fromUnit_P") as op, - [EvNumber(f)], + [IevNumber(f)], ) => - op->ScientificUnit.getMultiplier->E.O2.fmap(multiplier => EV.EvNumber(f *. multiplier)->Ok) + op->ScientificUnit.getMultiplier->E.O2.fmap(multiplier => EV.IevNumber(f *. multiplier)->Ok) | _ => None } } diff --git a/packages/squiggle-lang/src/rescript/ReducerInterface/ReducerInterface_StdLib.res b/packages/squiggle-lang/src/rescript/ReducerInterface/ReducerInterface_StdLib.res index f341f9e2..43823007 100644 --- a/packages/squiggle-lang/src/rescript/ReducerInterface/ReducerInterface_StdLib.res +++ b/packages/squiggle-lang/src/rescript/ReducerInterface/ReducerInterface_StdLib.res @@ -1,6 +1,5 @@ -module Bindings = Reducer_Category_Bindings +module Module = Reducer_Category_Module -let internalStdLib = Bindings.emptyBindings->SquiggleLibrary_Math.makeBindings +let internalStdLib = Module.emptyModule->SquiggleLibrary_Math.makeBindings -@genType -let externalStdLib = internalStdLib->Bindings.toRecord +let externalStdLib = internalStdLib->Module.toTypeScriptBindings diff --git a/packages/squiggle-lang/src/rescript/SquiggleLibrary/SquiggleLibrary_Math.res b/packages/squiggle-lang/src/rescript/SquiggleLibrary/SquiggleLibrary_Math.res index a29fafcc..13550eda 100644 --- a/packages/squiggle-lang/src/rescript/SquiggleLibrary/SquiggleLibrary_Math.res +++ b/packages/squiggle-lang/src/rescript/SquiggleLibrary/SquiggleLibrary_Math.res @@ -1,8 +1,8 @@ -module Bindings = Reducer_Category_Bindings +module Bindings = Reducer_Category_Module module Module = Reducer_Category_Module let m = Module.emptyModule->Module.defineNumber("pi", Js.Math._PI)->Module.defineNumber("e", Js.Math._E) -let makeBindings = (previousBindings: Bindings.t): Bindings.t => +let makeBindings = (previousBindings: Module.t): Module.t => previousBindings->Bindings.defineModule("Math", m) From 7b2c16d90f0f28e4eb076316fd53e31fa52f6de2 Mon Sep 17 00:00:00 2001 From: Umur Ozkul Date: Thu, 23 Jun 2022 03:54:37 +0200 Subject: [PATCH 06/12] fix typescript test --- .../rescript/Reducer/Reducer_Expression/Reducer_Expression.res | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/squiggle-lang/src/rescript/Reducer/Reducer_Expression/Reducer_Expression.res b/packages/squiggle-lang/src/rescript/Reducer/Reducer_Expression/Reducer_Expression.res index 2f634709..28a2d538 100644 --- a/packages/squiggle-lang/src/rescript/Reducer/Reducer_Expression/Reducer_Expression.res +++ b/packages/squiggle-lang/src/rescript/Reducer/Reducer_Expression/Reducer_Expression.res @@ -151,7 +151,7 @@ let evaluatePartialUsingExternalBindings = ( code, ) switch rAnswer { - | Ok(EvRecord(externalBindings)) => Ok(externalBindings) + | Ok(EvModule(externalBindings)) => Ok(externalBindings) | Ok(_) => Error(Reducer_ErrorValue.RESyntaxError(`Partials must end with an assignment or record`)) | Error(err) => err->Error From 95d3bf6eaaeffbf17c24037558b49f26db3e56f2 Mon Sep 17 00:00:00 2001 From: Umur Ozkul Date: Thu, 23 Jun 2022 03:36:57 +0200 Subject: [PATCH 07/12] merge Reducer --- .../ReducerInterface_Distribution_test.res | 1 + .../ReducerInterface_StdLib.res | 1 + .../SquiggleLibrary/SquiggleLibrary_Math.res | 23 +++++++++++++++---- 3 files changed, 21 insertions(+), 4 deletions(-) diff --git a/packages/squiggle-lang/__tests__/ReducerInterface/ReducerInterface_Distribution_test.res b/packages/squiggle-lang/__tests__/ReducerInterface/ReducerInterface_Distribution_test.res index a2fa37df..ecc07bfa 100644 --- a/packages/squiggle-lang/__tests__/ReducerInterface/ReducerInterface_Distribution_test.res +++ b/packages/squiggle-lang/__tests__/ReducerInterface/ReducerInterface_Distribution_test.res @@ -80,6 +80,7 @@ describe("eval on distribution functions", () => { testEval("truncateLeft(normal(5,2), 3)", "Ok(Point Set Distribution)") testEval("truncateRight(normal(5,2), 3)", "Ok(Point Set Distribution)") testEval("truncate(normal(5,2), 3, 8)", "Ok(Point Set Distribution)") + testEval("isNormalized(truncate(normal(5,2), 3, 8))", "Ok(true)") }) describe("exp", () => { diff --git a/packages/squiggle-lang/src/rescript/ReducerInterface/ReducerInterface_StdLib.res b/packages/squiggle-lang/src/rescript/ReducerInterface/ReducerInterface_StdLib.res index 43823007..b714790a 100644 --- a/packages/squiggle-lang/src/rescript/ReducerInterface/ReducerInterface_StdLib.res +++ b/packages/squiggle-lang/src/rescript/ReducerInterface/ReducerInterface_StdLib.res @@ -2,4 +2,5 @@ module Module = Reducer_Category_Module let internalStdLib = Module.emptyModule->SquiggleLibrary_Math.makeBindings +@genType let externalStdLib = internalStdLib->Module.toTypeScriptBindings diff --git a/packages/squiggle-lang/src/rescript/SquiggleLibrary/SquiggleLibrary_Math.res b/packages/squiggle-lang/src/rescript/SquiggleLibrary/SquiggleLibrary_Math.res index 13550eda..4dc59b56 100644 --- a/packages/squiggle-lang/src/rescript/SquiggleLibrary/SquiggleLibrary_Math.res +++ b/packages/squiggle-lang/src/rescript/SquiggleLibrary/SquiggleLibrary_Math.res @@ -1,8 +1,23 @@ module Bindings = Reducer_Category_Module module Module = Reducer_Category_Module -let m = - Module.emptyModule->Module.defineNumber("pi", Js.Math._PI)->Module.defineNumber("e", Js.Math._E) +let availableNumbers: array<(string, float)> = [ + ("pi", Js.Math._PI), + ("e", Js.Math._E), + ("ln2", Js.Math._LN2), + ("ln10", Js.Math._LN10), + ("log2e", Js.Math._LOG2E), + ("log10e", Js.Math._LOG10E), + ("sqrt2", Js.Math._SQRT2), + ("sqrt1_2", Js.Math._SQRT1_2), + ("phi", 1.618033988749895), + ("tau", 6.283185307179586), +] -let makeBindings = (previousBindings: Module.t): Module.t => - previousBindings->Bindings.defineModule("Math", m) +let mathBindings: Bindings.t = + availableNumbers + ->E.A2.fmap(((name, v)) => (name, ReducerInterface_InternalExpressionValue.IevNumber(v))) + ->Bindings.fromArray + +let makeBindings = (previousBindings: Bindings.t): Bindings.t => + previousBindings->Bindings.defineModule("Math", mathBindings) From 8e4fb99b536a85a5ec8b7d46413968b5480f8c1f Mon Sep 17 00:00:00 2001 From: Vyacheslav Matyukhin Date: Thu, 23 Jun 2022 10:35:42 +0300 Subject: [PATCH 08/12] cleanup unused code; fix tsc builds --- packages/vscode-ext/client/src/client.ts | 2 +- packages/vscode-ext/package.json | 4 ++-- packages/vscode-ext/server/src/server.ts | 4 ---- 3 files changed, 3 insertions(+), 7 deletions(-) diff --git a/packages/vscode-ext/client/src/client.ts b/packages/vscode-ext/client/src/client.ts index 83cbd59e..83a80129 100644 --- a/packages/vscode-ext/client/src/client.ts +++ b/packages/vscode-ext/client/src/client.ts @@ -17,7 +17,7 @@ export const startClient = (context: vscode.ExtensionContext) => { ); // The debug options for the server // --inspect=6009: runs the server in Node's Inspector mode so VS Code can attach to the server for debugging - let debugOptions = { execArgv: ["--nolazy", "--inspect=6009"] }; + let debugOptions = { execArgv: ["--nolazy" /*"--inspect=6009"*/] }; // If the extension is launched in debug mode then the debug server options are used // Otherwise the run options are used diff --git a/packages/vscode-ext/package.json b/packages/vscode-ext/package.json index e2f6c025..239ad6ca 100644 --- a/packages/vscode-ext/package.json +++ b/packages/vscode-ext/package.json @@ -125,11 +125,11 @@ }, "scripts": { "vscode:prepublish": "yarn run compile", - "compile:tsc": "tsc -p ./", + "compile:tsc": "tsc -b", "compile:grammar": "js-yaml syntaxes/squiggle.tmLanguage.yaml >syntaxes/squiggle.tmLanguage.json", "compile:vendor": "(cd ../squiggle-lang && yarn run build) && (cd ../components && yarn run bundle && yarn run build:css) && mkdir -p media/vendor && cp ../components/dist/bundle.js media/vendor/components.js && cp ../components/dist/main.css media/vendor/components.css && cp ../../node_modules/react/umd/react.production.min.js media/vendor/react.js && cp ../../node_modules/react-dom/umd/react-dom.production.min.js media/vendor/react-dom.js && cp ../website/static/img/quri-logo.png media/vendor/icon.png", "compile": "yarn run compile:tsc && yarn run compile:grammar && yarn run compile:vendor", - "watch": "tsc -watch -p ./", + "watch": "tsc -b -watch", "pretest": "yarn run compile && yarn run lint", "lint": "eslint client/src server/src --ext ts", "format": "eslint client/src server/src --ext ts --fix", diff --git a/packages/vscode-ext/server/src/server.ts b/packages/vscode-ext/server/src/server.ts index 84d9fd44..dd22a0ff 100644 --- a/packages/vscode-ext/server/src/server.ts +++ b/packages/vscode-ext/server/src/server.ts @@ -45,12 +45,8 @@ connection.onInitialize((params: InitializeParams) => { async function validateSquiggleDocument( textDocument: TextDocument ): Promise { - // The validator creates diagnostics for all uppercase words length 2 and more const text = textDocument.getText(); - const pattern = /\b[A-Z]{2,}\b/g; - let m: RegExpExecArray | null; - let problems = 0; const diagnostics: Diagnostic[] = []; const parseResult = parse(text); From 9da6c12fc322c0ba729d7e27fc5d877960600c28 Mon Sep 17 00:00:00 2001 From: Vyacheslav Matyukhin Date: Thu, 23 Jun 2022 12:00:12 +0300 Subject: [PATCH 09/12] fix compile script --- packages/vscode-ext/package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/vscode-ext/package.json b/packages/vscode-ext/package.json index 239ad6ca..effdb398 100644 --- a/packages/vscode-ext/package.json +++ b/packages/vscode-ext/package.json @@ -128,7 +128,7 @@ "compile:tsc": "tsc -b", "compile:grammar": "js-yaml syntaxes/squiggle.tmLanguage.yaml >syntaxes/squiggle.tmLanguage.json", "compile:vendor": "(cd ../squiggle-lang && yarn run build) && (cd ../components && yarn run bundle && yarn run build:css) && mkdir -p media/vendor && cp ../components/dist/bundle.js media/vendor/components.js && cp ../components/dist/main.css media/vendor/components.css && cp ../../node_modules/react/umd/react.production.min.js media/vendor/react.js && cp ../../node_modules/react-dom/umd/react-dom.production.min.js media/vendor/react-dom.js && cp ../website/static/img/quri-logo.png media/vendor/icon.png", - "compile": "yarn run compile:tsc && yarn run compile:grammar && yarn run compile:vendor", + "compile": "yarn run compile:vendor && yarn run compile:grammar && yarn run compile:tsc", "watch": "tsc -b -watch", "pretest": "yarn run compile && yarn run lint", "lint": "eslint client/src server/src --ext ts", From 07d5c6d8b324a3eda2328e2f6e045cbcb7372b7a Mon Sep 17 00:00:00 2001 From: Umur Ozkul Date: Thu, 23 Jun 2022 20:38:07 +0200 Subject: [PATCH 10/12] Iev -> IEv Just more readable prefix --- .../Reducer_Dispatch_BuiltInMacros_test.res | 18 +- .../__tests__/Reducer/Reducer_Helpers.res | 4 +- .../Reducer_MathJsEval_test.res | 12 +- .../FunctionRegistry_Core.res | 54 +++--- .../FunctionRegistry_Helpers.res | 10 +- .../FunctionRegistry_Library.res | 4 +- .../Reducer_Category_Module.res | 22 +-- .../Reducer_Category_Module_TypeChecker.res | 2 +- .../Reducer_Dispatch_BuiltIn.res | 150 +++++++-------- .../Reducer_Dispatch_BuiltInMacros.res | 24 +-- .../Reducer_Expression/Reducer_Expression.res | 14 +- .../Reducer_Expression_BindingsReplacer.res | 8 +- .../Reducer_Expression_ExpressionBuilder.res | 26 +-- .../Reducer_Expression_Lambda.res | 2 +- .../Reducer_Expression_T.res | 2 +- .../Reducer/Reducer_Js/Reducer_Js_Gate.res | 8 +- .../Reducer_MathJs/Reducer_MathJs_Eval.res | 2 +- .../ReducerInterface_Date.res | 22 +-- .../ReducerInterface_Duration.res | 50 ++--- .../ReducerInterface_GenericDistribution.res | 118 ++++++------ ...ducerInterface_InternalExpressionValue.res | 180 +++++++++--------- .../ReducerInterface_Number.res | 4 +- .../SquiggleLibrary/SquiggleLibrary_Math.res | 2 +- 23 files changed, 369 insertions(+), 369 deletions(-) diff --git a/packages/squiggle-lang/__tests__/Reducer/Reducer_Dispatch/Reducer_Dispatch_BuiltInMacros_test.res b/packages/squiggle-lang/__tests__/Reducer/Reducer_Dispatch/Reducer_Dispatch_BuiltInMacros_test.res index 96f80379..84659ed7 100644 --- a/packages/squiggle-lang/__tests__/Reducer/Reducer_Dispatch/Reducer_Dispatch_BuiltInMacros_test.res +++ b/packages/squiggle-lang/__tests__/Reducer/Reducer_Dispatch/Reducer_Dispatch_BuiltInMacros_test.res @@ -26,14 +26,14 @@ describe("bindStatement", () => { // Now let's feed a binding to see what happens testMacro( [], - eBindStatement(eBindings([("x", IevNumber(2.))]), exampleStatementX), + eBindStatement(eBindings([("x", IEvNumber(2.))]), exampleStatementX), "Ok((:$_setBindings_$ @{x: 2} :y 2) context: @{x: 2})", ) // An expression does not return a binding, thus error testMacro([], eBindStatement(eBindings([]), exampleExpression), "Assignment expected") // When bindings from previous statement are missing the context is injected. This must be the first statement of a block testMacro( - [("z", IevNumber(99.))], + [("z", IEvNumber(99.))], eBindStatementDefault(exampleStatementY), "Ok((:$_setBindings_$ @{z: 99} :y 1) context: @{z: 99})", ) @@ -43,24 +43,24 @@ describe("bindExpression", () => { // x is simply bound in the expression testMacro( [], - eBindExpression(eBindings([("x", IevNumber(2.))]), eSymbol("x")), + eBindExpression(eBindings([("x", IEvNumber(2.))]), eSymbol("x")), "Ok(2 context: @{x: 2})", ) // When an let statement is the end expression then bindings are returned testMacro( [], - eBindExpression(eBindings([("x", IevNumber(2.))]), exampleStatementY), + eBindExpression(eBindings([("x", IEvNumber(2.))]), exampleStatementY), "Ok((:$_exportBindings_$ (:$_setBindings_$ @{x: 2} :y 1)) context: @{x: 2})", ) // Now let's reduce that expression testMacroEval( [], - eBindExpression(eBindings([("x", IevNumber(2.))]), exampleStatementY), + eBindExpression(eBindings([("x", IEvNumber(2.))]), exampleStatementY), "Ok(@{x: 2,y: 1})", ) // When bindings are missing the context is injected. This must be the first and last statement of a block testMacroEval( - [("z", IevNumber(99.))], + [("z", IEvNumber(99.))], eBindExpressionDefault(exampleStatementY), "Ok(@{y: 1,z: 99})", ) @@ -115,7 +115,7 @@ describe("block", () => { "Ok((:$$_bindExpression_$$ {(:$_let_$ :y (:add :x 1)); :y}))", ) testMacroEval( - [("x", IevNumber(1.))], + [("x", IEvNumber(1.))], eBlock(list{ eBlock(list{ eLetStatement("y", eFunction("add", list{eSymbol("x"), eNumber(1.)})), @@ -135,12 +135,12 @@ describe("lambda", () => { testMacro([], callLambdaExpression, "Ok(((:$$_lambda_$$ [y] :y) 1))") testMacroEval([], callLambdaExpression, "Ok(1)") // Parameters shadow the outer scope - testMacroEval([("y", IevNumber(666.))], callLambdaExpression, "Ok(1)") + testMacroEval([("y", IEvNumber(666.))], callLambdaExpression, "Ok(1)") // When not shadowed by the parameters, the outer scope variables are available let lambdaExpression = eFunction( "$$_lambda_$$", list{eArrayString(["z"]), eFunction("add", list{eSymbol("y"), eSymbol("z")})}, ) let callLambdaExpression = eList(list{lambdaExpression, eNumber(1.)}) - testMacroEval([("y", IevNumber(666.))], callLambdaExpression, "Ok(667)") + testMacroEval([("y", IEvNumber(666.))], callLambdaExpression, "Ok(667)") }) diff --git a/packages/squiggle-lang/__tests__/Reducer/Reducer_Helpers.res b/packages/squiggle-lang/__tests__/Reducer/Reducer_Helpers.res index afeff706..569b187f 100644 --- a/packages/squiggle-lang/__tests__/Reducer/Reducer_Helpers.res +++ b/packages/squiggle-lang/__tests__/Reducer/Reducer_Helpers.res @@ -6,11 +6,11 @@ module Module = Reducer_Category_Module let removeDefaultsInternal = (iev: InternalExpressionValue.expressionValue) => { switch iev { - | InternalExpressionValue.IevModule(nameSpace) => + | InternalExpressionValue.IEvModule(nameSpace) => Module.removeOther( nameSpace, ReducerInterface.StdLib.internalStdLib, - )->InternalExpressionValue.IevModule + )->InternalExpressionValue.IEvModule | value => value } } diff --git a/packages/squiggle-lang/__tests__/Reducer/Reducer_MathJs/Reducer_MathJsEval_test.res b/packages/squiggle-lang/__tests__/Reducer/Reducer_MathJs/Reducer_MathJsEval_test.res index 8e5bdef6..ed00e957 100644 --- a/packages/squiggle-lang/__tests__/Reducer/Reducer_MathJs/Reducer_MathJsEval_test.res +++ b/packages/squiggle-lang/__tests__/Reducer/Reducer_MathJs/Reducer_MathJsEval_test.res @@ -5,14 +5,14 @@ open Jest open ExpectJs describe("eval", () => { - test("Number", () => expect(MathJs.Eval.eval("1"))->toEqual(Ok(IevNumber(1.)))) - test("Number expr", () => expect(MathJs.Eval.eval("1-1"))->toEqual(Ok(IevNumber(0.)))) - test("String", () => expect(MathJs.Eval.eval("'hello'"))->toEqual(Ok(IevString("hello")))) + test("Number", () => expect(MathJs.Eval.eval("1"))->toEqual(Ok(IEvNumber(1.)))) + test("Number expr", () => expect(MathJs.Eval.eval("1-1"))->toEqual(Ok(IEvNumber(0.)))) + test("String", () => expect(MathJs.Eval.eval("'hello'"))->toEqual(Ok(IEvString("hello")))) test("String expr", () => - expect(MathJs.Eval.eval("concat('hello ','world')"))->toEqual(Ok(IevString("hello world"))) + expect(MathJs.Eval.eval("concat('hello ','world')"))->toEqual(Ok(IEvString("hello world"))) ) - test("Boolean", () => expect(MathJs.Eval.eval("true"))->toEqual(Ok(IevBool(true)))) - test("Boolean expr", () => expect(MathJs.Eval.eval("2>1"))->toEqual(Ok(IevBool(true)))) + test("Boolean", () => expect(MathJs.Eval.eval("true"))->toEqual(Ok(IEvBool(true)))) + test("Boolean expr", () => expect(MathJs.Eval.eval("2>1"))->toEqual(Ok(IEvBool(true)))) }) describe("errors", () => { diff --git a/packages/squiggle-lang/src/rescript/FunctionRegistry/FunctionRegistry_Core.res b/packages/squiggle-lang/src/rescript/FunctionRegistry/FunctionRegistry_Core.res index cf19fd63..e9d526bf 100644 --- a/packages/squiggle-lang/src/rescript/FunctionRegistry/FunctionRegistry_Core.res +++ b/packages/squiggle-lang/src/rescript/FunctionRegistry/FunctionRegistry_Core.res @@ -75,13 +75,13 @@ module FRType = { let rec toFrValue = (r: expressionValue): option => switch r { - | IevNumber(f) => Some(FRValueNumber(f)) - | IevString(f) => Some(FRValueString(f)) - | IevDistribution(f) => Some(FRValueDistOrNumber(FRValueDist(f))) - | IevLambda(f) => Some(FRValueLambda(f)) - | IevArray(elements) => + | IEvNumber(f) => Some(FRValueNumber(f)) + | IEvString(f) => Some(FRValueString(f)) + | IEvDistribution(f) => Some(FRValueDistOrNumber(FRValueDist(f))) + | IEvLambda(f) => Some(FRValueLambda(f)) + | IEvArray(elements) => elements->E.A2.fmap(toFrValue)->E.A.O.openIfAllSome->E.O2.fmap(r => FRValueArray(r)) - | IevRecord(map) => + | IEvRecord(map) => Belt.Map.String.toArray(map) ->E.A2.fmap(((key, item)) => item->toFrValue->E.O2.fmap(o => (key, o))) ->E.A.O.openIfAllSome @@ -92,26 +92,26 @@ module FRType = { let rec matchWithExpressionValue = (t: t, r: expressionValue): option => switch (t, r) { | (FRTypeAny, f) => toFrValue(f) - | (FRTypeString, IevString(f)) => Some(FRValueString(f)) - | (FRTypeNumber, IevNumber(f)) => Some(FRValueNumber(f)) - | (FRTypeDistOrNumber, IevNumber(f)) => Some(FRValueDistOrNumber(FRValueNumber(f))) - | (FRTypeDistOrNumber, IevDistribution(Symbolic(#Float(f)))) => + | (FRTypeString, IEvString(f)) => Some(FRValueString(f)) + | (FRTypeNumber, IEvNumber(f)) => Some(FRValueNumber(f)) + | (FRTypeDistOrNumber, IEvNumber(f)) => Some(FRValueDistOrNumber(FRValueNumber(f))) + | (FRTypeDistOrNumber, IEvDistribution(Symbolic(#Float(f)))) => Some(FRValueDistOrNumber(FRValueNumber(f))) - | (FRTypeDistOrNumber, IevDistribution(f)) => Some(FRValueDistOrNumber(FRValueDist(f))) - | (FRTypeNumeric, IevNumber(f)) => Some(FRValueNumber(f)) - | (FRTypeNumeric, IevDistribution(Symbolic(#Float(f)))) => Some(FRValueNumber(f)) - | (FRTypeLambda, IevLambda(f)) => Some(FRValueLambda(f)) - | (FRTypeArray(intendedType), IevArray(elements)) => { + | (FRTypeDistOrNumber, IEvDistribution(f)) => Some(FRValueDistOrNumber(FRValueDist(f))) + | (FRTypeNumeric, IEvNumber(f)) => Some(FRValueNumber(f)) + | (FRTypeNumeric, IEvDistribution(Symbolic(#Float(f)))) => Some(FRValueNumber(f)) + | (FRTypeLambda, IEvLambda(f)) => Some(FRValueLambda(f)) + | (FRTypeArray(intendedType), IEvArray(elements)) => { let el = elements->E.A2.fmap(matchWithExpressionValue(intendedType)) E.A.O.openIfAllSome(el)->E.O2.fmap(r => FRValueArray(r)) } - | (FRTypeDict(r), IevRecord(map)) => + | (FRTypeDict(r), IEvRecord(map)) => map ->Belt.Map.String.toArray ->E.A2.fmap(((key, item)) => matchWithExpressionValue(r, item)->E.O2.fmap(o => (key, o))) ->E.A.O.openIfAllSome ->E.O2.fmap(r => FRValueDict(Js.Dict.fromArray(r))) - | (FRTypeRecord(recordParams), IevRecord(map)) => { + | (FRTypeRecord(recordParams), IEvRecord(map)) => { let getAndMatch = (name, input) => Belt.Map.String.get(map, name)->E.O.bind(matchWithExpressionValue(input)) //All names in the type must be present. If any are missing, the corresponding @@ -127,17 +127,17 @@ module FRType = { let rec matchReverse = (e: frValue): expressionValue => switch e { - | FRValueNumber(f) => IevNumber(f) - | FRValueDistOrNumber(FRValueNumber(n)) => IevNumber(n) - | FRValueDistOrNumber(FRValueDist(n)) => IevDistribution(n) - | FRValueDist(dist) => IevDistribution(dist) - | FRValueArray(elements) => IevArray(elements->E.A2.fmap(matchReverse)) + | FRValueNumber(f) => IEvNumber(f) + | FRValueDistOrNumber(FRValueNumber(n)) => IEvNumber(n) + | FRValueDistOrNumber(FRValueDist(n)) => IEvDistribution(n) + | FRValueDist(dist) => IEvDistribution(dist) + | FRValueArray(elements) => IEvArray(elements->E.A2.fmap(matchReverse)) | FRValueRecord(frValueRecord) => { let map = frValueRecord ->E.A2.fmap(((name, value)) => (name, matchReverse(value))) ->Belt.Map.String.fromArray - IevRecord(map) + IEvRecord(map) } | FRValueDict(frValueRecord) => { let map = @@ -145,11 +145,11 @@ module FRType = { ->Js.Dict.entries ->E.A2.fmap(((name, value)) => (name, matchReverse(value))) ->Belt.Map.String.fromArray - IevRecord(map) + IEvRecord(map) } - | FRValueLambda(l) => IevLambda(l) - | FRValueString(string) => IevString(string) - | FRValueVariant(string) => IevString(string) + | FRValueLambda(l) => IEvLambda(l) + | FRValueString(string) => IEvString(string) + | FRValueVariant(string) => IEvString(string) | FRValueAny(f) => matchReverse(f) } diff --git a/packages/squiggle-lang/src/rescript/FunctionRegistry/FunctionRegistry_Helpers.res b/packages/squiggle-lang/src/rescript/FunctionRegistry/FunctionRegistry_Helpers.res index 6da4d819..46ae18f9 100644 --- a/packages/squiggle-lang/src/rescript/FunctionRegistry/FunctionRegistry_Helpers.res +++ b/packages/squiggle-lang/src/rescript/FunctionRegistry/FunctionRegistry_Helpers.res @@ -4,11 +4,11 @@ let impossibleError = "Wrong inputs / Logically impossible" module Wrappers = { let symbolic = r => DistributionTypes.Symbolic(r) - let evDistribution = r => ReducerInterface_InternalExpressionValue.IevDistribution(r) - let evNumber = r => ReducerInterface_InternalExpressionValue.IevNumber(r) - let evArray = r => ReducerInterface_InternalExpressionValue.IevArray(r) - let evRecord = r => ReducerInterface_InternalExpressionValue.IevRecord(r) - let evString = r => ReducerInterface_InternalExpressionValue.IevString(r) + let evDistribution = r => ReducerInterface_InternalExpressionValue.IEvDistribution(r) + let evNumber = r => ReducerInterface_InternalExpressionValue.IEvNumber(r) + let evArray = r => ReducerInterface_InternalExpressionValue.IEvArray(r) + let evRecord = r => ReducerInterface_InternalExpressionValue.IEvRecord(r) + let evString = r => ReducerInterface_InternalExpressionValue.IEvString(r) let symbolicEvDistribution = r => r->DistributionTypes.Symbolic->evDistribution } diff --git a/packages/squiggle-lang/src/rescript/FunctionRegistry/FunctionRegistry_Library.res b/packages/squiggle-lang/src/rescript/FunctionRegistry/FunctionRegistry_Library.res index 53c9fdde..68d06ae8 100644 --- a/packages/squiggle-lang/src/rescript/FunctionRegistry/FunctionRegistry_Library.res +++ b/packages/squiggle-lang/src/rescript/FunctionRegistry/FunctionRegistry_Library.res @@ -20,7 +20,7 @@ module Declaration = { inputs ->E.A2.fmap(getMinMax) ->E.A.R.firstErrorOrOpen - ->E.R2.fmap(args => ReducerInterface_InternalExpressionValue.IevDeclaration( + ->E.R2.fmap(args => ReducerInterface_InternalExpressionValue.IEvDeclaration( Declaration.make(lambda, args), )) } @@ -43,7 +43,7 @@ let inputsTodist = (inputs: array, makeDist) => { let expressionValue = xyCoords ->E.R.bind(r => r->XYShape.T.makeFromZipped->E.R2.errMap(XYShape.Error.toString)) - ->E.R2.fmap(r => ReducerInterface_InternalExpressionValue.IevDistribution( + ->E.R2.fmap(r => ReducerInterface_InternalExpressionValue.IEvDistribution( PointSet(makeDist(r)), )) expressionValue diff --git a/packages/squiggle-lang/src/rescript/Reducer/Reducer_Category/Reducer_Category_Module.res b/packages/squiggle-lang/src/rescript/Reducer/Reducer_Category/Reducer_Category_Module.res index b8056449..58174063 100644 --- a/packages/squiggle-lang/src/rescript/Reducer/Reducer_Category/Reducer_Category_Module.res +++ b/packages/squiggle-lang/src/rescript/Reducer/Reducer_Category/Reducer_Category_Module.res @@ -11,7 +11,7 @@ let getType = (nameSpace: t, id: string) => { let NameSpace(container) = nameSpace Belt.Map.String.get(container, typeAliasesKey)->Belt.Option.flatMap(aliases => switch aliases { - | IevRecord(r) => Belt.Map.String.get(r, id) + | IEvRecord(r) => Belt.Map.String.get(r, id) | _ => None } ) @@ -21,7 +21,7 @@ let getTypeOf = (nameSpace: t, id: string) => { let NameSpace(container) = nameSpace Belt.Map.String.get(container, typeReferencesKey)->Belt.Option.flatMap(defs => switch defs { - | IevRecord(r) => Belt.Map.String.get(r, id) + | IEvRecord(r) => Belt.Map.String.get(r, id) | _ => None } ) @@ -41,23 +41,23 @@ let emptyMap: map = Belt.Map.String.empty let setTypeAlias = (nameSpace: t, id: string, value): t => { let NameSpace(container) = nameSpace - let rValue = Belt.Map.String.getWithDefault(container, typeAliasesKey, IevRecord(emptyMap)) + let rValue = Belt.Map.String.getWithDefault(container, typeAliasesKey, IEvRecord(emptyMap)) let r = switch rValue { - | IevRecord(r) => r + | IEvRecord(r) => r | _ => emptyMap } - let r2 = Belt.Map.String.set(r, id, value)->IevRecord + let r2 = Belt.Map.String.set(r, id, value)->IEvRecord Belt.Map.String.set(container, typeAliasesKey, r2)->NameSpace } let setTypeOf = (nameSpace: t, id: string, value): t => { let NameSpace(container) = nameSpace - let rValue = Belt.Map.String.getWithDefault(container, typeReferencesKey, IevRecord(emptyMap)) + let rValue = Belt.Map.String.getWithDefault(container, typeReferencesKey, IEvRecord(emptyMap)) let r = switch rValue { - | IevRecord(r) => r + | IEvRecord(r) => r | _ => emptyMap } - let r2 = Belt.Map.String.set(r, id, value)->IevRecord + let r2 = Belt.Map.String.set(r, id, value)->IEvRecord Belt.Map.String.set(container, typeReferencesKey, r2)->NameSpace } @@ -71,10 +71,10 @@ let emptyModule: t = NameSpace(Belt.Map.String.empty) let fromTypeScriptBindings = ReducerInterface_InternalExpressionValue.nameSpaceFromTypeScriptBindings let toTypeScriptBindings = ReducerInterface_InternalExpressionValue.nameSpaceToTypeScriptBindings -let toExpressionValue = (nameSpace: t): expressionValue => IevModule(nameSpace) +let toExpressionValue = (nameSpace: t): expressionValue => IEvModule(nameSpace) let fromExpressionValue = (aValue: expressionValue): t => switch aValue { - | IevModule(nameSpace) => nameSpace + | IEvModule(nameSpace) => nameSpace | _ => emptyModule } @@ -106,7 +106,7 @@ let define = (nameSpace: t, identifier: string, ev: expressionValue): t => { Belt.Map.String.set(container, identifier, ev)->NameSpace // TODO build lambda for polymorphic functions here } let defineNumber = (nameSpace: t, identifier: string, value: float): t => - nameSpace->define(identifier, IevNumber(value)) + nameSpace->define(identifier, IEvNumber(value)) let defineModule = (nameSpace: t, identifier: string, value: t): t => nameSpace->define(identifier, toExpressionValue(value)) diff --git a/packages/squiggle-lang/src/rescript/Reducer/Reducer_Category/Reducer_Category_Module_TypeChecker.res b/packages/squiggle-lang/src/rescript/Reducer/Reducer_Category/Reducer_Category_Module_TypeChecker.res index 61dbfbb8..fb5d2ef3 100644 --- a/packages/squiggle-lang/src/rescript/Reducer/Reducer_Category/Reducer_Category_Module_TypeChecker.res +++ b/packages/squiggle-lang/src/rescript/Reducer/Reducer_Category/Reducer_Category_Module_TypeChecker.res @@ -10,7 +10,7 @@ let isOfResolvedType = (aType, aValue) => { } switch aType { - | IevTypeIdentifier(aTypeIdentifier) => caseTypeIdentifier(aTypeIdentifier, aValue) + | IEvTypeIdentifier(aTypeIdentifier) => caseTypeIdentifier(aTypeIdentifier, aValue) | _ => false } } diff --git a/packages/squiggle-lang/src/rescript/Reducer/Reducer_Dispatch/Reducer_Dispatch_BuiltIn.res b/packages/squiggle-lang/src/rescript/Reducer/Reducer_Dispatch/Reducer_Dispatch_BuiltIn.res index 847c290a..f1664319 100644 --- a/packages/squiggle-lang/src/rescript/Reducer/Reducer_Dispatch/Reducer_Dispatch_BuiltIn.res +++ b/packages/squiggle-lang/src/rescript/Reducer/Reducer_Dispatch/Reducer_Dispatch_BuiltIn.res @@ -32,12 +32,12 @@ let callInternal = (call: functionCall, environment, reducer: ExpressionT.reduce let constructRecord = arrayOfPairs => { Belt.Array.map(arrayOfPairs, pairValue => switch pairValue { - | IevArray([IevString(key), valueValue]) => (key, valueValue) - | _ => ("wrong key type", pairValue->toStringWithType->IevString) + | IEvArray([IEvString(key), valueValue]) => (key, valueValue) + | _ => ("wrong key type", pairValue->toStringWithType->IEvString) } ) ->Belt.Map.String.fromArray - ->IevRecord + ->IEvRecord ->Ok } @@ -62,11 +62,11 @@ let callInternal = (call: functionCall, environment, reducer: ExpressionT.reduce let doAddArray = (originalA, b) => { let a = originalA->Js.Array2.copy let _ = Js.Array2.pushMany(a, b) - a->IevArray->Ok + a->IEvArray->Ok } let doAddString = (a, b) => { let answer = Js.String2.concat(a, b) - answer->IevString->Ok + answer->IEvString->Ok } let inspect = (value: expressionValue) => { @@ -80,14 +80,14 @@ let callInternal = (call: functionCall, environment, reducer: ExpressionT.reduce } let doSetBindings = (bindings: nameSpace, symbol: string, value: expressionValue) => { - Module.set(bindings, symbol, value)->IevModule->Ok + Module.set(bindings, symbol, value)->IEvModule->Ok } let doSetTypeAliasBindings = (bindings: nameSpace, symbol: string, value: expressionValue) => - Module.setTypeAlias(bindings, symbol, value)->IevModule->Ok + Module.setTypeAlias(bindings, symbol, value)->IEvModule->Ok let doSetTypeOfBindings = (bindings: nameSpace, symbol: string, value: expressionValue) => - Module.setTypeOf(bindings, symbol, value)->IevModule->Ok + Module.setTypeOf(bindings, symbol, value)->IEvModule->Ok let doExportBindings = (bindings: nameSpace) => bindings->Module.toExpressionValue->Ok @@ -97,13 +97,13 @@ let callInternal = (call: functionCall, environment, reducer: ExpressionT.reduce let rNewElem = Lambda.doLambdaCall(aLambdaValue, list{elem}, environment, reducer) rNewElem->Result.map(newElem => switch newElem { - | IevBool(true) => list{elem, ...acc} + | IEvBool(true) => list{elem, ...acc} | _ => acc } ) }) ) - rMappedList->Result.map(mappedList => mappedList->Belt.List.toArray->IevArray) + rMappedList->Result.map(mappedList => mappedList->Belt.List.toArray->IEvArray) } let doMapArray = (aValueArray, aLambdaValue) => { @@ -113,36 +113,36 @@ let callInternal = (call: functionCall, environment, reducer: ExpressionT.reduce rNewElem->Result.map(newElem => list{newElem, ...acc}) }) ) - rMappedList->Result.map(mappedList => mappedList->Belt.List.toArray->IevArray) + rMappedList->Result.map(mappedList => mappedList->Belt.List.toArray->IEvArray) } module SampleMap = { type t = SampleSetDist.t let doLambdaCall = (aLambdaValue, list) => switch Lambda.doLambdaCall(aLambdaValue, list, environment, reducer) { - | Ok(IevNumber(f)) => Ok(f) + | Ok(IEvNumber(f)) => Ok(f) | _ => Error(Operation.SampleMapNeedsNtoNFunction) } let toType = r => switch r { - | Ok(r) => Ok(IevDistribution(SampleSet(r))) + | Ok(r) => Ok(IEvDistribution(SampleSet(r))) | Error(r) => Error(REDistributionError(SampleSetError(r))) } let map1 = (sampleSetDist: t, aLambdaValue) => { - let fn = r => doLambdaCall(aLambdaValue, list{IevNumber(r)}) + let fn = r => doLambdaCall(aLambdaValue, list{IEvNumber(r)}) toType(SampleSetDist.samplesMap(~fn, sampleSetDist)) } let map2 = (t1: t, t2: t, aLambdaValue) => { - let fn = (a, b) => doLambdaCall(aLambdaValue, list{IevNumber(a), IevNumber(b)}) + let fn = (a, b) => doLambdaCall(aLambdaValue, list{IEvNumber(a), IEvNumber(b)}) SampleSetDist.map2(~fn, ~t1, ~t2)->toType } let map3 = (t1: t, t2: t, t3: t, aLambdaValue) => { let fn = (a, b, c) => - doLambdaCall(aLambdaValue, list{IevNumber(a), IevNumber(b), IevNumber(c)}) + doLambdaCall(aLambdaValue, list{IEvNumber(a), IEvNumber(b), IEvNumber(c)}) SampleSetDist.map3(~fn, ~t1, ~t2, ~t3)->toType } } @@ -165,127 +165,127 @@ let callInternal = (call: functionCall, environment, reducer: ExpressionT.reduce let typeModifier_memberOf = (aType, anArray) => { let newRecord = Belt.Map.String.fromArray([ - ("typeTag", IevString("typeIdentifier")), + ("typeTag", IEvString("typeIdentifier")), ("typeIdentifier", aType), ]) - newRecord->Belt.Map.String.set("memberOf", anArray)->IevRecord->Ok + newRecord->Belt.Map.String.set("memberOf", anArray)->IEvRecord->Ok } let typeModifier_memberOf_update = (aRecord, anArray) => { - aRecord->Belt.Map.String.set("memberOf", anArray)->IevRecord->Ok + aRecord->Belt.Map.String.set("memberOf", anArray)->IEvRecord->Ok } let typeModifier_min = (aType, value) => { let newRecord = Belt.Map.String.fromArray([ - ("typeTag", IevString("typeIdentifier")), + ("typeTag", IEvString("typeIdentifier")), ("typeIdentifier", aType), ]) - newRecord->Belt.Map.String.set("min", value)->IevRecord->Ok + newRecord->Belt.Map.String.set("min", value)->IEvRecord->Ok } let typeModifier_min_update = (aRecord, value) => { - aRecord->Belt.Map.String.set("min", value)->IevRecord->Ok + aRecord->Belt.Map.String.set("min", value)->IEvRecord->Ok } let typeModifier_max = (aType, value) => { let newRecord = Belt.Map.String.fromArray([ - ("typeTag", IevString("typeIdentifier")), + ("typeTag", IEvString("typeIdentifier")), ("typeIdentifier", aType), ]) - newRecord->Belt.Map.String.set("max", value)->IevRecord->Ok + newRecord->Belt.Map.String.set("max", value)->IEvRecord->Ok } let typeModifier_max_update = (aRecord, value) => - aRecord->Belt.Map.String.set("max", value)->IevRecord->Ok + aRecord->Belt.Map.String.set("max", value)->IEvRecord->Ok let typeModifier_opaque_update = aRecord => - aRecord->Belt.Map.String.set("opaque", IevBool(true))->IevRecord->Ok + aRecord->Belt.Map.String.set("opaque", IEvBool(true))->IEvRecord->Ok let typeOr = evArray => { let newRecord = Belt.Map.String.fromArray([ - ("typeTag", IevString("typeOr")), + ("typeTag", IEvString("typeOr")), ("typeOr", evArray), ]) - newRecord->IevRecord->Ok + newRecord->IEvRecord->Ok } let typeFunction = anArray => { let output = Belt.Array.getUnsafe(anArray, Js.Array2.length(anArray) - 1) let inputs = Js.Array2.slice(anArray, ~start=0, ~end_=-1) let newRecord = Belt.Map.String.fromArray([ - ("typeTag", IevString("typeFunction")), - ("inputs", IevArray(inputs)), + ("typeTag", IEvString("typeFunction")), + ("inputs", IEvArray(inputs)), ("output", output), ]) - newRecord->IevRecord->Ok + newRecord->IEvRecord->Ok } switch call { - | ("$_atIndex_$", [IevArray(aValueArray), IevNumber(fIndex)]) => arrayAtIndex(aValueArray, fIndex) - | ("$_atIndex_$", [IevModule(dict), IevString(sIndex)]) => moduleAtIndex(dict, sIndex) - | ("$_atIndex_$", [IevRecord(dict), IevString(sIndex)]) => recordAtIndex(dict, sIndex) - | ("$_constructArray_$", [IevArray(aValueArray)]) => IevArray(aValueArray)->Ok - | ("$_constructRecord_$", [IevArray(arrayOfPairs)]) => constructRecord(arrayOfPairs) - | ("$_exportBindings_$", [IevModule(nameSpace)]) => doExportBindings(nameSpace) - | ("$_setBindings_$", [IevModule(nameSpace), IevSymbol(symbol), value]) => + | ("$_atIndex_$", [IEvArray(aValueArray), IEvNumber(fIndex)]) => arrayAtIndex(aValueArray, fIndex) + | ("$_atIndex_$", [IEvModule(dict), IEvString(sIndex)]) => moduleAtIndex(dict, sIndex) + | ("$_atIndex_$", [IEvRecord(dict), IEvString(sIndex)]) => recordAtIndex(dict, sIndex) + | ("$_constructArray_$", [IEvArray(aValueArray)]) => IEvArray(aValueArray)->Ok + | ("$_constructRecord_$", [IEvArray(arrayOfPairs)]) => constructRecord(arrayOfPairs) + | ("$_exportBindings_$", [IEvModule(nameSpace)]) => doExportBindings(nameSpace) + | ("$_setBindings_$", [IEvModule(nameSpace), IEvSymbol(symbol), value]) => doSetBindings(nameSpace, symbol, value) - | ("$_setTypeAliasBindings_$", [IevModule(nameSpace), IevTypeIdentifier(symbol), value]) => + | ("$_setTypeAliasBindings_$", [IEvModule(nameSpace), IEvTypeIdentifier(symbol), value]) => doSetTypeAliasBindings(nameSpace, symbol, value) - | ("$_setTypeOfBindings_$", [IevModule(nameSpace), IevSymbol(symbol), value]) => + | ("$_setTypeOfBindings_$", [IEvModule(nameSpace), IEvSymbol(symbol), value]) => doSetTypeOfBindings(nameSpace, symbol, value) - | ("$_typeModifier_memberOf_$", [IevTypeIdentifier(typeIdentifier), IevArray(arr)]) => - typeModifier_memberOf(IevTypeIdentifier(typeIdentifier), IevArray(arr)) - | ("$_typeModifier_memberOf_$", [IevRecord(typeRecord), IevArray(arr)]) => - typeModifier_memberOf_update(typeRecord, IevArray(arr)) - | ("$_typeModifier_min_$", [IevTypeIdentifier(typeIdentifier), value]) => - typeModifier_min(IevTypeIdentifier(typeIdentifier), value) - | ("$_typeModifier_min_$", [IevRecord(typeRecord), value]) => + | ("$_typeModifier_memberOf_$", [IEvTypeIdentifier(typeIdentifier), IEvArray(arr)]) => + typeModifier_memberOf(IEvTypeIdentifier(typeIdentifier), IEvArray(arr)) + | ("$_typeModifier_memberOf_$", [IEvRecord(typeRecord), IEvArray(arr)]) => + typeModifier_memberOf_update(typeRecord, IEvArray(arr)) + | ("$_typeModifier_min_$", [IEvTypeIdentifier(typeIdentifier), value]) => + typeModifier_min(IEvTypeIdentifier(typeIdentifier), value) + | ("$_typeModifier_min_$", [IEvRecord(typeRecord), value]) => typeModifier_min_update(typeRecord, value) - | ("$_typeModifier_max_$", [IevTypeIdentifier(typeIdentifier), value]) => - typeModifier_max(IevTypeIdentifier(typeIdentifier), value) - | ("$_typeModifier_max_$", [IevRecord(typeRecord), value]) => + | ("$_typeModifier_max_$", [IEvTypeIdentifier(typeIdentifier), value]) => + typeModifier_max(IEvTypeIdentifier(typeIdentifier), value) + | ("$_typeModifier_max_$", [IEvRecord(typeRecord), value]) => typeModifier_max_update(typeRecord, value) - | ("$_typeModifier_opaque_$", [IevRecord(typeRecord)]) => typeModifier_opaque_update(typeRecord) - | ("$_typeOr_$", [IevArray(arr)]) => typeOr(IevArray(arr)) - | ("$_typeFunction_$", [IevArray(arr)]) => typeFunction(arr) - | ("concat", [IevArray(aValueArray), IevArray(bValueArray)]) => + | ("$_typeModifier_opaque_$", [IEvRecord(typeRecord)]) => typeModifier_opaque_update(typeRecord) + | ("$_typeOr_$", [IEvArray(arr)]) => typeOr(IEvArray(arr)) + | ("$_typeFunction_$", [IEvArray(arr)]) => typeFunction(arr) + | ("concat", [IEvArray(aValueArray), IEvArray(bValueArray)]) => doAddArray(aValueArray, bValueArray) - | ("concat", [IevString(aValueString), IevString(bValueString)]) => + | ("concat", [IEvString(aValueString), IEvString(bValueString)]) => doAddString(aValueString, bValueString) - | ("inspect", [value, IevString(label)]) => inspectLabel(value, label) + | ("inspect", [value, IEvString(label)]) => inspectLabel(value, label) | ("inspect", [value]) => inspect(value) - | ("filter", [IevArray(aValueArray), IevLambda(aLambdaValue)]) => + | ("filter", [IEvArray(aValueArray), IEvLambda(aLambdaValue)]) => doKeepArray(aValueArray, aLambdaValue) - | ("map", [IevArray(aValueArray), IevLambda(aLambdaValue)]) => + | ("map", [IEvArray(aValueArray), IEvLambda(aLambdaValue)]) => doMapArray(aValueArray, aLambdaValue) - | ("mapSamples", [IevDistribution(SampleSet(dist)), IevLambda(aLambdaValue)]) => + | ("mapSamples", [IEvDistribution(SampleSet(dist)), IEvLambda(aLambdaValue)]) => SampleMap.map1(dist, aLambdaValue) | ( "mapSamples2", [ - IevDistribution(SampleSet(dist1)), - IevDistribution(SampleSet(dist2)), - IevLambda(aLambdaValue), + IEvDistribution(SampleSet(dist1)), + IEvDistribution(SampleSet(dist2)), + IEvLambda(aLambdaValue), ], ) => SampleMap.map2(dist1, dist2, aLambdaValue) | ( "mapSamples3", [ - IevDistribution(SampleSet(dist1)), - IevDistribution(SampleSet(dist2)), - IevDistribution(SampleSet(dist3)), - IevLambda(aLambdaValue), + IEvDistribution(SampleSet(dist1)), + IEvDistribution(SampleSet(dist2)), + IEvDistribution(SampleSet(dist3)), + IEvLambda(aLambdaValue), ], ) => SampleMap.map3(dist1, dist2, dist3, aLambdaValue) - | ("reduce", [IevArray(aValueArray), initialValue, IevLambda(aLambdaValue)]) => + | ("reduce", [IEvArray(aValueArray), initialValue, IEvLambda(aLambdaValue)]) => doReduceArray(aValueArray, initialValue, aLambdaValue) - | ("reduceReverse", [IevArray(aValueArray), initialValue, IevLambda(aLambdaValue)]) => + | ("reduceReverse", [IEvArray(aValueArray), initialValue, IEvLambda(aLambdaValue)]) => doReduceReverseArray(aValueArray, initialValue, aLambdaValue) - | ("reverse", [IevArray(aValueArray)]) => aValueArray->Belt.Array.reverse->IevArray->Ok - | (_, [IevBool(_)]) - | (_, [IevNumber(_)]) - | (_, [IevString(_)]) - | (_, [IevBool(_), IevBool(_)]) - | (_, [IevNumber(_), IevNumber(_)]) - | (_, [IevString(_), IevString(_)]) => + | ("reverse", [IEvArray(aValueArray)]) => aValueArray->Belt.Array.reverse->IEvArray->Ok + | (_, [IEvBool(_)]) + | (_, [IEvNumber(_)]) + | (_, [IEvString(_)]) + | (_, [IEvBool(_), IEvBool(_)]) + | (_, [IEvNumber(_), IEvNumber(_)]) + | (_, [IEvString(_), IEvString(_)]) => callMathJs(call) | call => Error(REFunctionNotFound(call->functionCallToCallSignature->functionCallSignatureToString)) // Report full type signature as error diff --git a/packages/squiggle-lang/src/rescript/Reducer/Reducer_Dispatch/Reducer_Dispatch_BuiltInMacros.res b/packages/squiggle-lang/src/rescript/Reducer/Reducer_Dispatch/Reducer_Dispatch_BuiltInMacros.res index 1a91b28c..0431457e 100644 --- a/packages/squiggle-lang/src/rescript/Reducer/Reducer_Dispatch/Reducer_Dispatch_BuiltInMacros.res +++ b/packages/squiggle-lang/src/rescript/Reducer/Reducer_Dispatch/Reducer_Dispatch_BuiltInMacros.res @@ -52,7 +52,7 @@ let dispatchMacroCall = ( let doBindStatement = (bindingExpr: expression, statement: expression, environment) => { let defaultStatement = ErrorValue.REAssignmentExpected->Error switch statement { - | ExpressionT.EList(list{ExpressionT.EValue(IevCall(callName)), symbolExpr, statement}) => { + | ExpressionT.EList(list{ExpressionT.EValue(IEvCall(callName)), symbolExpr, statement}) => { let setBindingsFn = correspondingSetBindingsFn(callName) if setBindingsFn !== "" { useExpressionToSetBindings(bindingExpr, environment, statement, ( @@ -78,7 +78,7 @@ let dispatchMacroCall = ( ) => boundStatement) switch statement { - | ExpressionT.EList(list{ExpressionT.EValue(IevCall(callName)), symbolExpr, statement}) => { + | ExpressionT.EList(list{ExpressionT.EValue(IEvCall(callName)), symbolExpr, statement}) => { let setBindingsFn = correspondingSetBindingsFn(callName) if setBindingsFn !== "" { useExpressionToSetBindings(bindingExpr, environment, statement, ( @@ -137,11 +137,11 @@ let dispatchMacroCall = ( let rCondition = reduceExpression(blockCondition, bindings, environment) rCondition->Result.flatMap(conditionValue => switch conditionValue { - | ExpressionValue.IevBool(false) => { + | ExpressionValue.IEvBool(false) => { let ifFalseBlock = eBlock(list{ifFalse}) ExpressionWithContext.withContext(ifFalseBlock, bindings)->Ok } - | ExpressionValue.IevBool(true) => { + | ExpressionValue.IEvBool(true) => { let ifTrueBlock = eBlock(list{ifTrue}) ExpressionWithContext.withContext(ifTrueBlock, bindings)->Ok } @@ -156,32 +156,32 @@ let dispatchMacroCall = ( > => switch aList { | list{ - ExpressionT.EValue(IevCall("$$_bindStatement_$$")), + ExpressionT.EValue(IEvCall("$$_bindStatement_$$")), bindingExpr: ExpressionT.expression, statement, } => doBindStatement(bindingExpr, statement, environment) - | list{ExpressionT.EValue(IevCall("$$_bindStatement_$$")), statement} => + | list{ExpressionT.EValue(IEvCall("$$_bindStatement_$$")), statement} => // bindings of the context are used when there is no binding expression doBindStatement(eModule(bindings), statement, environment) | list{ - ExpressionT.EValue(IevCall("$$_bindExpression_$$")), + ExpressionT.EValue(IEvCall("$$_bindExpression_$$")), bindingExpr: ExpressionT.expression, expression, } => doBindExpression(bindingExpr, expression, environment) - | list{ExpressionT.EValue(IevCall("$$_bindExpression_$$")), expression} => + | list{ExpressionT.EValue(IEvCall("$$_bindExpression_$$")), expression} => // bindings of the context are used when there is no binding expression doBindExpression(eModule(bindings), expression, environment) - | list{ExpressionT.EValue(IevCall("$$_block_$$")), ...exprs} => + | list{ExpressionT.EValue(IEvCall("$$_block_$$")), ...exprs} => doBlock(exprs, bindings, environment) | list{ - ExpressionT.EValue(IevCall("$$_lambda_$$")), - ExpressionT.EValue(IevArrayString(parameters)), + ExpressionT.EValue(IEvCall("$$_lambda_$$")), + ExpressionT.EValue(IEvArrayString(parameters)), lambdaDefinition, } => doLambdaDefinition(bindings, parameters, lambdaDefinition) - | list{ExpressionT.EValue(IevCall("$$_ternary_$$")), condition, ifTrue, ifFalse} => + | list{ExpressionT.EValue(IEvCall("$$_ternary_$$")), condition, ifTrue, ifFalse} => doTernary(condition, ifTrue, ifFalse, bindings, environment) | _ => ExpressionWithContext.noContext(ExpressionT.EList(aList))->Ok } diff --git a/packages/squiggle-lang/src/rescript/Reducer/Reducer_Expression/Reducer_Expression.res b/packages/squiggle-lang/src/rescript/Reducer/Reducer_Expression/Reducer_Expression.res index 28a2d538..99c8cdbb 100644 --- a/packages/squiggle-lang/src/rescript/Reducer/Reducer_Expression/Reducer_Expression.res +++ b/packages/squiggle-lang/src/rescript/Reducer/Reducer_Expression/Reducer_Expression.res @@ -36,7 +36,7 @@ let rec reduceExpression = (expression: t, bindings: T.bindings, environment: en | T.EValue(value) => value->Ok | T.EList(list) => switch list { - | list{EValue(IevCall(fName)), ..._args} => + | list{EValue(IEvCall(fName)), ..._args} => switch Macro.isMacroName(fName) { // A macro expands then reduces itself | true => Macro.doMacroCall(expression, bindings, environment, reduceExpression) @@ -75,7 +75,7 @@ and reduceValueList = (valueList: list, environment): result< 'e, > => switch valueList { - | list{IevCall(fName), ...args} => { + | list{IEvCall(fName), ...args} => { let rCheckedArgs = switch fName { | "$_setBindings_$" | "$_setTypeOfBindings_$" | "$_setTypeAliasBindings_$" => args->Ok | _ => args->Lambda.checkIfReduced @@ -85,14 +85,14 @@ and reduceValueList = (valueList: list, environment): result< (fName, checkedArgs->Belt.List.toArray)->BuiltIn.dispatch(environment, reduceExpression) ) } - | list{IevLambda(_)} => + | list{IEvLambda(_)} => // TODO: remove on solving issue#558 valueList ->Lambda.checkIfReduced ->Result.flatMap(reducedValueList => - reducedValueList->Belt.List.toArray->InternalExpressionValue.IevArray->Ok + reducedValueList->Belt.List.toArray->InternalExpressionValue.IEvArray->Ok ) - | list{IevLambda(lamdaCall), ...args} => + | list{IEvLambda(lamdaCall), ...args} => args ->Lambda.checkIfReduced ->Result.flatMap(checkedArgs => @@ -103,7 +103,7 @@ and reduceValueList = (valueList: list, environment): result< valueList ->Lambda.checkIfReduced ->Result.flatMap(reducedValueList => - reducedValueList->Belt.List.toArray->InternalExpressionValue.IevArray->Ok + reducedValueList->Belt.List.toArray->InternalExpressionValue.IEvArray->Ok ) } @@ -135,7 +135,7 @@ let evaluateUsingOptions = ( } /* - Ievaluates Squiggle code and bindings via Reducer and answers the result + IEvaluates Squiggle code and bindings via Reducer and answers the result */ let evaluate = (code: string): result => { evaluateUsingOptions(~environment=None, ~externalBindings=None, code) diff --git a/packages/squiggle-lang/src/rescript/Reducer/Reducer_Expression/Reducer_Expression_BindingsReplacer.res b/packages/squiggle-lang/src/rescript/Reducer/Reducer_Expression/Reducer_Expression_BindingsReplacer.res index 1a1350c3..43109f0d 100644 --- a/packages/squiggle-lang/src/rescript/Reducer/Reducer_Expression/Reducer_Expression_BindingsReplacer.res +++ b/packages/squiggle-lang/src/rescript/Reducer/Reducer_Expression/Reducer_Expression_BindingsReplacer.res @@ -21,7 +21,7 @@ let rec replaceSymbols = (bindings: ExpressionT.bindings, expression: expression replaceSymbolOnValue(bindings, value)->Result.map(evValue => evValue->ExpressionT.EValue) | ExpressionT.EList(list) => switch list { - | list{EValue(IevCall(fName)), ..._args} => + | list{EValue(IEvCall(fName)), ..._args} => switch isMacroName(fName) { // A macro reduces itself so we dont dive in it | true => expression->Ok @@ -43,12 +43,12 @@ and replaceSymbolsOnExpressionList = (bindings, list) => { } and replaceSymbolOnValue = (bindings, evValue: expressionValue) => switch evValue { - | IevSymbol(symbol) => Module.getWithDefault(bindings, symbol, evValue)->Ok - | IevCall(symbol) => Module.getWithDefault(bindings, symbol, evValue)->checkIfCallable + | IEvSymbol(symbol) => Module.getWithDefault(bindings, symbol, evValue)->Ok + | IEvCall(symbol) => Module.getWithDefault(bindings, symbol, evValue)->checkIfCallable | _ => evValue->Ok } and checkIfCallable = (evValue: expressionValue) => switch evValue { - | IevCall(_) | IevLambda(_) => evValue->Ok + | IEvCall(_) | IEvLambda(_) => evValue->Ok | _ => ErrorValue.RENotAFunction(ExpressionValue.toString(evValue))->Error } diff --git a/packages/squiggle-lang/src/rescript/Reducer/Reducer_Expression/Reducer_Expression_ExpressionBuilder.res b/packages/squiggle-lang/src/rescript/Reducer/Reducer_Expression/Reducer_Expression_ExpressionBuilder.res index 0fda62db..04d5fb7b 100644 --- a/packages/squiggle-lang/src/rescript/Reducer/Reducer_Expression/Reducer_Expression_ExpressionBuilder.res +++ b/packages/squiggle-lang/src/rescript/Reducer/Reducer_Expression/Reducer_Expression_ExpressionBuilder.res @@ -12,16 +12,16 @@ type internalCode = ReducerInterface_InternalExpressionValue.internalCode external castExpressionToInternalCode: expressionOrFFI => internalCode = "%identity" -let eArray = anArray => anArray->BExpressionValue.IevArray->BExpressionT.EValue +let eArray = anArray => anArray->BExpressionValue.IEvArray->BExpressionT.EValue -let eArrayString = anArray => anArray->BExpressionValue.IevArrayString->BExpressionT.EValue +let eArrayString = anArray => anArray->BExpressionValue.IEvArrayString->BExpressionT.EValue let eBindings = (anArray: array<(string, BExpressionValue.expressionValue)>) => anArray->BModule.fromArray->BModule.toExpressionValue->BExpressionT.EValue -let eBool = aBool => aBool->BExpressionValue.IevBool->BExpressionT.EValue +let eBool = aBool => aBool->BExpressionValue.IEvBool->BExpressionT.EValue -let eCall = (name: string): expression => name->BExpressionValue.IevCall->BExpressionT.EValue +let eCall = (name: string): expression => name->BExpressionValue.IEvCall->BExpressionT.EValue let eFunction = (fName: string, lispArgs: list): expression => { let fn = fName->eCall @@ -33,7 +33,7 @@ let eLambda = ( context: BExpressionValue.nameSpace, expr: expression, ) => { - BExpressionValue.IevLambda({ + BExpressionValue.IEvLambda({ parameters: parameters, context: context, body: NotFFI(expr)->castExpressionToInternalCode, @@ -42,27 +42,27 @@ let eLambda = ( let eLambdaFFI = (parameters: array, ffiFn: ffiFn) => { let context = BModule.emptyModule - BExpressionValue.IevLambda({ + BExpressionValue.IEvLambda({ parameters: parameters, context: context, body: FFI(ffiFn)->castExpressionToInternalCode, })->BExpressionT.EValue } -let eNumber = aNumber => aNumber->BExpressionValue.IevNumber->BExpressionT.EValue +let eNumber = aNumber => aNumber->BExpressionValue.IEvNumber->BExpressionT.EValue -let eRecord = aMap => aMap->BExpressionValue.IevRecord->BExpressionT.EValue +let eRecord = aMap => aMap->BExpressionValue.IEvRecord->BExpressionT.EValue -let eString = aString => aString->BExpressionValue.IevString->BExpressionT.EValue +let eString = aString => aString->BExpressionValue.IEvString->BExpressionT.EValue -let eSymbol = (name: string): expression => name->BExpressionValue.IevSymbol->BExpressionT.EValue +let eSymbol = (name: string): expression => name->BExpressionValue.IEvSymbol->BExpressionT.EValue let eList = (list: list): expression => list->BExpressionT.EList let eBlock = (exprs: list): expression => eFunction("$$_block_$$", exprs) let eModule = (nameSpace: BExpressionValue.nameSpace): expression => - nameSpace->BExpressionValue.IevModule->BExpressionT.EValue + nameSpace->BExpressionValue.IEvModule->BExpressionT.EValue let eLetStatement = (symbol: string, valueExpression: expression): expression => eFunction("$_let_$", list{eSymbol(symbol), valueExpression}) @@ -80,7 +80,7 @@ let eBindExpressionDefault = (expression: expression): expression => eFunction("$$_bindExpression_$$", list{expression}) let eIdentifier = (name: string): expression => - name->BExpressionValue.IevSymbol->BExpressionT.EValue + name->BExpressionValue.IEvSymbol->BExpressionT.EValue let eTypeIdentifier = (name: string): expression => - name->BExpressionValue.IevTypeIdentifier->BExpressionT.EValue + name->BExpressionValue.IEvTypeIdentifier->BExpressionT.EValue diff --git a/packages/squiggle-lang/src/rescript/Reducer/Reducer_Expression/Reducer_Expression_Lambda.res b/packages/squiggle-lang/src/rescript/Reducer/Reducer_Expression/Reducer_Expression_Lambda.res index 7376c392..6026a6d1 100644 --- a/packages/squiggle-lang/src/rescript/Reducer/Reducer_Expression/Reducer_Expression_Lambda.res +++ b/packages/squiggle-lang/src/rescript/Reducer/Reducer_Expression/Reducer_Expression_Lambda.res @@ -29,7 +29,7 @@ let checkIfReduced = (args: list) => args->Belt.List.reduceReverse(Ok(list{}), (rAcc, arg) => rAcc->Result.flatMap(acc => switch arg { - | IevSymbol(symbol) => ErrorValue.RESymbolNotFound(symbol)->Error + | IEvSymbol(symbol) => ErrorValue.RESymbolNotFound(symbol)->Error | _ => list{arg, ...acc}->Ok } ) diff --git a/packages/squiggle-lang/src/rescript/Reducer/Reducer_Expression/Reducer_Expression_T.res b/packages/squiggle-lang/src/rescript/Reducer/Reducer_Expression/Reducer_Expression_T.res index efc6e639..3af9a4f7 100644 --- a/packages/squiggle-lang/src/rescript/Reducer/Reducer_Expression/Reducer_Expression_T.res +++ b/packages/squiggle-lang/src/rescript/Reducer/Reducer_Expression/Reducer_Expression_T.res @@ -28,7 +28,7 @@ type reducerFn = ( */ let rec toString = expression => switch expression { - | EList(list{EValue(IevCall("$$_block_$$")), ...statements}) => + | EList(list{EValue(IEvCall("$$_block_$$")), ...statements}) => `{${Belt.List.map(statements, aValue => toString(aValue)) ->Extra.List.interperse("; ") ->Belt.List.toArray diff --git a/packages/squiggle-lang/src/rescript/Reducer/Reducer_Js/Reducer_Js_Gate.res b/packages/squiggle-lang/src/rescript/Reducer/Reducer_Js/Reducer_Js_Gate.res index b1e8c4b3..e13255e5 100644 --- a/packages/squiggle-lang/src/rescript/Reducer/Reducer_Js/Reducer_Js_Gate.res +++ b/packages/squiggle-lang/src/rescript/Reducer/Reducer_Js/Reducer_Js_Gate.res @@ -8,10 +8,10 @@ external castString: unit => string = "%identity" /* As JavaScript returns us any type, we need to type check and cast type propertype before using it */ -let jsToIev = (jsValue): result => +let jsToIEv = (jsValue): result => switch Js.typeof(jsValue) { - | "boolean" => jsValue->castBool->IevBool->Ok - | "number" => jsValue->castNumber->IevNumber->Ok - | "string" => jsValue->castString->IevString->Ok + | "boolean" => jsValue->castBool->IEvBool->Ok + | "number" => jsValue->castNumber->IEvNumber->Ok + | "string" => jsValue->castString->IEvString->Ok | other => RETodo(`Unhandled MathJs literal type: ${Js.String.make(other)}`)->Error } diff --git a/packages/squiggle-lang/src/rescript/Reducer/Reducer_MathJs/Reducer_MathJs_Eval.res b/packages/squiggle-lang/src/rescript/Reducer/Reducer_MathJs/Reducer_MathJs_Eval.res index 1fe54e86..6c8bc8e7 100644 --- a/packages/squiggle-lang/src/rescript/Reducer/Reducer_MathJs/Reducer_MathJs_Eval.res +++ b/packages/squiggle-lang/src/rescript/Reducer/Reducer_MathJs/Reducer_MathJs_Eval.res @@ -20,7 +20,7 @@ let eval__: string => 'a = %raw(`function (expr) { return {value: Mathjs.evaluat let eval = (expr: string): result => { try { let answer = eval__(expr) - answer["value"]->JavaScript.Gate.jsToIev + answer["value"]->JavaScript.Gate.jsToIEv } catch { | Js.Exn.Error(obj) => REJavaScriptExn(Js.Exn.message(obj), Js.Exn.name(obj))->Error } diff --git a/packages/squiggle-lang/src/rescript/ReducerInterface/ReducerInterface_Date.res b/packages/squiggle-lang/src/rescript/ReducerInterface/ReducerInterface_Date.res index fcb207d2..3d5d095d 100644 --- a/packages/squiggle-lang/src/rescript/ReducerInterface/ReducerInterface_Date.res +++ b/packages/squiggle-lang/src/rescript/ReducerInterface/ReducerInterface_Date.res @@ -5,23 +5,23 @@ let dispatch = (call: EV.functionCall, _: DistributionOperation.env): option< result, > => { switch call { - | ("toString", [IevDate(t)]) => EV.IevString(DateTime.Date.toString(t))->Ok->Some - | ("makeDateFromYear", [IevNumber(year)]) => + | ("toString", [IEvDate(t)]) => EV.IEvString(DateTime.Date.toString(t))->Ok->Some + | ("makeDateFromYear", [IEvNumber(year)]) => switch DateTime.Date.makeFromYear(year) { - | Ok(t) => EV.IevDate(t)->Ok->Some + | Ok(t) => EV.IEvDate(t)->Ok->Some | Error(e) => Reducer_ErrorValue.RETodo(e)->Error->Some } - | ("dateFromNumber", [IevNumber(f)]) => EV.IevDate(DateTime.Date.fromFloat(f))->Ok->Some - | ("toNumber", [IevDate(f)]) => EV.IevNumber(DateTime.Date.toFloat(f))->Ok->Some - | ("subtract", [IevDate(d1), IevDate(d2)]) => + | ("dateFromNumber", [IEvNumber(f)]) => EV.IEvDate(DateTime.Date.fromFloat(f))->Ok->Some + | ("toNumber", [IEvDate(f)]) => EV.IEvNumber(DateTime.Date.toFloat(f))->Ok->Some + | ("subtract", [IEvDate(d1), IEvDate(d2)]) => switch DateTime.Date.subtract(d1, d2) { - | Ok(d) => EV.IevTimeDuration(d)->Ok + | Ok(d) => EV.IEvTimeDuration(d)->Ok | Error(e) => Error(RETodo(e)) }->Some - | ("subtract", [IevDate(d1), IevTimeDuration(d2)]) => - EV.IevDate(DateTime.Date.subtractDuration(d1, d2))->Ok->Some - | ("add", [IevDate(d1), IevTimeDuration(d2)]) => - EV.IevDate(DateTime.Date.addDuration(d1, d2))->Ok->Some + | ("subtract", [IEvDate(d1), IEvTimeDuration(d2)]) => + EV.IEvDate(DateTime.Date.subtractDuration(d1, d2))->Ok->Some + | ("add", [IEvDate(d1), IEvTimeDuration(d2)]) => + EV.IEvDate(DateTime.Date.addDuration(d1, d2))->Ok->Some | _ => None } } diff --git a/packages/squiggle-lang/src/rescript/ReducerInterface/ReducerInterface_Duration.res b/packages/squiggle-lang/src/rescript/ReducerInterface/ReducerInterface_Duration.res index bff0a693..f0b31ae2 100644 --- a/packages/squiggle-lang/src/rescript/ReducerInterface/ReducerInterface_Duration.res +++ b/packages/squiggle-lang/src/rescript/ReducerInterface/ReducerInterface_Duration.res @@ -5,31 +5,31 @@ let dispatch = (call: EV.functionCall, _: DistributionOperation.env): option< result, > => { switch call { - | ("toString", [IevTimeDuration(t)]) => EV.IevString(DateTime.Duration.toString(t))->Ok->Some - | ("minutes", [IevNumber(f)]) => EV.IevTimeDuration(DateTime.Duration.fromMinutes(f))->Ok->Some - | ("fromUnit_minutes", [IevNumber(f)]) => - EV.IevTimeDuration(DateTime.Duration.fromMinutes(f))->Ok->Some - | ("hours", [IevNumber(f)]) => EV.IevTimeDuration(DateTime.Duration.fromHours(f))->Ok->Some - | ("fromUnit_hours", [IevNumber(f)]) => - EV.IevTimeDuration(DateTime.Duration.fromHours(f))->Ok->Some - | ("days", [IevNumber(f)]) => EV.IevTimeDuration(DateTime.Duration.fromDays(f))->Ok->Some - | ("fromUnit_days", [IevNumber(f)]) => EV.IevTimeDuration(DateTime.Duration.fromDays(f))->Ok->Some - | ("years", [IevNumber(f)]) => EV.IevTimeDuration(DateTime.Duration.fromYears(f))->Ok->Some - | ("fromUnit_years", [IevNumber(f)]) => - EV.IevTimeDuration(DateTime.Duration.fromYears(f))->Ok->Some - | ("toHours", [IevTimeDuration(f)]) => EV.IevNumber(DateTime.Duration.toHours(f))->Ok->Some - | ("toMinutes", [IevTimeDuration(f)]) => EV.IevNumber(DateTime.Duration.toMinutes(f))->Ok->Some - | ("toDays", [IevTimeDuration(f)]) => EV.IevNumber(DateTime.Duration.toDays(f))->Ok->Some - | ("toYears", [IevTimeDuration(f)]) => EV.IevNumber(DateTime.Duration.toYears(f))->Ok->Some - | ("add", [IevTimeDuration(d1), IevTimeDuration(d2)]) => - EV.IevTimeDuration(DateTime.Duration.add(d1, d2))->Ok->Some - | ("subtract", [IevTimeDuration(d1), IevTimeDuration(d2)]) => - EV.IevTimeDuration(DateTime.Duration.subtract(d1, d2))->Ok->Some - | ("multiply", [IevTimeDuration(d1), IevNumber(d2)]) => - EV.IevTimeDuration(DateTime.Duration.multiply(d1, d2))->Ok->Some - | ("divide", [IevTimeDuration(d1), IevNumber(d2)]) => - EV.IevTimeDuration(DateTime.Duration.divide(d1, d2))->Ok->Some - | ("divide", [IevTimeDuration(d1), IevTimeDuration(d2)]) => EV.IevNumber(d1 /. d2)->Ok->Some + | ("toString", [IEvTimeDuration(t)]) => EV.IEvString(DateTime.Duration.toString(t))->Ok->Some + | ("minutes", [IEvNumber(f)]) => EV.IEvTimeDuration(DateTime.Duration.fromMinutes(f))->Ok->Some + | ("fromUnit_minutes", [IEvNumber(f)]) => + EV.IEvTimeDuration(DateTime.Duration.fromMinutes(f))->Ok->Some + | ("hours", [IEvNumber(f)]) => EV.IEvTimeDuration(DateTime.Duration.fromHours(f))->Ok->Some + | ("fromUnit_hours", [IEvNumber(f)]) => + EV.IEvTimeDuration(DateTime.Duration.fromHours(f))->Ok->Some + | ("days", [IEvNumber(f)]) => EV.IEvTimeDuration(DateTime.Duration.fromDays(f))->Ok->Some + | ("fromUnit_days", [IEvNumber(f)]) => EV.IEvTimeDuration(DateTime.Duration.fromDays(f))->Ok->Some + | ("years", [IEvNumber(f)]) => EV.IEvTimeDuration(DateTime.Duration.fromYears(f))->Ok->Some + | ("fromUnit_years", [IEvNumber(f)]) => + EV.IEvTimeDuration(DateTime.Duration.fromYears(f))->Ok->Some + | ("toHours", [IEvTimeDuration(f)]) => EV.IEvNumber(DateTime.Duration.toHours(f))->Ok->Some + | ("toMinutes", [IEvTimeDuration(f)]) => EV.IEvNumber(DateTime.Duration.toMinutes(f))->Ok->Some + | ("toDays", [IEvTimeDuration(f)]) => EV.IEvNumber(DateTime.Duration.toDays(f))->Ok->Some + | ("toYears", [IEvTimeDuration(f)]) => EV.IEvNumber(DateTime.Duration.toYears(f))->Ok->Some + | ("add", [IEvTimeDuration(d1), IEvTimeDuration(d2)]) => + EV.IEvTimeDuration(DateTime.Duration.add(d1, d2))->Ok->Some + | ("subtract", [IEvTimeDuration(d1), IEvTimeDuration(d2)]) => + EV.IEvTimeDuration(DateTime.Duration.subtract(d1, d2))->Ok->Some + | ("multiply", [IEvTimeDuration(d1), IEvNumber(d2)]) => + EV.IEvTimeDuration(DateTime.Duration.multiply(d1, d2))->Ok->Some + | ("divide", [IEvTimeDuration(d1), IEvNumber(d2)]) => + EV.IEvTimeDuration(DateTime.Duration.divide(d1, d2))->Ok->Some + | ("divide", [IEvTimeDuration(d1), IEvTimeDuration(d2)]) => EV.IEvNumber(d1 /. d2)->Ok->Some | _ => None } } diff --git a/packages/squiggle-lang/src/rescript/ReducerInterface/ReducerInterface_GenericDistribution.res b/packages/squiggle-lang/src/rescript/ReducerInterface/ReducerInterface_GenericDistribution.res index a9ddabd6..fd3ebadf 100644 --- a/packages/squiggle-lang/src/rescript/ReducerInterface/ReducerInterface_GenericDistribution.res +++ b/packages/squiggle-lang/src/rescript/ReducerInterface/ReducerInterface_GenericDistribution.res @@ -23,9 +23,9 @@ module Helpers = { DistributionTypes.genericDist, )> => switch args { - | [IevDistribution(a), IevDistribution(b)] => Some((a, b)) - | [IevNumber(a), IevDistribution(b)] => Some((GenericDist.fromFloat(a), b)) - | [IevDistribution(a), IevNumber(b)] => Some((a, GenericDist.fromFloat(b))) + | [IEvDistribution(a), IEvDistribution(b)] => Some((a, b)) + | [IEvNumber(a), IEvDistribution(b)] => Some((GenericDist.fromFloat(a), b)) + | [IEvDistribution(a), IEvNumber(b)] => Some((a, GenericDist.fromFloat(b))) | _ => None } @@ -82,7 +82,7 @@ module Helpers = { let parseNumber = (args: expressionValue): Belt.Result.t => switch args { - | IevNumber(x) => Ok(x) + | IEvNumber(x) => Ok(x) | _ => Error("Not a number") } @@ -91,8 +91,8 @@ module Helpers = { let parseDist = (args: expressionValue): Belt.Result.t => switch args { - | IevDistribution(x) => Ok(x) - | IevNumber(x) => Ok(GenericDist.fromFloat(x)) + | IEvDistribution(x) => Ok(x) + | IEvNumber(x) => Ok(GenericDist.fromFloat(x)) | _ => Error("Not a distribution") } @@ -128,12 +128,12 @@ module Helpers = { let error = (err: string): DistributionOperation.outputType => err->DistributionTypes.ArgumentError->GenDistError switch args { - | [IevArray(distributions)] => + | [IEvArray(distributions)] => switch parseDistributionArray(distributions) { | Ok(distrs) => mixtureWithDefaultWeights(distrs, ~env) | Error(err) => error(err) } - | [IevArray(distributions), IevArray(weights)] => + | [IEvArray(distributions), IEvArray(weights)] => switch (parseDistributionArray(distributions), parseNumberArray(weights)) { | (Ok(distrs), Ok(wghts)) => mixtureWithGivenWeights(distrs, wghts, ~env) | (Error(err), Ok(_)) => error(err) @@ -142,7 +142,7 @@ module Helpers = { } | _ => switch E.A.last(args) { - | Some(IevArray(b)) => { + | Some(IEvArray(b)) => { let weights = parseNumberArray(b) let distributions = parseDistributionArray( Belt.Array.slice(args, ~offset=0, ~len=E.A.length(args) - 1), @@ -152,8 +152,8 @@ module Helpers = { | Error(err) => error(err) } } - | Some(IevNumber(_)) - | Some(IevDistribution(_)) => + | Some(IEvNumber(_)) + | Some(IEvDistribution(_)) => switch parseDistributionArray(args) { | Ok(distributions) => mixtureWithDefaultWeights(distributions, ~env) | Error(err) => error(err) @@ -200,14 +200,14 @@ let dispatchToGenericOutput = ( ): option => { let (fnName, args) = call switch (fnName, args) { - | ("triangular" as fnName, [IevNumber(f1), IevNumber(f2), IevNumber(f3)]) => + | ("triangular" as fnName, [IEvNumber(f1), IEvNumber(f2), IEvNumber(f3)]) => SymbolicConstructors.threeFloat(fnName) ->E.R.bind(r => r(f1, f2, f3)) ->SymbolicConstructors.symbolicResultToOutput - | ("sample", [IevDistribution(dist)]) => Helpers.toFloatFn(#Sample, dist, ~env) - | ("sampleN", [IevDistribution(dist), IevNumber(n)]) => + | ("sample", [IEvDistribution(dist)]) => Helpers.toFloatFn(#Sample, dist, ~env) + | ("sampleN", [IEvDistribution(dist), IEvNumber(n)]) => Some(FloatArray(GenericDist.sampleN(dist, Belt.Int.fromFloat(n)))) - | (("mean" | "stdev" | "variance" | "min" | "max" | "mode") as op, [IevDistribution(dist)]) => { + | (("mean" | "stdev" | "variance" | "min" | "max" | "mode") as op, [IEvDistribution(dist)]) => { let fn = switch op { | "mean" => #Mean | "stdev" => #Stdev @@ -219,13 +219,13 @@ let dispatchToGenericOutput = ( } Helpers.toFloatFn(fn, dist, ~env) } - | ("integralSum", [IevDistribution(dist)]) => Helpers.toFloatFn(#IntegralSum, dist, ~env) - | ("toString", [IevDistribution(dist)]) => Helpers.toStringFn(ToString, dist, ~env) - | ("sparkline", [IevDistribution(dist)]) => + | ("integralSum", [IEvDistribution(dist)]) => Helpers.toFloatFn(#IntegralSum, dist, ~env) + | ("toString", [IEvDistribution(dist)]) => Helpers.toStringFn(ToString, dist, ~env) + | ("sparkline", [IEvDistribution(dist)]) => Helpers.toStringFn(ToSparkline(MagicNumbers.Environment.sparklineLength), dist, ~env) - | ("sparkline", [IevDistribution(dist), IevNumber(n)]) => + | ("sparkline", [IEvDistribution(dist), IEvNumber(n)]) => Helpers.toStringFn(ToSparkline(Belt.Float.toInt(n)), dist, ~env) - | ("exp", [IevDistribution(a)]) => + | ("exp", [IEvDistribution(a)]) => // https://mathjs.org/docs/reference/functions/exp.html Helpers.twoDiststoDistFn( Algebraic(AsDefault), @@ -234,62 +234,62 @@ let dispatchToGenericOutput = ( a, ~env, )->Some - | ("normalize", [IevDistribution(dist)]) => Helpers.toDistFn(Normalize, dist, ~env) - | ("klDivergence", [IevDistribution(prediction), IevDistribution(answer)]) => + | ("normalize", [IEvDistribution(dist)]) => Helpers.toDistFn(Normalize, dist, ~env) + | ("klDivergence", [IEvDistribution(prediction), IEvDistribution(answer)]) => Some(DistributionOperation.run(FromDist(ToScore(KLDivergence(answer)), prediction), ~env)) | ( "klDivergence", - [IevDistribution(prediction), IevDistribution(answer), IevDistribution(prior)], + [IEvDistribution(prediction), IEvDistribution(answer), IEvDistribution(prior)], ) => Helpers.klDivergenceWithPrior(prediction, answer, prior, env) | ( "logScoreWithPointAnswer", - [IevDistribution(prediction), IevNumber(answer), IevDistribution(prior)], + [IEvDistribution(prediction), IEvNumber(answer), IEvDistribution(prior)], ) | ( "logScoreWithPointAnswer", [ - IevDistribution(prediction), - IevDistribution(Symbolic(#Float(answer))), - IevDistribution(prior), + IEvDistribution(prediction), + IEvDistribution(Symbolic(#Float(answer))), + IEvDistribution(prior), ], ) => DistributionOperation.run( FromDist(ToScore(LogScore(answer, prior->Some)), prediction), ~env, )->Some - | ("logScoreWithPointAnswer", [IevDistribution(prediction), IevNumber(answer)]) + | ("logScoreWithPointAnswer", [IEvDistribution(prediction), IEvNumber(answer)]) | ( "logScoreWithPointAnswer", - [IevDistribution(prediction), IevDistribution(Symbolic(#Float(answer)))], + [IEvDistribution(prediction), IEvDistribution(Symbolic(#Float(answer)))], ) => DistributionOperation.run(FromDist(ToScore(LogScore(answer, None)), prediction), ~env)->Some - | ("isNormalized", [IevDistribution(dist)]) => Helpers.toBoolFn(IsNormalized, dist, ~env) - | ("toPointSet", [IevDistribution(dist)]) => Helpers.toDistFn(ToPointSet, dist, ~env) - | ("scaleLog", [IevDistribution(dist)]) => + | ("isNormalized", [IEvDistribution(dist)]) => Helpers.toBoolFn(IsNormalized, dist, ~env) + | ("toPointSet", [IEvDistribution(dist)]) => Helpers.toDistFn(ToPointSet, dist, ~env) + | ("scaleLog", [IEvDistribution(dist)]) => Helpers.toDistFn(Scale(#Logarithm, MagicNumbers.Math.e), dist, ~env) - | ("scaleLog10", [IevDistribution(dist)]) => Helpers.toDistFn(Scale(#Logarithm, 10.0), dist, ~env) - | ("scaleLog", [IevDistribution(dist), IevNumber(float)]) => + | ("scaleLog10", [IEvDistribution(dist)]) => Helpers.toDistFn(Scale(#Logarithm, 10.0), dist, ~env) + | ("scaleLog", [IEvDistribution(dist), IEvNumber(float)]) => Helpers.toDistFn(Scale(#Logarithm, float), dist, ~env) - | ("scaleLogWithThreshold", [IevDistribution(dist), IevNumber(base), IevNumber(eps)]) => + | ("scaleLogWithThreshold", [IEvDistribution(dist), IEvNumber(base), IEvNumber(eps)]) => Helpers.toDistFn(Scale(#LogarithmWithThreshold(eps), base), dist, ~env) - | ("scaleMultiply", [IevDistribution(dist), IevNumber(float)]) => + | ("scaleMultiply", [IEvDistribution(dist), IEvNumber(float)]) => Helpers.toDistFn(Scale(#Multiply, float), dist, ~env) - | ("scalePow", [IevDistribution(dist), IevNumber(float)]) => + | ("scalePow", [IEvDistribution(dist), IEvNumber(float)]) => Helpers.toDistFn(Scale(#Power, float), dist, ~env) - | ("scaleExp", [IevDistribution(dist)]) => + | ("scaleExp", [IEvDistribution(dist)]) => Helpers.toDistFn(Scale(#Power, MagicNumbers.Math.e), dist, ~env) - | ("cdf", [IevDistribution(dist), IevNumber(float)]) => Helpers.toFloatFn(#Cdf(float), dist, ~env) - | ("pdf", [IevDistribution(dist), IevNumber(float)]) => Helpers.toFloatFn(#Pdf(float), dist, ~env) - | ("inv", [IevDistribution(dist), IevNumber(float)]) => Helpers.toFloatFn(#Inv(float), dist, ~env) - | ("quantile", [IevDistribution(dist), IevNumber(float)]) => + | ("cdf", [IEvDistribution(dist), IEvNumber(float)]) => Helpers.toFloatFn(#Cdf(float), dist, ~env) + | ("pdf", [IEvDistribution(dist), IEvNumber(float)]) => Helpers.toFloatFn(#Pdf(float), dist, ~env) + | ("inv", [IEvDistribution(dist), IEvNumber(float)]) => Helpers.toFloatFn(#Inv(float), dist, ~env) + | ("quantile", [IEvDistribution(dist), IEvNumber(float)]) => Helpers.toFloatFn(#Inv(float), dist, ~env) - | ("toSampleSet", [IevDistribution(dist), IevNumber(float)]) => + | ("toSampleSet", [IEvDistribution(dist), IEvNumber(float)]) => Helpers.toDistFn(ToSampleSet(Belt.Int.fromFloat(float)), dist, ~env) - | ("toSampleSet", [IevDistribution(dist)]) => + | ("toSampleSet", [IEvDistribution(dist)]) => Helpers.toDistFn(ToSampleSet(env.sampleCount), dist, ~env) - | ("toList", [IevDistribution(SampleSet(dist))]) => Some(FloatArray(SampleSetDist.T.get(dist))) - | ("fromSamples", [IevArray(inputArray)]) => { + | ("toList", [IEvDistribution(SampleSet(dist))]) => Some(FloatArray(SampleSetDist.T.get(dist))) + | ("fromSamples", [IEvArray(inputArray)]) => { let _wrapInputErrors = x => SampleSetDist.NonNumericInput(x) let parsedArray = Helpers.parseNumberArray(inputArray)->E.R2.errMap(_wrapInputErrors) switch parsedArray { @@ -297,15 +297,15 @@ let dispatchToGenericOutput = ( | Error(e) => GenDistError(SampleSetError(e)) }->Some } - | ("inspect", [IevDistribution(dist)]) => Helpers.toDistFn(Inspect, dist, ~env) - | ("truncateLeft", [IevDistribution(dist), IevNumber(float)]) => + | ("inspect", [IEvDistribution(dist)]) => Helpers.toDistFn(Inspect, dist, ~env) + | ("truncateLeft", [IEvDistribution(dist), IEvNumber(float)]) => Helpers.toDistFn(Truncate(Some(float), None), dist, ~env) - | ("truncateRight", [IevDistribution(dist), IevNumber(float)]) => + | ("truncateRight", [IEvDistribution(dist), IEvNumber(float)]) => Helpers.toDistFn(Truncate(None, Some(float)), dist, ~env) - | ("truncate", [IevDistribution(dist), IevNumber(float1), IevNumber(float2)]) => + | ("truncate", [IEvDistribution(dist), IEvNumber(float1), IEvNumber(float2)]) => Helpers.toDistFn(Truncate(Some(float1), Some(float2)), dist, ~env) | ("mx" | "mixture", args) => Helpers.mixture(args, ~env)->Some - | ("log", [IevDistribution(a)]) => + | ("log", [IEvDistribution(a)]) => Helpers.twoDiststoDistFn( Algebraic(AsDefault), "log", @@ -313,7 +313,7 @@ let dispatchToGenericOutput = ( GenericDist.fromFloat(MagicNumbers.Math.e), ~env, )->Some - | ("log10", [IevDistribution(a)]) => + | ("log10", [IEvDistribution(a)]) => Helpers.twoDiststoDistFn( Algebraic(AsDefault), "log", @@ -321,7 +321,7 @@ let dispatchToGenericOutput = ( GenericDist.fromFloat(10.0), ~env, )->Some - | ("unaryMinus", [IevDistribution(a)]) => + | ("unaryMinus", [IEvDistribution(a)]) => Helpers.twoDiststoDistFn( Algebraic(AsDefault), "multiply", @@ -344,7 +344,7 @@ let dispatchToGenericOutput = ( Helpers.catchAndConvertTwoArgsToDists(args)->E.O2.fmap(((fst, snd)) => Helpers.twoDiststoDistFn(Pointwise, arithmetic, fst, snd, ~env) ) - | ("dotExp", [IevDistribution(a)]) => + | ("dotExp", [IEvDistribution(a)]) => Helpers.twoDiststoDistFn( Pointwise, "dotPow", @@ -361,12 +361,12 @@ let genericOutputToReducerValue = (o: DistributionOperation.outputType): result< Reducer_ErrorValue.errorValue, > => switch o { - | Dist(d) => Ok(ReducerInterface_InternalExpressionValue.IevDistribution(d)) - | Float(d) => Ok(IevNumber(d)) - | String(d) => Ok(IevString(d)) - | Bool(d) => Ok(IevBool(d)) + | Dist(d) => Ok(ReducerInterface_InternalExpressionValue.IEvDistribution(d)) + | Float(d) => Ok(IEvNumber(d)) + | String(d) => Ok(IEvString(d)) + | Bool(d) => Ok(IEvBool(d)) | FloatArray(d) => - Ok(IevArray(d |> E.A.fmap(r => ReducerInterface_InternalExpressionValue.IevNumber(r)))) + Ok(IEvArray(d |> E.A.fmap(r => ReducerInterface_InternalExpressionValue.IEvNumber(r)))) | GenDistError(err) => Error(REDistributionError(err)) } diff --git a/packages/squiggle-lang/src/rescript/ReducerInterface/ReducerInterface_InternalExpressionValue.res b/packages/squiggle-lang/src/rescript/ReducerInterface/ReducerInterface_InternalExpressionValue.res index b912dde2..7290c12e 100644 --- a/packages/squiggle-lang/src/rescript/ReducerInterface/ReducerInterface_InternalExpressionValue.res +++ b/packages/squiggle-lang/src/rescript/ReducerInterface/ReducerInterface_InternalExpressionValue.res @@ -7,21 +7,21 @@ type environment = ExternalExpressionValue.environment let defaultEnvironment = ExternalExpressionValue.defaultEnvironment type rec expressionValue = - | IevArray(array) // FIXME: Convert - | IevArrayString(array) // FIXME: Convert - | IevBool(bool) - | IevCall(string) // External function call - | IevDate(Js.Date.t) - | IevDeclaration(lambdaDeclaration) - | IevDistribution(DistributionTypes.genericDist) - | IevLambda(lambdaValue) - | IevModule(nameSpace) // FIXME: Convert - | IevNumber(float) - | IevRecord(map) - | IevString(string) - | IevSymbol(string) - | IevTimeDuration(float) - | IevTypeIdentifier(string) + | IEvArray(array) // FIXME: Convert + | IEvArrayString(array) // FIXME: Convert + | IEvBool(bool) + | IEvCall(string) // External function call + | IEvDate(Js.Date.t) + | IEvDeclaration(lambdaDeclaration) + | IEvDistribution(DistributionTypes.genericDist) + | IEvLambda(lambdaValue) + | IEvModule(nameSpace) // FIXME: Convert + | IEvNumber(float) + | IEvRecord(map) + | IEvString(string) + | IEvSymbol(string) + | IEvTimeDuration(float) + | IEvTypeIdentifier(string) and map = Belt.Map.String.t and nameSpace = NameSpace(Belt.Map.String.t) and tmpExternalBindings = Js.Dict.t // FIXME: Remove @@ -38,27 +38,27 @@ type functionCall = (string, array) let rec toString = aValue => switch aValue { - | IevArray(anArray) => { + | IEvArray(anArray) => { let args = anArray->Js.Array2.map(each => toString(each))->Js.Array2.toString `[${args}]` } - | IevArrayString(anArray) => { + | IEvArrayString(anArray) => { let args = anArray->Js.Array2.toString `[${args}]` } - | IevBool(aBool) => Js.String.make(aBool) - | IevCall(fName) => `:${fName}` - | IevDate(date) => DateTime.Date.toString(date) - | IevDeclaration(d) => Declaration.toString(d, r => toString(IevLambda(r))) - | IevDistribution(dist) => GenericDist.toString(dist) - | IevLambda(lambdaValue) => `lambda(${Js.Array2.toString(lambdaValue.parameters)}=>internal code)` - | IevModule(m) => `@${m->toStringNameSpace}` - | IevNumber(aNumber) => Js.String.make(aNumber) - | IevRecord(aMap) => aMap->toStringMap - | IevString(aString) => `'${aString}'` - | IevSymbol(aString) => `:${aString}` - | IevTimeDuration(t) => DateTime.Duration.toString(t) - | IevTypeIdentifier(id) => `#${id}` + | IEvBool(aBool) => Js.String.make(aBool) + | IEvCall(fName) => `:${fName}` + | IEvDate(date) => DateTime.Date.toString(date) + | IEvDeclaration(d) => Declaration.toString(d, r => toString(IEvLambda(r))) + | IEvDistribution(dist) => GenericDist.toString(dist) + | IEvLambda(lambdaValue) => `lambda(${Js.Array2.toString(lambdaValue.parameters)}=>internal code)` + | IEvModule(m) => `@${m->toStringNameSpace}` + | IEvNumber(aNumber) => Js.String.make(aNumber) + | IEvRecord(aMap) => aMap->toStringMap + | IEvString(aString) => `'${aString}'` + | IEvSymbol(aString) => `:${aString}` + | IEvTimeDuration(t) => DateTime.Duration.toString(t) + | IEvTypeIdentifier(id) => `#${id}` } and toStringMap = aMap => { let pairs = @@ -75,21 +75,21 @@ and toStringNameSpace = nameSpace => { let toStringWithType = aValue => switch aValue { - | IevArray(_) => `Array::${toString(aValue)}` - | IevArrayString(_) => `ArrayString::${toString(aValue)}` - | IevBool(_) => `Bool::${toString(aValue)}` - | IevCall(_) => `Call::${toString(aValue)}` - | IevDistribution(_) => `Distribution::${toString(aValue)}` - | IevLambda(_) => `Lambda::${toString(aValue)}` - | IevNumber(_) => `Number::${toString(aValue)}` - | IevRecord(_) => `Record::${toString(aValue)}` - | IevString(_) => `String::${toString(aValue)}` - | IevSymbol(_) => `Symbol::${toString(aValue)}` - | IevDate(_) => `Date::${toString(aValue)}` - | IevTimeDuration(_) => `Date::${toString(aValue)}` - | IevDeclaration(_) => `Declaration::${toString(aValue)}` - | IevTypeIdentifier(_) => `TypeIdentifier::${toString(aValue)}` - | IevModule(_) => `Module::${toString(aValue)}` + | IEvArray(_) => `Array::${toString(aValue)}` + | IEvArrayString(_) => `ArrayString::${toString(aValue)}` + | IEvBool(_) => `Bool::${toString(aValue)}` + | IEvCall(_) => `Call::${toString(aValue)}` + | IEvDistribution(_) => `Distribution::${toString(aValue)}` + | IEvLambda(_) => `Lambda::${toString(aValue)}` + | IEvNumber(_) => `Number::${toString(aValue)}` + | IEvRecord(_) => `Record::${toString(aValue)}` + | IEvString(_) => `String::${toString(aValue)}` + | IEvSymbol(_) => `Symbol::${toString(aValue)}` + | IEvDate(_) => `Date::${toString(aValue)}` + | IEvTimeDuration(_) => `Date::${toString(aValue)}` + | IEvDeclaration(_) => `Declaration::${toString(aValue)}` + | IEvTypeIdentifier(_) => `TypeIdentifier::${toString(aValue)}` + | IEvModule(_) => `Module::${toString(aValue)}` } let argsToString = (args: array): string => { @@ -139,21 +139,21 @@ type functionDefinitionSignature = let valueToValueType = value => switch value { - | IevArray(_) => EvtArray - | IevArrayString(_) => EvtArrayString - | IevBool(_) => EvtBool - | IevCall(_) => EvtCall - | IevDistribution(_) => EvtDistribution - | IevLambda(_) => EvtLambda - | IevNumber(_) => EvtNumber - | IevRecord(_) => EvtRecord - | IevString(_) => EvtString - | IevSymbol(_) => EvtSymbol - | IevDate(_) => EvtDate - | IevTimeDuration(_) => EvtTimeDuration - | IevDeclaration(_) => EvtDeclaration - | IevTypeIdentifier(_) => EvtTypeIdentifier - | IevModule(_) => EvtModule + | IEvArray(_) => EvtArray + | IEvArrayString(_) => EvtArrayString + | IEvBool(_) => EvtBool + | IEvCall(_) => EvtCall + | IEvDistribution(_) => EvtDistribution + | IEvLambda(_) => EvtLambda + | IEvNumber(_) => EvtNumber + | IEvRecord(_) => EvtRecord + | IEvString(_) => EvtString + | IEvSymbol(_) => EvtSymbol + | IEvDate(_) => EvtDate + | IEvTimeDuration(_) => EvtTimeDuration + | IEvDeclaration(_) => EvtDeclaration + | IEvTypeIdentifier(_) => EvtTypeIdentifier + | IEvModule(_) => EvtModule } let functionCallToCallSignature = (functionCall: functionCall): functionCallSignature => { @@ -187,25 +187,25 @@ let functionCallSignatureToString = (functionCallSignature: functionCallSignatur let rec toExternal = (iev: expressionValue): ExternalExpressionValue.expressionValue => { switch iev { - | IevArray(v) => v->Belt.Array.map(e => toExternal(e))->EvArray - | IevArrayString(v) => EvArrayString(v) - | IevBool(v) => EvBool(v) - | IevCall(v) => EvCall(v) - | IevDistribution(v) => EvDistribution(v) - | IevLambda(v) => EvLambda(lambdaValueToExternal(v)) - | IevNumber(v) => EvNumber(v) - | IevRecord(v) => v->mapToExternal->EvRecord - | IevString(v) => EvString(v) - | IevSymbol(v) => EvSymbol(v) - | IevDate(v) => EvDate(v) - | IevTimeDuration(v) => EvTimeDuration(v) - | IevDeclaration(v) => { + | IEvArray(v) => v->Belt.Array.map(e => toExternal(e))->EvArray + | IEvArrayString(v) => EvArrayString(v) + | IEvBool(v) => EvBool(v) + | IEvCall(v) => EvCall(v) + | IEvDistribution(v) => EvDistribution(v) + | IEvLambda(v) => EvLambda(lambdaValueToExternal(v)) + | IEvNumber(v) => EvNumber(v) + | IEvRecord(v) => v->mapToExternal->EvRecord + | IEvString(v) => EvString(v) + | IEvSymbol(v) => EvSymbol(v) + | IEvDate(v) => EvDate(v) + | IEvTimeDuration(v) => EvTimeDuration(v) + | IEvDeclaration(v) => { let fn = lambdaValueToExternal(v.fn) let args = v.args EvDeclaration({fn: fn, args: args}) } - | IevTypeIdentifier(v) => EvTypeIdentifier(v) - | IevModule(v) => v->nameSpaceToTypeScriptBindings->EvModule + | IEvTypeIdentifier(v) => EvTypeIdentifier(v) + | IEvModule(v) => v->nameSpaceToTypeScriptBindings->EvModule } } and mapToExternal = v => @@ -225,25 +225,25 @@ and nameSpaceToTypeScriptBindings = ( let rec toInternal = (ev: ExternalExpressionValue.expressionValue): expressionValue => { switch ev { - | EvArray(v) => v->Belt.Array.map(e => toInternal(e))->IevArray - | EvArrayString(v) => IevArrayString(v) - | EvBool(v) => IevBool(v) - | EvCall(v) => IevCall(v) - | EvDistribution(v) => IevDistribution(v) - | EvLambda(v) => IevLambda(lambdaValueToInternal(v)) - | EvNumber(v) => IevNumber(v) - | EvRecord(v) => v->recordToInternal->IevRecord - | EvString(v) => IevString(v) - | EvSymbol(v) => IevSymbol(v) - | EvDate(v) => IevDate(v) - | EvTimeDuration(v) => IevTimeDuration(v) + | EvArray(v) => v->Belt.Array.map(e => toInternal(e))->IEvArray + | EvArrayString(v) => IEvArrayString(v) + | EvBool(v) => IEvBool(v) + | EvCall(v) => IEvCall(v) + | EvDistribution(v) => IEvDistribution(v) + | EvLambda(v) => IEvLambda(lambdaValueToInternal(v)) + | EvNumber(v) => IEvNumber(v) + | EvRecord(v) => v->recordToInternal->IEvRecord + | EvString(v) => IEvString(v) + | EvSymbol(v) => IEvSymbol(v) + | EvDate(v) => IEvDate(v) + | EvTimeDuration(v) => IEvTimeDuration(v) | EvDeclaration(v) => { let fn = lambdaValueToInternal(v.fn) let args = v.args - IevDeclaration({fn: fn, args: args}) + IEvDeclaration({fn: fn, args: args}) } - | EvTypeIdentifier(v) => IevTypeIdentifier(v) - | EvModule(v) => v->nameSpaceFromTypeScriptBindings->IevModule + | EvTypeIdentifier(v) => IEvTypeIdentifier(v) + | EvModule(v) => v->nameSpaceFromTypeScriptBindings->IEvModule } } and recordToInternal = v => diff --git a/packages/squiggle-lang/src/rescript/ReducerInterface/ReducerInterface_Number.res b/packages/squiggle-lang/src/rescript/ReducerInterface/ReducerInterface_Number.res index 8d5b008f..4787880d 100644 --- a/packages/squiggle-lang/src/rescript/ReducerInterface/ReducerInterface_Number.res +++ b/packages/squiggle-lang/src/rescript/ReducerInterface/ReducerInterface_Number.res @@ -37,9 +37,9 @@ let dispatch = (call: EV.functionCall, _: DistributionOperation.env): option< | "fromUnit_G" | "fromUnit_T" | "fromUnit_P") as op, - [IevNumber(f)], + [IEvNumber(f)], ) => - op->ScientificUnit.getMultiplier->E.O2.fmap(multiplier => EV.IevNumber(f *. multiplier)->Ok) + op->ScientificUnit.getMultiplier->E.O2.fmap(multiplier => EV.IEvNumber(f *. multiplier)->Ok) | _ => None } } diff --git a/packages/squiggle-lang/src/rescript/SquiggleLibrary/SquiggleLibrary_Math.res b/packages/squiggle-lang/src/rescript/SquiggleLibrary/SquiggleLibrary_Math.res index 4dc59b56..ba049bea 100644 --- a/packages/squiggle-lang/src/rescript/SquiggleLibrary/SquiggleLibrary_Math.res +++ b/packages/squiggle-lang/src/rescript/SquiggleLibrary/SquiggleLibrary_Math.res @@ -16,7 +16,7 @@ let availableNumbers: array<(string, float)> = [ let mathBindings: Bindings.t = availableNumbers - ->E.A2.fmap(((name, v)) => (name, ReducerInterface_InternalExpressionValue.IevNumber(v))) + ->E.A2.fmap(((name, v)) => (name, ReducerInterface_InternalExpressionValue.IEvNumber(v))) ->Bindings.fromArray let makeBindings = (previousBindings: Bindings.t): Bindings.t => From e192fe5790b8206fc7a1a7b441a7c2c88386f196 Mon Sep 17 00:00:00 2001 From: Umur Ozkul Date: Fri, 24 Jun 2022 12:15:38 +0200 Subject: [PATCH 11/12] PR comments --- .../__tests__/Reducer/Reducer_Helpers.res | 6 +-- .../Reducer/Reducer_TestMacroHelpers.res | 16 +++---- .../FunctionRegistry_Core.res | 33 +++++++------- .../FunctionRegistry_Library.res | 2 +- .../src/rescript/Reducer/Reducer.res | 6 +-- .../src/rescript/Reducer/Reducer.resi | 24 +++++----- .../Reducer_Category_Module.res | 6 +-- .../Reducer_Category_Module_TypeChecker.res | 5 --- .../Reducer_Dispatch_BuiltIn.res | 21 +++++---- .../Reducer_Dispatch_BuiltInMacros.res | 9 ++-- .../Reducer_Expression/Reducer_Expression.res | 35 +++++++-------- .../Reducer_ExpressionWithContext.res | 10 ++--- .../Reducer_Expression_BindingsReplacer.res | 13 +++--- .../Reducer_Expression_ExpressionBuilder.res | 36 ++++++++------- .../Reducer_Expression_Lambda.res | 15 ++++--- .../Reducer_Expression_Macro.res | 8 ++-- .../Reducer_Expression_T.res | 10 ++--- .../Reducer/Reducer_Js/Reducer_Js_Gate.res | 2 +- .../Reducer_MathJs/Reducer_MathJs_Eval.res | 2 +- .../ReducerInterface/ReducerInterface.res | 2 +- .../ReducerInterface_Date.res | 22 ++++----- .../ReducerInterface_Duration.res | 45 ++++++++++--------- ...ucerInterface_ExternalExpressionValue.res} | 25 ++++------- .../ReducerInterface_ExternalLibrary.res | 10 ++--- .../ReducerInterface_GenericDistribution.res | 34 +++++++------- .../ReducerInterface_GenericDistribution.resi | 6 +-- ...ducerInterface_InternalExpressionValue.res | 37 ++++++++------- .../ReducerInterface_Number.res | 10 ++--- .../src/rescript/TypescriptInterface.res | 12 ++--- 29 files changed, 228 insertions(+), 234 deletions(-) rename packages/squiggle-lang/src/rescript/ReducerInterface/{ReducerInterface_ExpressionValue.res => ReducerInterface_ExternalExpressionValue.res} (87%) diff --git a/packages/squiggle-lang/__tests__/Reducer/Reducer_Helpers.res b/packages/squiggle-lang/__tests__/Reducer/Reducer_Helpers.res index 569b187f..8e3d8257 100644 --- a/packages/squiggle-lang/__tests__/Reducer/Reducer_Helpers.res +++ b/packages/squiggle-lang/__tests__/Reducer/Reducer_Helpers.res @@ -4,7 +4,7 @@ module ExternalExpressionValue = ReducerInterface.ExternalExpressionValue module InternalExpressionValue = ReducerInterface.InternalExpressionValue module Module = Reducer_Category_Module -let removeDefaultsInternal = (iev: InternalExpressionValue.expressionValue) => { +let removeDefaultsInternal = (iev: InternalExpressionValue.t) => { switch iev { | InternalExpressionValue.IEvModule(nameSpace) => Module.removeOther( @@ -15,9 +15,7 @@ let removeDefaultsInternal = (iev: InternalExpressionValue.expressionValue) => { } } -let removeDefaultsExternal = ( - ev: ExternalExpressionValue.expressionValue, -): ExternalExpressionValue.expressionValue => +let removeDefaultsExternal = (ev: ExternalExpressionValue.t): ExternalExpressionValue.t => ev->InternalExpressionValue.toInternal->removeDefaultsInternal->InternalExpressionValue.toExternal let rRemoveDefaultsInternal = r => Belt.Result.map(r, removeDefaultsInternal) diff --git a/packages/squiggle-lang/__tests__/Reducer/Reducer_TestMacroHelpers.res b/packages/squiggle-lang/__tests__/Reducer/Reducer_TestMacroHelpers.res index 1383d45e..103609a2 100644 --- a/packages/squiggle-lang/__tests__/Reducer/Reducer_TestMacroHelpers.res +++ b/packages/squiggle-lang/__tests__/Reducer/Reducer_TestMacroHelpers.res @@ -12,7 +12,7 @@ module Module = Reducer_Category_Module let testMacro_ = ( tester, - bindArray: array<(string, InternalExpressionValue.expressionValue)>, + bindArray: array<(string, InternalExpressionValue.t)>, expr: T.expression, expectedCode: string, ) => { @@ -32,7 +32,7 @@ let testMacro_ = ( let testMacroEval_ = ( tester, - bindArray: array<(string, InternalExpressionValue.expressionValue)>, + bindArray: array<(string, InternalExpressionValue.t)>, expr: T.expression, expectedValue: string, ) => { @@ -51,24 +51,24 @@ let testMacroEval_ = ( } let testMacro = ( - bindArray: array<(string, InternalExpressionValue.expressionValue)>, + bindArray: array<(string, InternalExpressionValue.t)>, expr: T.expression, expectedExpr: string, ) => testMacro_(test, bindArray, expr, expectedExpr) let testMacroEval = ( - bindArray: array<(string, InternalExpressionValue.expressionValue)>, + bindArray: array<(string, InternalExpressionValue.t)>, expr: T.expression, expectedValue: string, ) => testMacroEval_(test, bindArray, expr, expectedValue) module MySkip = { let testMacro = ( - bindArray: array<(string, InternalExpressionValue.expressionValue)>, + bindArray: array<(string, InternalExpressionValue.t)>, expr: T.expression, expectedExpr: string, ) => testMacro_(Skip.test, bindArray, expr, expectedExpr) let testMacroEval = ( - bindArray: array<(string, InternalExpressionValue.expressionValue)>, + bindArray: array<(string, InternalExpressionValue.t)>, expr: T.expression, expectedValue: string, ) => testMacroEval_(Skip.test, bindArray, expr, expectedValue) @@ -76,12 +76,12 @@ module MySkip = { module MyOnly = { let testMacro = ( - bindArray: array<(string, InternalExpressionValue.expressionValue)>, + bindArray: array<(string, InternalExpressionValue.t)>, expr: T.expression, expectedExpr: string, ) => testMacro_(Only.test, bindArray, expr, expectedExpr) let testMacroEval = ( - bindArray: array<(string, InternalExpressionValue.expressionValue)>, + bindArray: array<(string, InternalExpressionValue.t)>, expr: T.expression, expectedValue: string, ) => testMacroEval_(Only.test, bindArray, expr, expectedValue) diff --git a/packages/squiggle-lang/src/rescript/FunctionRegistry/FunctionRegistry_Core.res b/packages/squiggle-lang/src/rescript/FunctionRegistry/FunctionRegistry_Core.res index e9d526bf..bbca7bc7 100644 --- a/packages/squiggle-lang/src/rescript/FunctionRegistry/FunctionRegistry_Core.res +++ b/packages/squiggle-lang/src/rescript/FunctionRegistry/FunctionRegistry_Core.res @@ -1,4 +1,4 @@ -type expressionValue = ReducerInterface_InternalExpressionValue.expressionValue +type internalExpressionValue = ReducerInterface_InternalExpressionValue.t /* Function Registry "Type". A type, without any other information. @@ -41,7 +41,7 @@ and frValueDistOrNumber = FRValueNumber(float) | FRValueDist(DistributionTypes.g type fnDefinition = { name: string, inputs: array, - run: (array, DistributionOperation.env) => result, + run: (array, DistributionOperation.env) => result, } type function = { @@ -73,7 +73,7 @@ module FRType = { | FRTypeAny => `any` } - let rec toFrValue = (r: expressionValue): option => + let rec toFrValue = (r: internalExpressionValue): option => switch r { | IEvNumber(f) => Some(FRValueNumber(f)) | IEvString(f) => Some(FRValueString(f)) @@ -89,7 +89,7 @@ module FRType = { | _ => None } - let rec matchWithExpressionValue = (t: t, r: expressionValue): option => + let rec matchWithExpressionValue = (t: t, r: internalExpressionValue): option => switch (t, r) { | (FRTypeAny, f) => toFrValue(f) | (FRTypeString, IEvString(f)) => Some(FRValueString(f)) @@ -125,7 +125,7 @@ module FRType = { | _ => None } - let rec matchReverse = (e: frValue): expressionValue => + let rec matchReverse = (e: frValue): internalExpressionValue => switch e { | FRValueNumber(f) => IEvNumber(f) | FRValueDistOrNumber(FRValueNumber(n)) => IEvNumber(n) @@ -153,9 +153,10 @@ module FRType = { | FRValueAny(f) => matchReverse(f) } - let matchWithExpressionValueArray = (inputs: array, args: array): option< - array, - > => { + let matchWithExpressionValueArray = ( + inputs: array, + args: array, + ): option> => { let isSameLength = E.A.length(inputs) == E.A.length(args) if !isSameLength { None @@ -206,14 +207,14 @@ module Matcher = { } module FnDefinition = { - let matchAssumingSameName = (f: fnDefinition, args: array) => { + let matchAssumingSameName = (f: fnDefinition, args: array) => { switch FRType.matchWithExpressionValueArray(f.inputs, args) { | Some(_) => MatchSimple.FullMatch | None => MatchSimple.SameNameDifferentArguments } } - let match = (f: fnDefinition, fnName: string, args: array) => { + let match = (f: fnDefinition, fnName: string, args: array) => { if f.name !== fnName { MatchSimple.DifferentName } else { @@ -226,7 +227,7 @@ module Matcher = { type definitionId = int type match = Match.t, definitionId> - let match = (f: function, fnName: string, args: array): match => { + let match = (f: function, fnName: string, args: array): match => { let matchedDefinition = () => E.A.getIndexBy(f.definitions, r => MatchSimple.isFullMatch(FnDefinition.match(r, fnName, args)) @@ -260,7 +261,7 @@ module Matcher = { } module Registry = { - let _findExactMatches = (r: registry, fnName: string, args: array) => { + let _findExactMatches = (r: registry, fnName: string, args: array) => { let functionMatchPairs = r->E.A2.fmap(l => (l, Function.match(l, fnName, args))) let fullMatch = functionMatchPairs->E.A.getBy(((_, match)) => Match.isFullMatch(match)) fullMatch->E.O.bind(((fn, match)) => @@ -271,7 +272,7 @@ module Matcher = { ) } - let _findNameMatches = (r: registry, fnName: string, args: array) => { + let _findNameMatches = (r: registry, fnName: string, args: array) => { let functionMatchPairs = r->E.A2.fmap(l => (l, Function.match(l, fnName, args))) let getNameMatches = functionMatchPairs @@ -290,7 +291,7 @@ module Matcher = { E.A.toNoneIfEmpty(matches) } - let findMatches = (r: registry, fnName: string, args: array) => { + let findMatches = (r: registry, fnName: string, args: array) => { switch _findExactMatches(r, fnName, args) { | Some(r) => Match.FullMatch(r) | None => @@ -318,7 +319,7 @@ module FnDefinition = { t.name ++ `(${inputs})` } - let run = (t: t, args: array, env: DistributionOperation.env) => { + let run = (t: t, args: array, env: DistributionOperation.env) => { let argValues = FRType.matchWithExpressionValueArray(t.inputs, args) switch argValues { | Some(values) => t.run(values, env) @@ -372,7 +373,7 @@ module Registry = { let matchAndRun = ( ~registry: registry, ~fnName: string, - ~args: array, + ~args: array, ~env: DistributionOperation.env, ) => { let matchToDef = m => Matcher.Registry.matchToDef(registry, m) diff --git a/packages/squiggle-lang/src/rescript/FunctionRegistry/FunctionRegistry_Library.res b/packages/squiggle-lang/src/rescript/FunctionRegistry/FunctionRegistry_Library.res index 68d06ae8..56315860 100644 --- a/packages/squiggle-lang/src/rescript/FunctionRegistry/FunctionRegistry_Library.res +++ b/packages/squiggle-lang/src/rescript/FunctionRegistry/FunctionRegistry_Library.res @@ -9,7 +9,7 @@ module Declaration = { ("inputs", FRTypeArray(FRTypeRecord([("min", FRTypeNumber), ("max", FRTypeNumber)]))), ]) - let fromExpressionValue = (e: frValue): result => { + let fromExpressionValue = (e: frValue): result => { switch FunctionRegistry_Helpers.Prepare.ToValueArray.Record.twoArgs([e]) { | Ok([FRValueLambda(lambda), FRValueArray(inputs)]) => { open FunctionRegistry_Helpers.Prepare diff --git a/packages/squiggle-lang/src/rescript/Reducer/Reducer.res b/packages/squiggle-lang/src/rescript/Reducer/Reducer.res index 34ca2595..bf8c89f9 100644 --- a/packages/squiggle-lang/src/rescript/Reducer/Reducer.res +++ b/packages/squiggle-lang/src/rescript/Reducer/Reducer.res @@ -1,13 +1,13 @@ module ErrorValue = Reducer_ErrorValue module Expression = Reducer_Expression -module ExternalExpressionValue = ReducerInterface_ExpressionValue +module ExternalExpressionValue = ReducerInterface_ExternalExpressionValue module InternalExpressionValue = ReducerInterface_InternalExpressionValue module Lambda = Reducer_Expression_Lambda type environment = ReducerInterface_InternalExpressionValue.environment type errorValue = Reducer_ErrorValue.errorValue -type expressionValue = ExternalExpressionValue.expressionValue -type externalBindings = ReducerInterface_ExpressionValue.externalBindings +type expressionValue = ExternalExpressionValue.t +type externalBindings = ReducerInterface_ExternalExpressionValue.externalBindings type lambdaValue = ExternalExpressionValue.lambdaValue let evaluate = Expression.evaluate diff --git a/packages/squiggle-lang/src/rescript/Reducer/Reducer.resi b/packages/squiggle-lang/src/rescript/Reducer/Reducer.resi index d4e40a63..bd0c43fb 100644 --- a/packages/squiggle-lang/src/rescript/Reducer/Reducer.resi +++ b/packages/squiggle-lang/src/rescript/Reducer/Reducer.resi @@ -2,27 +2,29 @@ module ErrorValue = Reducer_ErrorValue module Expression = Reducer_Expression @genType -type environment = ReducerInterface_ExpressionValue.environment +type environment = ReducerInterface_ExternalExpressionValue.environment @genType type errorValue = Reducer_ErrorValue.errorValue @genType -type expressionValue = ReducerInterface_ExpressionValue.expressionValue +type expressionValue = ReducerInterface_ExternalExpressionValue.t @genType -type externalBindings = ReducerInterface_ExpressionValue.externalBindings +type externalBindings = ReducerInterface_ExternalExpressionValue.externalBindings @genType -type lambdaValue = ReducerInterface_ExpressionValue.lambdaValue +type lambdaValue = ReducerInterface_ExternalExpressionValue.lambdaValue @genType let evaluateUsingOptions: ( - ~environment: option, - ~externalBindings: option, + ~environment: option, + ~externalBindings: option< + QuriSquiggleLang.ReducerInterface_ExternalExpressionValue.externalBindings, + >, string, ) => result @genType let evaluatePartialUsingExternalBindings: ( string, - QuriSquiggleLang.ReducerInterface_ExpressionValue.externalBindings, - QuriSquiggleLang.ReducerInterface_ExpressionValue.environment, + QuriSquiggleLang.ReducerInterface_ExternalExpressionValue.externalBindings, + QuriSquiggleLang.ReducerInterface_ExternalExpressionValue.environment, ) => result @genType let evaluate: string => result @@ -31,9 +33,9 @@ let parse: string => result @genType let foreignFunctionInterface: ( - QuriSquiggleLang.ReducerInterface_ExpressionValue.lambdaValue, - array, - QuriSquiggleLang.ReducerInterface_ExpressionValue.environment, + QuriSquiggleLang.ReducerInterface_ExternalExpressionValue.lambdaValue, + array, + QuriSquiggleLang.ReducerInterface_ExternalExpressionValue.environment, ) => result @genType diff --git a/packages/squiggle-lang/src/rescript/Reducer/Reducer_Category/Reducer_Category_Module.res b/packages/squiggle-lang/src/rescript/Reducer/Reducer_Category/Reducer_Category_Module.res index 58174063..584f9089 100644 --- a/packages/squiggle-lang/src/rescript/Reducer/Reducer_Category/Reducer_Category_Module.res +++ b/packages/squiggle-lang/src/rescript/Reducer/Reducer_Category/Reducer_Category_Module.res @@ -71,8 +71,8 @@ let emptyModule: t = NameSpace(Belt.Map.String.empty) let fromTypeScriptBindings = ReducerInterface_InternalExpressionValue.nameSpaceFromTypeScriptBindings let toTypeScriptBindings = ReducerInterface_InternalExpressionValue.nameSpaceToTypeScriptBindings -let toExpressionValue = (nameSpace: t): expressionValue => IEvModule(nameSpace) -let fromExpressionValue = (aValue: expressionValue): t => +let toExpressionValue = (nameSpace: t): internalExpressionValue => IEvModule(nameSpace) +let fromExpressionValue = (aValue: internalExpressionValue): t => switch aValue { | IEvModule(nameSpace) => nameSpace | _ => emptyModule @@ -101,7 +101,7 @@ let removeOther = (nameSpace: t, other: t): t => { } // -- Module definition -let define = (nameSpace: t, identifier: string, ev: expressionValue): t => { +let define = (nameSpace: t, identifier: string, ev: internalExpressionValue): t => { let NameSpace(container) = nameSpace Belt.Map.String.set(container, identifier, ev)->NameSpace // TODO build lambda for polymorphic functions here } diff --git a/packages/squiggle-lang/src/rescript/Reducer/Reducer_Category/Reducer_Category_Module_TypeChecker.res b/packages/squiggle-lang/src/rescript/Reducer/Reducer_Category/Reducer_Category_Module_TypeChecker.res index fb5d2ef3..957b0dc8 100644 --- a/packages/squiggle-lang/src/rescript/Reducer/Reducer_Category/Reducer_Category_Module_TypeChecker.res +++ b/packages/squiggle-lang/src/rescript/Reducer/Reducer_Category/Reducer_Category_Module_TypeChecker.res @@ -14,8 +14,3 @@ let isOfResolvedType = (aType, aValue) => { | _ => false } } - -// let compileTypeExpression = (typeExpression: string, bindings: ExpressionT.bindings, reducerFn: ExpressionT.reducerFn) => { -// statement = `type compiled=${typeExpression}` - -// } diff --git a/packages/squiggle-lang/src/rescript/Reducer/Reducer_Dispatch/Reducer_Dispatch_BuiltIn.res b/packages/squiggle-lang/src/rescript/Reducer/Reducer_Dispatch/Reducer_Dispatch_BuiltIn.res index f1664319..6012d179 100644 --- a/packages/squiggle-lang/src/rescript/Reducer/Reducer_Dispatch/Reducer_Dispatch_BuiltIn.res +++ b/packages/squiggle-lang/src/rescript/Reducer/Reducer_Dispatch/Reducer_Dispatch_BuiltIn.res @@ -41,7 +41,7 @@ let callInternal = (call: functionCall, environment, reducer: ExpressionT.reduce ->Ok } - let arrayAtIndex = (aValueArray: array, fIndex: float) => + let arrayAtIndex = (aValueArray: array, fIndex: float) => switch Belt.Array.get(aValueArray, Belt.Int.fromFloat(fIndex)) { | Some(value) => value->Ok | None => REArrayIndexNotFound("Array index not found", Belt.Int.fromFloat(fIndex))->Error @@ -53,7 +53,7 @@ let callInternal = (call: functionCall, environment, reducer: ExpressionT.reduce | None => RERecordPropertyNotFound("Module property not found", sIndex)->Error } - let recordAtIndex = (dict: Belt.Map.String.t, sIndex) => + let recordAtIndex = (dict: Belt.Map.String.t, sIndex) => switch Belt.Map.String.get(dict, sIndex) { | Some(value) => value->Ok | None => RERecordPropertyNotFound("Record property not found", sIndex)->Error @@ -69,24 +69,27 @@ let callInternal = (call: functionCall, environment, reducer: ExpressionT.reduce answer->IEvString->Ok } - let inspect = (value: expressionValue) => { + let inspect = (value: internalExpressionValue) => { Js.log(value->toString) value->Ok } - let inspectLabel = (value: expressionValue, label: string) => { + let inspectLabel = (value: internalExpressionValue, label: string) => { Js.log(`${label}: ${value->toString}`) value->Ok } - let doSetBindings = (bindings: nameSpace, symbol: string, value: expressionValue) => { + let doSetBindings = (bindings: nameSpace, symbol: string, value: internalExpressionValue) => { Module.set(bindings, symbol, value)->IEvModule->Ok } - let doSetTypeAliasBindings = (bindings: nameSpace, symbol: string, value: expressionValue) => - Module.setTypeAlias(bindings, symbol, value)->IEvModule->Ok + let doSetTypeAliasBindings = ( + bindings: nameSpace, + symbol: string, + value: internalExpressionValue, + ) => Module.setTypeAlias(bindings, symbol, value)->IEvModule->Ok - let doSetTypeOfBindings = (bindings: nameSpace, symbol: string, value: expressionValue) => + let doSetTypeOfBindings = (bindings: nameSpace, symbol: string, value: internalExpressionValue) => Module.setTypeOf(bindings, symbol, value)->IEvModule->Ok let doExportBindings = (bindings: nameSpace) => bindings->Module.toExpressionValue->Ok @@ -296,7 +299,7 @@ let callInternal = (call: functionCall, environment, reducer: ExpressionT.reduce Reducer uses Result monad while reducing expressions */ let dispatch = (call: functionCall, environment, reducer: ExpressionT.reducerFn): result< - expressionValue, + internalExpressionValue, errorValue, > => try { diff --git a/packages/squiggle-lang/src/rescript/Reducer/Reducer_Dispatch/Reducer_Dispatch_BuiltInMacros.res b/packages/squiggle-lang/src/rescript/Reducer/Reducer_Dispatch/Reducer_Dispatch_BuiltInMacros.res index 0431457e..1467f815 100644 --- a/packages/squiggle-lang/src/rescript/Reducer/Reducer_Dispatch/Reducer_Dispatch_BuiltInMacros.res +++ b/packages/squiggle-lang/src/rescript/Reducer/Reducer_Dispatch/Reducer_Dispatch_BuiltInMacros.res @@ -7,16 +7,15 @@ module BindingsReplacer = Reducer_Expression_BindingsReplacer module ErrorValue = Reducer_ErrorValue module ExpressionBuilder = Reducer_Expression_ExpressionBuilder module ExpressionT = Reducer_Expression_T -module ExpressionValue = ReducerInterface_InternalExpressionValue +module InternalExpressionValue = ReducerInterface_InternalExpressionValue module ExpressionWithContext = Reducer_ExpressionWithContext module Module = Reducer_Category_Module module Result = Belt.Result open Reducer_Expression_ExpressionBuilder -type environment = ExpressionValue.environment +type environment = InternalExpressionValue.environment type errorValue = ErrorValue.errorValue type expression = ExpressionT.expression -type expressionValue = ExpressionValue.expressionValue type expressionWithContext = ExpressionWithContext.expressionWithContext let dispatchMacroCall = ( @@ -137,11 +136,11 @@ let dispatchMacroCall = ( let rCondition = reduceExpression(blockCondition, bindings, environment) rCondition->Result.flatMap(conditionValue => switch conditionValue { - | ExpressionValue.IEvBool(false) => { + | InternalExpressionValue.IEvBool(false) => { let ifFalseBlock = eBlock(list{ifFalse}) ExpressionWithContext.withContext(ifFalseBlock, bindings)->Ok } - | ExpressionValue.IEvBool(true) => { + | InternalExpressionValue.IEvBool(true) => { let ifTrueBlock = eBlock(list{ifTrue}) ExpressionWithContext.withContext(ifTrueBlock, bindings)->Ok } diff --git a/packages/squiggle-lang/src/rescript/Reducer/Reducer_Expression/Reducer_Expression.res b/packages/squiggle-lang/src/rescript/Reducer/Reducer_Expression/Reducer_Expression.res index 99c8cdbb..4b551e38 100644 --- a/packages/squiggle-lang/src/rescript/Reducer/Reducer_Expression/Reducer_Expression.res +++ b/packages/squiggle-lang/src/rescript/Reducer/Reducer_Expression/Reducer_Expression.res @@ -13,9 +13,8 @@ module T = Reducer_Expression_T type environment = InternalExpressionValue.environment type errorValue = Reducer_ErrorValue.errorValue type expression = T.expression -type expressionValue = InternalExpressionValue.expressionValue -type externalExpressionValue = ReducerInterface_ExpressionValue.expressionValue -type tmpExternalBindings = InternalExpressionValue.tmpExternalBindings +type internalExpressionValue = InternalExpressionValue.t +type externalExpressionValue = ReducerInterface_ExternalExpressionValue.t type t = expression /* @@ -28,7 +27,7 @@ let parse = (peggyCode: string): result => Recursively evaluate/reduce the expression (Lisp AST) */ let rec reduceExpression = (expression: t, bindings: T.bindings, environment: environment): result< - expressionValue, + internalExpressionValue, 'e, > => { // Js.log(`reduce: ${T.toString(expression)} bindings: ${bindings->Bindings.toString}`) @@ -51,11 +50,11 @@ and reduceExpressionList = ( expressions: list, bindings: T.bindings, environment: environment, -): result => { - let racc: result, 'e> = expressions->Belt.List.reduceReverse(Ok(list{}), ( - racc, - each: expression, - ) => +): result => { + let racc: result< + list, + 'e, + > = expressions->Belt.List.reduceReverse(Ok(list{}), (racc, each: expression) => racc->Result.flatMap(acc => { each ->reduceExpression(bindings, environment) @@ -70,8 +69,8 @@ and reduceExpressionList = ( /* After reducing each level of expression(Lisp AST), we have a value list to evaluate */ -and reduceValueList = (valueList: list, environment): result< - expressionValue, +and reduceValueList = (valueList: list, environment): result< + internalExpressionValue, 'e, > => switch valueList { @@ -108,18 +107,18 @@ and reduceValueList = (valueList: list, environment): result< } let evalUsingBindingsExpression_ = (aExpression, bindings, environment): result< - expressionValue, + internalExpressionValue, 'e, > => reduceExpression(aExpression, bindings, environment) let evaluateUsingOptions = ( - ~environment: option, - ~externalBindings: option, + ~environment: option, + ~externalBindings: option, code: string, ): result => { let anEnvironment = Belt.Option.getWithDefault( environment, - ReducerInterface_ExpressionValue.defaultEnvironment, + ReducerInterface_ExternalExpressionValue.defaultEnvironment, ) let mergedBindings: InternalExpressionValue.nameSpace = Module.merge( @@ -142,9 +141,9 @@ let evaluate = (code: string): result => { } let evaluatePartialUsingExternalBindings = ( code: string, - externalBindings: ReducerInterface_ExpressionValue.externalBindings, - environment: ReducerInterface_ExpressionValue.environment, -): result => { + externalBindings: ReducerInterface_ExternalExpressionValue.externalBindings, + environment: ReducerInterface_ExternalExpressionValue.environment, +): result => { let rAnswer = evaluateUsingOptions( ~environment=Some(environment), ~externalBindings=Some(externalBindings), diff --git a/packages/squiggle-lang/src/rescript/Reducer/Reducer_Expression/Reducer_ExpressionWithContext.res b/packages/squiggle-lang/src/rescript/Reducer/Reducer_Expression/Reducer_ExpressionWithContext.res index defc6d02..1f6b18b7 100644 --- a/packages/squiggle-lang/src/rescript/Reducer/Reducer_Expression/Reducer_ExpressionWithContext.res +++ b/packages/squiggle-lang/src/rescript/Reducer/Reducer_Expression/Reducer_ExpressionWithContext.res @@ -1,16 +1,16 @@ module BindingsReplacer = Reducer_Expression_BindingsReplacer module ErrorValue = Reducer_ErrorValue module ExpressionT = Reducer_Expression_T -module ExpressionValue = ReducerInterface_InternalExpressionValue +module InternalExpressionValue = ReducerInterface_InternalExpressionValue module Result = Belt.Result module Module = Reducer_Category_Module type bindings = ExpressionT.bindings type context = bindings -type environment = ExpressionValue.environment +type environment = InternalExpressionValue.environment type errorValue = Reducer_ErrorValue.errorValue type expression = ExpressionT.expression -type expressionValue = ExpressionValue.expressionValue +type internalExpressionValue = InternalExpressionValue.t type reducerFn = ExpressionT.reducerFn type expressionWithContext = @@ -22,7 +22,7 @@ let callReducer = ( bindings: bindings, environment: environment, reducer: reducerFn, -): result => { +): result => { switch expressionWithContext { | ExpressionNoContext(expr) => // Js.log(`callReducer: bindings ${Bindings.toString(bindings)} expr ${ExpressionT.toString(expr)}`) @@ -42,7 +42,7 @@ let toString = expressionWithContext => | ExpressionWithContext(expr, context) => `${ExpressionT.toString(expr)} context: ${context ->Module.toExpressionValue - ->ExpressionValue.toString}` + ->InternalExpressionValue.toString}` } let toStringResult = rExpressionWithContext => diff --git a/packages/squiggle-lang/src/rescript/Reducer/Reducer_Expression/Reducer_Expression_BindingsReplacer.res b/packages/squiggle-lang/src/rescript/Reducer/Reducer_Expression/Reducer_Expression_BindingsReplacer.res index 43109f0d..e96ae4a1 100644 --- a/packages/squiggle-lang/src/rescript/Reducer/Reducer_Expression/Reducer_Expression_BindingsReplacer.res +++ b/packages/squiggle-lang/src/rescript/Reducer/Reducer_Expression/Reducer_Expression_BindingsReplacer.res @@ -1,14 +1,13 @@ module ErrorValue = Reducer_ErrorValue module ExpressionT = Reducer_Expression_T -module ExpressionValue = ReducerInterface_InternalExpressionValue +module InternalExpressionValue = ReducerInterface_InternalExpressionValue module Result = Belt.Result module Module = Reducer_Category_Module type errorValue = Reducer_ErrorValue.errorValue type expression = ExpressionT.expression -type expressionValue = ExpressionValue.expressionValue -type tmpExternalBindings = ReducerInterface_InternalExpressionValue.tmpExternalBindings -type externalBindings = ReducerInterface_ExpressionValue.externalBindings +type internalExpressionValue = InternalExpressionValue.t +type externalBindings = ReducerInterface_ExternalExpressionValue.externalBindings let isMacroName = (fName: string): bool => fName->Js.String2.startsWith("$$") @@ -41,14 +40,14 @@ and replaceSymbolsOnExpressionList = (bindings, list) => { ) racc->Result.map(acc => acc->ExpressionT.EList) } -and replaceSymbolOnValue = (bindings, evValue: expressionValue) => +and replaceSymbolOnValue = (bindings, evValue: internalExpressionValue) => switch evValue { | IEvSymbol(symbol) => Module.getWithDefault(bindings, symbol, evValue)->Ok | IEvCall(symbol) => Module.getWithDefault(bindings, symbol, evValue)->checkIfCallable | _ => evValue->Ok } -and checkIfCallable = (evValue: expressionValue) => +and checkIfCallable = (evValue: internalExpressionValue) => switch evValue { | IEvCall(_) | IEvLambda(_) => evValue->Ok - | _ => ErrorValue.RENotAFunction(ExpressionValue.toString(evValue))->Error + | _ => ErrorValue.RENotAFunction(InternalExpressionValue.toString(evValue))->Error } diff --git a/packages/squiggle-lang/src/rescript/Reducer/Reducer_Expression/Reducer_Expression_ExpressionBuilder.res b/packages/squiggle-lang/src/rescript/Reducer/Reducer_Expression/Reducer_Expression_ExpressionBuilder.res index 04d5fb7b..9fd4a34a 100644 --- a/packages/squiggle-lang/src/rescript/Reducer/Reducer_Expression/Reducer_Expression_ExpressionBuilder.res +++ b/packages/squiggle-lang/src/rescript/Reducer/Reducer_Expression/Reducer_Expression_ExpressionBuilder.res @@ -1,7 +1,7 @@ module BBindingsReplacer = Reducer_Expression_BindingsReplacer module BErrorValue = Reducer_ErrorValue module BExpressionT = Reducer_Expression_T -module BExpressionValue = ReducerInterface_InternalExpressionValue +module BInternalExpressionValue = ReducerInterface_InternalExpressionValue module BModule = Reducer_Category_Module type errorValue = BErrorValue.errorValue @@ -12,16 +12,17 @@ type internalCode = ReducerInterface_InternalExpressionValue.internalCode external castExpressionToInternalCode: expressionOrFFI => internalCode = "%identity" -let eArray = anArray => anArray->BExpressionValue.IEvArray->BExpressionT.EValue +let eArray = anArray => anArray->BInternalExpressionValue.IEvArray->BExpressionT.EValue -let eArrayString = anArray => anArray->BExpressionValue.IEvArrayString->BExpressionT.EValue +let eArrayString = anArray => anArray->BInternalExpressionValue.IEvArrayString->BExpressionT.EValue -let eBindings = (anArray: array<(string, BExpressionValue.expressionValue)>) => +let eBindings = (anArray: array<(string, BInternalExpressionValue.t)>) => anArray->BModule.fromArray->BModule.toExpressionValue->BExpressionT.EValue -let eBool = aBool => aBool->BExpressionValue.IEvBool->BExpressionT.EValue +let eBool = aBool => aBool->BInternalExpressionValue.IEvBool->BExpressionT.EValue -let eCall = (name: string): expression => name->BExpressionValue.IEvCall->BExpressionT.EValue +let eCall = (name: string): expression => + name->BInternalExpressionValue.IEvCall->BExpressionT.EValue let eFunction = (fName: string, lispArgs: list): expression => { let fn = fName->eCall @@ -30,10 +31,10 @@ let eFunction = (fName: string, lispArgs: list): expression => { let eLambda = ( parameters: array, - context: BExpressionValue.nameSpace, + context: BInternalExpressionValue.nameSpace, expr: expression, ) => { - BExpressionValue.IEvLambda({ + BInternalExpressionValue.IEvLambda({ parameters: parameters, context: context, body: NotFFI(expr)->castExpressionToInternalCode, @@ -42,27 +43,28 @@ let eLambda = ( let eLambdaFFI = (parameters: array, ffiFn: ffiFn) => { let context = BModule.emptyModule - BExpressionValue.IEvLambda({ + BInternalExpressionValue.IEvLambda({ parameters: parameters, context: context, body: FFI(ffiFn)->castExpressionToInternalCode, })->BExpressionT.EValue } -let eNumber = aNumber => aNumber->BExpressionValue.IEvNumber->BExpressionT.EValue +let eNumber = aNumber => aNumber->BInternalExpressionValue.IEvNumber->BExpressionT.EValue -let eRecord = aMap => aMap->BExpressionValue.IEvRecord->BExpressionT.EValue +let eRecord = aMap => aMap->BInternalExpressionValue.IEvRecord->BExpressionT.EValue -let eString = aString => aString->BExpressionValue.IEvString->BExpressionT.EValue +let eString = aString => aString->BInternalExpressionValue.IEvString->BExpressionT.EValue -let eSymbol = (name: string): expression => name->BExpressionValue.IEvSymbol->BExpressionT.EValue +let eSymbol = (name: string): expression => + name->BInternalExpressionValue.IEvSymbol->BExpressionT.EValue let eList = (list: list): expression => list->BExpressionT.EList let eBlock = (exprs: list): expression => eFunction("$$_block_$$", exprs) -let eModule = (nameSpace: BExpressionValue.nameSpace): expression => - nameSpace->BExpressionValue.IEvModule->BExpressionT.EValue +let eModule = (nameSpace: BInternalExpressionValue.nameSpace): expression => + nameSpace->BInternalExpressionValue.IEvModule->BExpressionT.EValue let eLetStatement = (symbol: string, valueExpression: expression): expression => eFunction("$_let_$", list{eSymbol(symbol), valueExpression}) @@ -80,7 +82,7 @@ let eBindExpressionDefault = (expression: expression): expression => eFunction("$$_bindExpression_$$", list{expression}) let eIdentifier = (name: string): expression => - name->BExpressionValue.IEvSymbol->BExpressionT.EValue + name->BInternalExpressionValue.IEvSymbol->BExpressionT.EValue let eTypeIdentifier = (name: string): expression => - name->BExpressionValue.IEvTypeIdentifier->BExpressionT.EValue + name->BInternalExpressionValue.IEvTypeIdentifier->BExpressionT.EValue diff --git a/packages/squiggle-lang/src/rescript/Reducer/Reducer_Expression/Reducer_Expression_Lambda.res b/packages/squiggle-lang/src/rescript/Reducer/Reducer_Expression/Reducer_Expression_Lambda.res index 6026a6d1..28bdbc02 100644 --- a/packages/squiggle-lang/src/rescript/Reducer/Reducer_Expression/Reducer_Expression_Lambda.res +++ b/packages/squiggle-lang/src/rescript/Reducer/Reducer_Expression/Reducer_Expression_Lambda.res @@ -9,13 +9,16 @@ module Result = Belt.Result type environment = ReducerInterface_InternalExpressionValue.environment type expression = ExpressionT.expression type expressionOrFFI = ExpressionT.expressionOrFFI -type expressionValue = ReducerInterface_InternalExpressionValue.expressionValue +type internalExpressionValue = ReducerInterface_InternalExpressionValue.t // type tmpExternalBindings = ReducerInterface_InternalExpressionValue.tmpExternalBindings type internalCode = ReducerInterface_InternalExpressionValue.internalCode external castInternalCodeToExpression: internalCode => expressionOrFFI = "%identity" -let checkArity = (lambdaValue: ExpressionValue.lambdaValue, args: list) => { +let checkArity = ( + lambdaValue: ExpressionValue.lambdaValue, + args: list, +) => { let argsLength = Belt.List.length(args) let parametersLength = Js.Array2.length(lambdaValue.parameters) if argsLength !== parametersLength { @@ -25,7 +28,7 @@ let checkArity = (lambdaValue: ExpressionValue.lambdaValue, args: list) => +let checkIfReduced = (args: list) => args->Belt.List.reduceReverse(Ok(list{}), (rAcc, arg) => rAcc->Result.flatMap(acc => switch arg { @@ -55,7 +58,7 @@ let applyParametersToLambda = ( args, environment, reducer: ExpressionT.reducerFn, -): result => { +): result => { checkArity(lambdaValue, args)->Result.flatMap(args => checkIfReduced(args)->Result.flatMap(args => { let exprOrFFI = castInternalCodeToExpression(lambdaValue.body) @@ -72,10 +75,10 @@ let doLambdaCall = (lambdaValue: ExpressionValue.lambdaValue, args, environment, let foreignFunctionInterface = ( lambdaValue: ExpressionValue.lambdaValue, - argArray: array, + argArray: array, environment: ExpressionValue.environment, reducer: ExpressionT.reducerFn, -): result => { +): result => { let args = argArray->Belt.List.fromArray applyParametersToLambda(lambdaValue, args, environment, reducer) } diff --git a/packages/squiggle-lang/src/rescript/Reducer/Reducer_Expression/Reducer_Expression_Macro.res b/packages/squiggle-lang/src/rescript/Reducer/Reducer_Expression/Reducer_Expression_Macro.res index 4ac95bd5..2598a9ed 100644 --- a/packages/squiggle-lang/src/rescript/Reducer/Reducer_Expression/Reducer_Expression_Macro.res +++ b/packages/squiggle-lang/src/rescript/Reducer/Reducer_Expression/Reducer_Expression_Macro.res @@ -1,11 +1,11 @@ module ExpressionT = Reducer_Expression_T -module ExpressionValue = ReducerInterface_InternalExpressionValue +module InternalExpressionValue = ReducerInterface_InternalExpressionValue module ExpressionWithContext = Reducer_ExpressionWithContext module Result = Belt.Result -type environment = ExpressionValue.environment +type environment = InternalExpressionValue.environment type expression = ExpressionT.expression -type expressionValue = ExpressionValue.expressionValue +type internalExpressionValue = InternalExpressionValue.t type expressionWithContext = ExpressionWithContext.expressionWithContext let expandMacroCall = ( @@ -26,7 +26,7 @@ let doMacroCall = ( bindings: ExpressionT.bindings, environment: environment, reduceExpression: ExpressionT.reducerFn, -): result => +): result => expandMacroCall( macroExpression, bindings, diff --git a/packages/squiggle-lang/src/rescript/Reducer/Reducer_Expression/Reducer_Expression_T.res b/packages/squiggle-lang/src/rescript/Reducer/Reducer_Expression/Reducer_Expression_T.res index 3af9a4f7..38910da2 100644 --- a/packages/squiggle-lang/src/rescript/Reducer/Reducer_Expression/Reducer_Expression_T.res +++ b/packages/squiggle-lang/src/rescript/Reducer/Reducer_Expression/Reducer_Expression_T.res @@ -9,19 +9,19 @@ module Extra = Reducer_Extra module InternalExpressionValue = ReducerInterface_InternalExpressionValue -type expressionValue = InternalExpressionValue.expressionValue +type internalExpressionValue = InternalExpressionValue.t type environment = ReducerInterface_InternalExpressionValue.environment type rec expression = | EList(list) // A list to map-reduce - | EValue(expressionValue) // Irreducible built-in value. Reducer should not know the internals. External libraries are responsible + | EValue(internalExpressionValue) // Irreducible built-in value. Reducer should not know the internals. External libraries are responsible and bindings = InternalExpressionValue.nameSpace type reducerFn = ( expression, bindings, environment, -) => result +) => result /* Converts the expression to String @@ -67,9 +67,9 @@ let inspectResult = (r: result): resu } type ffiFn = ( - array, + array, environment, -) => result +) => result type expressionOrFFI = | NotFFI(expression) diff --git a/packages/squiggle-lang/src/rescript/Reducer/Reducer_Js/Reducer_Js_Gate.res b/packages/squiggle-lang/src/rescript/Reducer/Reducer_Js/Reducer_Js_Gate.res index e13255e5..d7a267e2 100644 --- a/packages/squiggle-lang/src/rescript/Reducer/Reducer_Js/Reducer_Js_Gate.res +++ b/packages/squiggle-lang/src/rescript/Reducer/Reducer_Js/Reducer_Js_Gate.res @@ -8,7 +8,7 @@ external castString: unit => string = "%identity" /* As JavaScript returns us any type, we need to type check and cast type propertype before using it */ -let jsToIEv = (jsValue): result => +let jsToIEv = (jsValue): result => switch Js.typeof(jsValue) { | "boolean" => jsValue->castBool->IEvBool->Ok | "number" => jsValue->castNumber->IEvNumber->Ok diff --git a/packages/squiggle-lang/src/rescript/Reducer/Reducer_MathJs/Reducer_MathJs_Eval.res b/packages/squiggle-lang/src/rescript/Reducer/Reducer_MathJs/Reducer_MathJs_Eval.res index 6c8bc8e7..30cb2014 100644 --- a/packages/squiggle-lang/src/rescript/Reducer/Reducer_MathJs/Reducer_MathJs_Eval.res +++ b/packages/squiggle-lang/src/rescript/Reducer/Reducer_MathJs/Reducer_MathJs_Eval.res @@ -17,7 +17,7 @@ let eval__: string => 'a = %raw(`function (expr) { return {value: Mathjs.evaluat /* Call MathJs evaluate and return as a variant */ -let eval = (expr: string): result => { +let eval = (expr: string): result => { try { let answer = eval__(expr) answer["value"]->JavaScript.Gate.jsToIEv diff --git a/packages/squiggle-lang/src/rescript/ReducerInterface/ReducerInterface.res b/packages/squiggle-lang/src/rescript/ReducerInterface/ReducerInterface.res index 4ab6fd35..ef27130b 100644 --- a/packages/squiggle-lang/src/rescript/ReducerInterface/ReducerInterface.res +++ b/packages/squiggle-lang/src/rescript/ReducerInterface/ReducerInterface.res @@ -1,4 +1,4 @@ -module ExternalExpressionValue = ReducerInterface_ExpressionValue +module ExternalExpressionValue = ReducerInterface_ExternalExpressionValue module ExternalLibrary = ReducerInterface_ExternalLibrary module InternalExpressionValue = ReducerInterface_InternalExpressionValue module StdLib = ReducerInterface_StdLib diff --git a/packages/squiggle-lang/src/rescript/ReducerInterface/ReducerInterface_Date.res b/packages/squiggle-lang/src/rescript/ReducerInterface/ReducerInterface_Date.res index 3d5d095d..e84c26f4 100644 --- a/packages/squiggle-lang/src/rescript/ReducerInterface/ReducerInterface_Date.res +++ b/packages/squiggle-lang/src/rescript/ReducerInterface/ReducerInterface_Date.res @@ -1,27 +1,27 @@ -module EV = ReducerInterface_InternalExpressionValue -type expressionValue = EV.expressionValue +module IEV = ReducerInterface_InternalExpressionValue +type internalExpressionValue = IEV.t -let dispatch = (call: EV.functionCall, _: DistributionOperation.env): option< - result, +let dispatch = (call: IEV.functionCall, _: DistributionOperation.env): option< + result, > => { switch call { - | ("toString", [IEvDate(t)]) => EV.IEvString(DateTime.Date.toString(t))->Ok->Some + | ("toString", [IEvDate(t)]) => IEV.IEvString(DateTime.Date.toString(t))->Ok->Some | ("makeDateFromYear", [IEvNumber(year)]) => switch DateTime.Date.makeFromYear(year) { - | Ok(t) => EV.IEvDate(t)->Ok->Some + | Ok(t) => IEV.IEvDate(t)->Ok->Some | Error(e) => Reducer_ErrorValue.RETodo(e)->Error->Some } - | ("dateFromNumber", [IEvNumber(f)]) => EV.IEvDate(DateTime.Date.fromFloat(f))->Ok->Some - | ("toNumber", [IEvDate(f)]) => EV.IEvNumber(DateTime.Date.toFloat(f))->Ok->Some + | ("dateFromNumber", [IEvNumber(f)]) => IEV.IEvDate(DateTime.Date.fromFloat(f))->Ok->Some + | ("toNumber", [IEvDate(f)]) => IEV.IEvNumber(DateTime.Date.toFloat(f))->Ok->Some | ("subtract", [IEvDate(d1), IEvDate(d2)]) => switch DateTime.Date.subtract(d1, d2) { - | Ok(d) => EV.IEvTimeDuration(d)->Ok + | Ok(d) => IEV.IEvTimeDuration(d)->Ok | Error(e) => Error(RETodo(e)) }->Some | ("subtract", [IEvDate(d1), IEvTimeDuration(d2)]) => - EV.IEvDate(DateTime.Date.subtractDuration(d1, d2))->Ok->Some + IEV.IEvDate(DateTime.Date.subtractDuration(d1, d2))->Ok->Some | ("add", [IEvDate(d1), IEvTimeDuration(d2)]) => - EV.IEvDate(DateTime.Date.addDuration(d1, d2))->Ok->Some + IEV.IEvDate(DateTime.Date.addDuration(d1, d2))->Ok->Some | _ => None } } diff --git a/packages/squiggle-lang/src/rescript/ReducerInterface/ReducerInterface_Duration.res b/packages/squiggle-lang/src/rescript/ReducerInterface/ReducerInterface_Duration.res index f0b31ae2..838e4375 100644 --- a/packages/squiggle-lang/src/rescript/ReducerInterface/ReducerInterface_Duration.res +++ b/packages/squiggle-lang/src/rescript/ReducerInterface/ReducerInterface_Duration.res @@ -1,35 +1,36 @@ -module EV = ReducerInterface_InternalExpressionValue -type expressionValue = EV.expressionValue +module IEV = ReducerInterface_InternalExpressionValue +type internalExpressionValue = IEV.t -let dispatch = (call: EV.functionCall, _: DistributionOperation.env): option< - result, +let dispatch = (call: IEV.functionCall, _: DistributionOperation.env): option< + result, > => { switch call { - | ("toString", [IEvTimeDuration(t)]) => EV.IEvString(DateTime.Duration.toString(t))->Ok->Some - | ("minutes", [IEvNumber(f)]) => EV.IEvTimeDuration(DateTime.Duration.fromMinutes(f))->Ok->Some + | ("toString", [IEvTimeDuration(t)]) => IEV.IEvString(DateTime.Duration.toString(t))->Ok->Some + | ("minutes", [IEvNumber(f)]) => IEV.IEvTimeDuration(DateTime.Duration.fromMinutes(f))->Ok->Some | ("fromUnit_minutes", [IEvNumber(f)]) => - EV.IEvTimeDuration(DateTime.Duration.fromMinutes(f))->Ok->Some - | ("hours", [IEvNumber(f)]) => EV.IEvTimeDuration(DateTime.Duration.fromHours(f))->Ok->Some + IEV.IEvTimeDuration(DateTime.Duration.fromMinutes(f))->Ok->Some + | ("hours", [IEvNumber(f)]) => IEV.IEvTimeDuration(DateTime.Duration.fromHours(f))->Ok->Some | ("fromUnit_hours", [IEvNumber(f)]) => - EV.IEvTimeDuration(DateTime.Duration.fromHours(f))->Ok->Some - | ("days", [IEvNumber(f)]) => EV.IEvTimeDuration(DateTime.Duration.fromDays(f))->Ok->Some - | ("fromUnit_days", [IEvNumber(f)]) => EV.IEvTimeDuration(DateTime.Duration.fromDays(f))->Ok->Some - | ("years", [IEvNumber(f)]) => EV.IEvTimeDuration(DateTime.Duration.fromYears(f))->Ok->Some + IEV.IEvTimeDuration(DateTime.Duration.fromHours(f))->Ok->Some + | ("days", [IEvNumber(f)]) => IEV.IEvTimeDuration(DateTime.Duration.fromDays(f))->Ok->Some + | ("fromUnit_days", [IEvNumber(f)]) => + IEV.IEvTimeDuration(DateTime.Duration.fromDays(f))->Ok->Some + | ("years", [IEvNumber(f)]) => IEV.IEvTimeDuration(DateTime.Duration.fromYears(f))->Ok->Some | ("fromUnit_years", [IEvNumber(f)]) => - EV.IEvTimeDuration(DateTime.Duration.fromYears(f))->Ok->Some - | ("toHours", [IEvTimeDuration(f)]) => EV.IEvNumber(DateTime.Duration.toHours(f))->Ok->Some - | ("toMinutes", [IEvTimeDuration(f)]) => EV.IEvNumber(DateTime.Duration.toMinutes(f))->Ok->Some - | ("toDays", [IEvTimeDuration(f)]) => EV.IEvNumber(DateTime.Duration.toDays(f))->Ok->Some - | ("toYears", [IEvTimeDuration(f)]) => EV.IEvNumber(DateTime.Duration.toYears(f))->Ok->Some + IEV.IEvTimeDuration(DateTime.Duration.fromYears(f))->Ok->Some + | ("toHours", [IEvTimeDuration(f)]) => IEV.IEvNumber(DateTime.Duration.toHours(f))->Ok->Some + | ("toMinutes", [IEvTimeDuration(f)]) => IEV.IEvNumber(DateTime.Duration.toMinutes(f))->Ok->Some + | ("toDays", [IEvTimeDuration(f)]) => IEV.IEvNumber(DateTime.Duration.toDays(f))->Ok->Some + | ("toYears", [IEvTimeDuration(f)]) => IEV.IEvNumber(DateTime.Duration.toYears(f))->Ok->Some | ("add", [IEvTimeDuration(d1), IEvTimeDuration(d2)]) => - EV.IEvTimeDuration(DateTime.Duration.add(d1, d2))->Ok->Some + IEV.IEvTimeDuration(DateTime.Duration.add(d1, d2))->Ok->Some | ("subtract", [IEvTimeDuration(d1), IEvTimeDuration(d2)]) => - EV.IEvTimeDuration(DateTime.Duration.subtract(d1, d2))->Ok->Some + IEV.IEvTimeDuration(DateTime.Duration.subtract(d1, d2))->Ok->Some | ("multiply", [IEvTimeDuration(d1), IEvNumber(d2)]) => - EV.IEvTimeDuration(DateTime.Duration.multiply(d1, d2))->Ok->Some + IEV.IEvTimeDuration(DateTime.Duration.multiply(d1, d2))->Ok->Some | ("divide", [IEvTimeDuration(d1), IEvNumber(d2)]) => - EV.IEvTimeDuration(DateTime.Duration.divide(d1, d2))->Ok->Some - | ("divide", [IEvTimeDuration(d1), IEvTimeDuration(d2)]) => EV.IEvNumber(d1 /. d2)->Ok->Some + IEV.IEvTimeDuration(DateTime.Duration.divide(d1, d2))->Ok->Some + | ("divide", [IEvTimeDuration(d1), IEvTimeDuration(d2)]) => IEV.IEvNumber(d1 /. d2)->Ok->Some | _ => None } } diff --git a/packages/squiggle-lang/src/rescript/ReducerInterface/ReducerInterface_ExpressionValue.res b/packages/squiggle-lang/src/rescript/ReducerInterface/ReducerInterface_ExternalExpressionValue.res similarity index 87% rename from packages/squiggle-lang/src/rescript/ReducerInterface/ReducerInterface_ExpressionValue.res rename to packages/squiggle-lang/src/rescript/ReducerInterface/ReducerInterface_ExternalExpressionValue.res index 0f8b0249..bd5d8a35 100644 --- a/packages/squiggle-lang/src/rescript/ReducerInterface/ReducerInterface_ExpressionValue.res +++ b/packages/squiggle-lang/src/rescript/ReducerInterface/ReducerInterface_ExternalExpressionValue.res @@ -8,8 +8,8 @@ module ErrorValue = Reducer_ErrorValue type internalCode = Object @genType -type rec expressionValue = - | EvArray(array) +type rec externalExpressionValue = + | EvArray(array) | EvArrayString(array) | EvBool(bool) | EvCall(string) // External function call @@ -24,7 +24,7 @@ type rec expressionValue = | EvDeclaration(lambdaDeclaration) | EvTypeIdentifier(string) | EvModule(record) -and record = Js.Dict.t +and record = Js.Dict.t and externalBindings = record and lambdaValue = { parameters: array, @@ -33,7 +33,10 @@ and lambdaValue = { } and lambdaDeclaration = Declaration.declaration -type functionCall = (string, array) +@genType +type t = externalExpressionValue + +type functionCall = (string, array) let rec toString = aValue => switch aValue { @@ -68,7 +71,7 @@ and toStringRecord = aRecord => { `{${pairs}}` } -let argsToString = (args: array): string => { +let argsToString = (args: array): string => { args->Js.Array2.map(arg => arg->toString)->Js.Array2.toString } @@ -80,18 +83,6 @@ let toStringResult = x => | Error(m) => `Error(${ErrorValue.errorToString(m)})` } -// let toStringResultOkless = (codeResult: result): string => -// switch codeResult { -// | Ok(a) => toString(a) -// | Error(m) => `Error(${ErrorValue.errorToString(m)})` -// } - -// let toStringResultRecord = x => -// switch x { -// | Ok(a) => `Ok(${toStringRecord(a)})` -// | Error(m) => `Error(${ErrorValue.errorToString(m)})` -// } - @genType type environment = DistributionOperation.env diff --git a/packages/squiggle-lang/src/rescript/ReducerInterface/ReducerInterface_ExternalLibrary.res b/packages/squiggle-lang/src/rescript/ReducerInterface/ReducerInterface_ExternalLibrary.res index a003f7b5..3e6172c9 100644 --- a/packages/squiggle-lang/src/rescript/ReducerInterface/ReducerInterface_ExternalLibrary.res +++ b/packages/squiggle-lang/src/rescript/ReducerInterface/ReducerInterface_ExternalLibrary.res @@ -1,6 +1,6 @@ -module ExpressionValue = ReducerInterface_InternalExpressionValue +module InternalExpressionValue = ReducerInterface_InternalExpressionValue -type expressionValue = ExpressionValue.expressionValue +type internalExpressionValue = InternalExpressionValue.t // module Sample = { // // In real life real libraries should be somewhere else @@ -17,14 +17,14 @@ type expressionValue = ExpressionValue.expressionValue // I expect that it's important to build this first, so it doesn't get recalculated for each tryRegistry() call. let registry = FunctionRegistry_Library.registry -let tryRegistry = ((fnName, args): ExpressionValue.functionCall, env) => { +let tryRegistry = ((fnName, args): InternalExpressionValue.functionCall, env) => { FunctionRegistry_Core.Registry.matchAndRun(~registry, ~fnName, ~args, ~env)->E.O2.fmap( E.R2.errMap(_, s => Reducer_ErrorValue.RETodo(s)), ) } -let dispatch = (call: ExpressionValue.functionCall, environment, chain): result< - expressionValue, +let dispatch = (call: InternalExpressionValue.functionCall, environment, chain): result< + internalExpressionValue, 'e, > => { E.A.O.firstSomeFn([ diff --git a/packages/squiggle-lang/src/rescript/ReducerInterface/ReducerInterface_GenericDistribution.res b/packages/squiggle-lang/src/rescript/ReducerInterface/ReducerInterface_GenericDistribution.res index fd3ebadf..6ca0a440 100644 --- a/packages/squiggle-lang/src/rescript/ReducerInterface/ReducerInterface_GenericDistribution.res +++ b/packages/squiggle-lang/src/rescript/ReducerInterface/ReducerInterface_GenericDistribution.res @@ -1,5 +1,5 @@ -module ExpressionValue = ReducerInterface_InternalExpressionValue -type expressionValue = ExpressionValue.expressionValue +module IEV = ReducerInterface_InternalExpressionValue +type internalExpressionValue = IEV.t module Helpers = { let arithmeticMap = r => @@ -18,7 +18,7 @@ module Helpers = { | _ => #Multiply } - let catchAndConvertTwoArgsToDists = (args: array): option<( + let catchAndConvertTwoArgsToDists = (args: array): option<( DistributionTypes.genericDist, DistributionTypes.genericDist, )> => @@ -80,23 +80,28 @@ module Helpers = { )->DistributionOperation.run(~env) } - let parseNumber = (args: expressionValue): Belt.Result.t => + let parseNumber = (args: internalExpressionValue): Belt.Result.t => switch args { | IEvNumber(x) => Ok(x) | _ => Error("Not a number") } - let parseNumberArray = (ags: array): Belt.Result.t, string> => - E.A.fmap(parseNumber, ags) |> E.A.R.firstErrorOrOpen + let parseNumberArray = (ags: array): Belt.Result.t< + array, + string, + > => E.A.fmap(parseNumber, ags) |> E.A.R.firstErrorOrOpen - let parseDist = (args: expressionValue): Belt.Result.t => + let parseDist = (args: internalExpressionValue): Belt.Result.t< + DistributionTypes.genericDist, + string, + > => switch args { | IEvDistribution(x) => Ok(x) | IEvNumber(x) => Ok(GenericDist.fromFloat(x)) | _ => Error("Not a distribution") } - let parseDistributionArray = (ags: array): Belt.Result.t< + let parseDistributionArray = (ags: array): Belt.Result.t< array, string, > => E.A.fmap(parseDist, ags) |> E.A.R.firstErrorOrOpen @@ -122,7 +127,7 @@ module Helpers = { } let mixture = ( - args: array, + args: array, ~env: DistributionOperation.env, ): DistributionOperation.outputType => { let error = (err: string): DistributionOperation.outputType => @@ -194,10 +199,9 @@ module SymbolicConstructors = { } } -let dispatchToGenericOutput = ( - call: ExpressionValue.functionCall, - env: DistributionOperation.env, -): option => { +let dispatchToGenericOutput = (call: IEV.functionCall, env: DistributionOperation.env): option< + DistributionOperation.outputType, +> => { let (fnName, args) = call switch (fnName, args) { | ("triangular" as fnName, [IEvNumber(f1), IEvNumber(f2), IEvNumber(f3)]) => @@ -357,7 +361,7 @@ let dispatchToGenericOutput = ( } let genericOutputToReducerValue = (o: DistributionOperation.outputType): result< - expressionValue, + internalExpressionValue, Reducer_ErrorValue.errorValue, > => switch o { @@ -370,5 +374,5 @@ let genericOutputToReducerValue = (o: DistributionOperation.outputType): result< | GenDistError(err) => Error(REDistributionError(err)) } -let dispatch = (call: ExpressionValue.functionCall, environment) => +let dispatch = (call: IEV.functionCall, environment) => dispatchToGenericOutput(call, environment)->E.O2.fmap(genericOutputToReducerValue) diff --git a/packages/squiggle-lang/src/rescript/ReducerInterface/ReducerInterface_GenericDistribution.resi b/packages/squiggle-lang/src/rescript/ReducerInterface/ReducerInterface_GenericDistribution.resi index 1c7948ad..6cccdf17 100644 --- a/packages/squiggle-lang/src/rescript/ReducerInterface/ReducerInterface_GenericDistribution.resi +++ b/packages/squiggle-lang/src/rescript/ReducerInterface/ReducerInterface_GenericDistribution.resi @@ -1,6 +1,4 @@ let dispatch: ( ReducerInterface_InternalExpressionValue.functionCall, - ReducerInterface_ExpressionValue.environment, -) => option< - result, -> + ReducerInterface_ExternalExpressionValue.environment, +) => option> diff --git a/packages/squiggle-lang/src/rescript/ReducerInterface/ReducerInterface_InternalExpressionValue.res b/packages/squiggle-lang/src/rescript/ReducerInterface/ReducerInterface_InternalExpressionValue.res index 7290c12e..30de55dd 100644 --- a/packages/squiggle-lang/src/rescript/ReducerInterface/ReducerInterface_InternalExpressionValue.res +++ b/packages/squiggle-lang/src/rescript/ReducerInterface/ReducerInterface_InternalExpressionValue.res @@ -1,13 +1,13 @@ module ErrorValue = Reducer_ErrorValue -module ExternalExpressionValue = ReducerInterface_ExpressionValue +module ExternalExpressionValue = ReducerInterface_ExternalExpressionValue module Extra_Array = Reducer_Extra_Array type internalCode = ExternalExpressionValue.internalCode type environment = ExternalExpressionValue.environment let defaultEnvironment = ExternalExpressionValue.defaultEnvironment -type rec expressionValue = - | IEvArray(array) // FIXME: Convert +type rec t = + | IEvArray(array) // FIXME: Convert | IEvArrayString(array) // FIXME: Convert | IEvBool(bool) | IEvCall(string) // External function call @@ -15,16 +15,15 @@ type rec expressionValue = | IEvDeclaration(lambdaDeclaration) | IEvDistribution(DistributionTypes.genericDist) | IEvLambda(lambdaValue) - | IEvModule(nameSpace) // FIXME: Convert + | IEvModule(nameSpace) | IEvNumber(float) | IEvRecord(map) | IEvString(string) | IEvSymbol(string) | IEvTimeDuration(float) | IEvTypeIdentifier(string) -and map = Belt.Map.String.t -and nameSpace = NameSpace(Belt.Map.String.t) -and tmpExternalBindings = Js.Dict.t // FIXME: Remove +and map = Belt.Map.String.t +and nameSpace = NameSpace(Belt.Map.String.t) and lambdaValue = { parameters: array, context: nameSpace, @@ -32,9 +31,9 @@ and lambdaValue = { } and lambdaDeclaration = Declaration.declaration -type t = expressionValue +type internalExpressionValue = t -type functionCall = (string, array) +type functionCall = (string, array) let rec toString = aValue => switch aValue { @@ -92,7 +91,7 @@ let toStringWithType = aValue => | IEvModule(_) => `Module::${toString(aValue)}` } -let argsToString = (args: array): string => { +let argsToString = (args: array): string => { args->Js.Array2.map(arg => arg->toString)->Js.Array2.toString } @@ -104,7 +103,7 @@ let toStringResult = x => | Error(m) => `Error(${ErrorValue.errorToString(m)})` } -let toStringResultOkless = (codeResult: result): string => +let toStringResultOkless = (codeResult: result): string => switch codeResult { | Ok(a) => toString(a) | Error(m) => `Error(${ErrorValue.errorToString(m)})` @@ -116,7 +115,7 @@ let toStringResultRecord = x => | Error(m) => `Error(${ErrorValue.errorToString(m)})` } -type expressionValueType = +type internalExpressionValueType = | EvtArray | EvtArrayString | EvtBool @@ -133,9 +132,9 @@ type expressionValueType = | EvtTypeIdentifier | EvtModule -type functionCallSignature = CallSignature(string, array) +type functionCallSignature = CallSignature(string, array) type functionDefinitionSignature = - FunctionDefinitionSignature(functionCallSignature, expressionValueType) + FunctionDefinitionSignature(functionCallSignature, internalExpressionValueType) let valueToValueType = value => switch value { @@ -161,7 +160,7 @@ let functionCallToCallSignature = (functionCall: functionCall): functionCallSign CallSignature(fn, args->Js.Array2.map(valueToValueType)) } -let valueTypeToString = (valueType: expressionValueType): string => +let valueTypeToString = (valueType: internalExpressionValueType): string => switch valueType { | EvtArray => `Array` | EvtArrayString => `ArrayString` @@ -185,7 +184,7 @@ let functionCallSignatureToString = (functionCallSignature: functionCallSignatur `${fn}(${args->Js.Array2.map(valueTypeToString)->Js.Array2.toString})` } -let rec toExternal = (iev: expressionValue): ExternalExpressionValue.expressionValue => { +let rec toExternal = (iev: t): ExternalExpressionValue.t => { switch iev { | IEvArray(v) => v->Belt.Array.map(e => toExternal(e))->EvArray | IEvArrayString(v) => EvArrayString(v) @@ -218,12 +217,12 @@ and lambdaValueToExternal = v => { } and nameSpaceToTypeScriptBindings = ( nameSpace: nameSpace, -): ReducerInterface_ExpressionValue.externalBindings => { +): ReducerInterface_ExternalExpressionValue.externalBindings => { let NameSpace(container) = nameSpace Belt.Map.String.map(container, e => toExternal(e))->Belt.Map.String.toArray->Js.Dict.fromArray } -let rec toInternal = (ev: ExternalExpressionValue.expressionValue): expressionValue => { +let rec toInternal = (ev: ExternalExpressionValue.t): t => { switch ev { | EvArray(v) => v->Belt.Array.map(e => toInternal(e))->IEvArray | EvArrayString(v) => IEvArrayString(v) @@ -255,6 +254,6 @@ and lambdaValueToInternal = v => { {parameters: p, context: c, body: b} } and nameSpaceFromTypeScriptBindings = ( - r: ReducerInterface_ExpressionValue.externalBindings, + r: ReducerInterface_ExternalExpressionValue.externalBindings, ): nameSpace => r->Js.Dict.entries->Belt.Map.String.fromArray->Belt.Map.String.map(e => toInternal(e))->NameSpace diff --git a/packages/squiggle-lang/src/rescript/ReducerInterface/ReducerInterface_Number.res b/packages/squiggle-lang/src/rescript/ReducerInterface/ReducerInterface_Number.res index 4787880d..900e6a2f 100644 --- a/packages/squiggle-lang/src/rescript/ReducerInterface/ReducerInterface_Number.res +++ b/packages/squiggle-lang/src/rescript/ReducerInterface/ReducerInterface_Number.res @@ -1,5 +1,5 @@ -module EV = ReducerInterface_InternalExpressionValue -type expressionValue = EV.expressionValue +module IEV = ReducerInterface_InternalExpressionValue +type internalExpressionValue = IEV.t module ScientificUnit = { let nameToMultiplier = str => @@ -24,8 +24,8 @@ module ScientificUnit = { } } -let dispatch = (call: EV.functionCall, _: DistributionOperation.env): option< - result, +let dispatch = (call: IEV.functionCall, _: DistributionOperation.env): option< + result, > => { switch call { | ( @@ -39,7 +39,7 @@ let dispatch = (call: EV.functionCall, _: DistributionOperation.env): option< | "fromUnit_P") as op, [IEvNumber(f)], ) => - op->ScientificUnit.getMultiplier->E.O2.fmap(multiplier => EV.IEvNumber(f *. multiplier)->Ok) + op->ScientificUnit.getMultiplier->E.O2.fmap(multiplier => IEV.IEvNumber(f *. multiplier)->Ok) | _ => None } } diff --git a/packages/squiggle-lang/src/rescript/TypescriptInterface.res b/packages/squiggle-lang/src/rescript/TypescriptInterface.res index 932edaa1..387c5526 100644 --- a/packages/squiggle-lang/src/rescript/TypescriptInterface.res +++ b/packages/squiggle-lang/src/rescript/TypescriptInterface.res @@ -47,10 +47,10 @@ let evaluatePartialUsingExternalBindings = Reducer.evaluatePartialUsingExternalB type externalBindings = Reducer.externalBindings @genType -type expressionValue = ReducerInterface_ExpressionValue.expressionValue +type expressionValue = ReducerInterface_ExternalExpressionValue.t @genType -type recordEV = ReducerInterface_ExpressionValue.record +type recordEV = ReducerInterface_ExternalExpressionValue.record @genType type errorValue = Reducer_ErrorValue.errorValue @@ -74,19 +74,19 @@ let errorValueToString = Reducer_ErrorValue.errorToString let distributionErrorToString = DistributionTypes.Error.toString @genType -type lambdaValue = ReducerInterface_ExpressionValue.lambdaValue +type lambdaValue = ReducerInterface_ExternalExpressionValue.lambdaValue @genType -type lambdaDeclaration = ReducerInterface_ExpressionValue.lambdaDeclaration +type lambdaDeclaration = ReducerInterface_ExternalExpressionValue.lambdaDeclaration @genType let defaultSamplingEnv = DistributionOperation.defaultEnv @genType -type environment = ReducerInterface_ExpressionValue.environment +type environment = ReducerInterface_ExternalExpressionValue.environment @genType -let defaultEnvironment = ReducerInterface_ExpressionValue.defaultEnvironment +let defaultEnvironment = ReducerInterface_ExternalExpressionValue.defaultEnvironment @genType let foreignFunctionInterface = Reducer.foreignFunctionInterface From 3b84c2892cf7416f54ba323d738a78a7ea8a5b40 Mon Sep 17 00:00:00 2001 From: Sam Nolan Date: Fri, 24 Jun 2022 10:53:53 +0000 Subject: [PATCH 12/12] Fix typescript errors (start raw decoding early) --- packages/squiggle-lang/src/js/index.ts | 31 ++++++-------------------- 1 file changed, 7 insertions(+), 24 deletions(-) diff --git a/packages/squiggle-lang/src/js/index.ts b/packages/squiggle-lang/src/js/index.ts index 592de8e3..7a246c41 100644 --- a/packages/squiggle-lang/src/js/index.ts +++ b/packages/squiggle-lang/src/js/index.ts @@ -129,30 +129,13 @@ function createTsExport( // case return tag( "array", - x.value.map((arrayItem): squiggleExpression => { - switch (arrayItem.tag) { - case "EvRecord": - return tag( - "record", - _.mapValues(arrayItem.value, (recordValue: unknown) => - convertRawToTypescript( - recordValue as rescriptExport, - environment - ) - ) - ); - case "EvArray": - let y = arrayItem.value as unknown as rescriptExport[]; - return tag( - "array", - y.map((childArrayItem) => - convertRawToTypescript(childArrayItem, environment) - ) - ); - default: - return createTsExport(arrayItem, environment); - } - }) + x.value.map( + (arrayItem): squiggleExpression => + convertRawToTypescript( + arrayItem as unknown as rescriptExport, + environment + ) + ) ); case "EvArrayString": return tag("arraystring", x.value);