diff --git a/package.json b/package.json index 1dcef48..74b843b 100644 --- a/package.json +++ b/package.json @@ -12,7 +12,7 @@ "dependencies": { "@fontsource-variable/inconsolata": "^5.2.5", "@fontsource-variable/roboto": "^5.2.5", - "dope2": "git+https://deemz.org/git/joeri/dope2.git", + "dope2": "git+https://deemz.org/git/research/dope2.git", "react": "^19.1.0", "react-dom": "^19.1.0" }, diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index 2e207c5..ebd7f26 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -15,8 +15,8 @@ importers: specifier: ^5.2.5 version: 5.2.5 dope2: - specifier: git+https://deemz.org/git/joeri/dope2.git - version: git+https://deemz.org/git/joeri/dope2.git#5b13fbb047bedecc711c48b7fcead8b99a3490c3 + specifier: git+https://deemz.org/git/research/dope2.git + version: git+https://deemz.org/git/research/dope2.git#3623988f86cb6be1b640430be3bde50072ce66f4 react: specifier: ^19.1.0 version: 19.1.0 @@ -461,12 +461,15 @@ packages: '@swc/counter@0.1.3': resolution: {integrity: sha512-e2BR4lsJkkRlKZ/qCHPw9ZaSxc0MVUd7gtbtaB7aMvHeJVYe8sOB8DBZkP2DtISHGSku9sCK6T6cnY0CtXrOCQ==} - '@swc/types@0.1.21': - resolution: {integrity: sha512-2YEtj5HJVbKivud9N4bpPBAyZhj4S2Ipe5LkUG94alTpr7in/GU/EARgPAd3BwU+YOmFVJC2+kjqhGRi3r0ZpQ==} + '@swc/types@0.1.22': + resolution: {integrity: sha512-D13mY/ZA4PPEFSy6acki9eBT/3WgjMoRqNcdpIvjaYLQ44Xk5BdaL7UkDxAh6Z9UOe7tCCp67BVmZCojYp9owg==} '@types/estree@1.0.7': resolution: {integrity: sha512-w28IoSUCJpidD/TGviZwwMJckNESJZXFu7NBZ5YJ4mEUnNraUn9Pm8HSZm/jDF1pDWYKspWE7oVphigUPRakIQ==} + '@types/estree@1.0.8': + resolution: {integrity: sha512-dWHzHa2WqEXI/O1E9OjrocMTKJl2mSrEolh1Iomrv6U+JuNwaHXsXx9bLu5gG7BUWFIN0skIQJQ/L1rIex4X6w==} + '@types/json-schema@7.0.15': resolution: {integrity: sha512-5+fP8P8MFNC+AyZCDxrB2pkZFPGzqQWUzpSeuuVLvm8VMcorNYavBqoFcxK8bQz4Qsbn4oUEEem4wDLfcysGHA==} @@ -612,8 +615,8 @@ packages: deep-is@0.1.4: resolution: {integrity: sha512-oIPzksmTg4/MriiaYGO+okXDT7ztn/w3Eptv/+gSIdMdKsJo0u4CfYNFJPy+4SKMuCqGw2wxnA+URMg3t8a/bQ==} - dope2@git+https://deemz.org/git/joeri/dope2.git#5b13fbb047bedecc711c48b7fcead8b99a3490c3: - resolution: {commit: 5b13fbb047bedecc711c48b7fcead8b99a3490c3, repo: https://deemz.org/git/joeri/dope2.git, type: git} + dope2@git+https://deemz.org/git/research/dope2.git#3623988f86cb6be1b640430be3bde50072ce66f4: + resolution: {commit: 3623988f86cb6be1b640430be3bde50072ce66f4, repo: https://deemz.org/git/research/dope2.git, type: git} version: 0.0.1 esbuild@0.25.5: @@ -1270,7 +1273,7 @@ snapshots: '@swc/core@1.11.31': dependencies: '@swc/counter': 0.1.3 - '@swc/types': 0.1.21 + '@swc/types': 0.1.22 optionalDependencies: '@swc/core-darwin-arm64': 1.11.31 '@swc/core-darwin-x64': 1.11.31 @@ -1285,12 +1288,14 @@ snapshots: '@swc/counter@0.1.3': {} - '@swc/types@0.1.21': + '@swc/types@0.1.22': dependencies: '@swc/counter': 0.1.3 '@types/estree@1.0.7': {} + '@types/estree@1.0.8': {} + '@types/json-schema@7.0.15': {} '@types/react-dom@19.1.6(@types/react@19.1.6)': @@ -1464,7 +1469,7 @@ snapshots: deep-is@0.1.4: {} - dope2@git+https://deemz.org/git/joeri/dope2.git#5b13fbb047bedecc711c48b7fcead8b99a3490c3: + dope2@git+https://deemz.org/git/research/dope2.git#3623988f86cb6be1b640430be3bde50072ce66f4: dependencies: functional-red-black-tree: 1.0.1 @@ -1528,7 +1533,7 @@ snapshots: '@humanfs/node': 0.16.6 '@humanwhocodes/module-importer': 1.0.1 '@humanwhocodes/retry': 0.4.3 - '@types/estree': 1.0.7 + '@types/estree': 1.0.8 '@types/json-schema': 7.0.15 ajv: 6.12.6 chalk: 4.1.2 diff --git a/src/component/app/environment.ts b/src/component/app/environment.ts index 3f71fc6..3163523 100644 --- a/src/component/app/environment.ts +++ b/src/component/app/environment.ts @@ -1,4 +1,4 @@ -import { getDefaultTypeParser, module2Env, ModuleStd } from "dope2"; +import { getDefaultTypeParser, list, ModuleStd, trie } from "dope2"; // import type { Dynamic, Environment } from "./eval"; import type { StaticEnvironment } from "../../eval/infer_type"; @@ -7,15 +7,18 @@ export const functionWith4Params = i => j => k => l => i+j+k+l; const mkType = getDefaultTypeParser(); +const mod = ModuleStd.concat([ + ["true", {i: true, t: mkType("Bool")}], + ["false", {i: false, t: mkType("Bool")}], + ["leqZero", {i: n => leq => otherwise => (n<=0)?leq({}):otherwise({}), t: mkType("Int -> (Unit -> a) -> (Unit -> a) -> a")}], + ["functionWith3Params", { i: functionWith3Params, t: mkType("Int->Int->Int->Int") }], + ["functionWith4Params", { i: functionWith4Params, t: mkType("Int->Int->Int->Int->Int")}] +]).map(([name, {i,t}]) => [name, { kind: "value", i, t, unification: new Map() }] as [string, any]); + export const extendedEnv: StaticEnvironment = { - names: module2Env(ModuleStd.concat([ - ["true", {i: true, t: mkType("Bool")}], - ["false", {i: false, t: mkType("Bool")}], - ["leqZero", {i: n => leq => otherwise => (n<=0)?leq({}):otherwise({}), t: mkType("Int -> (Unit -> a) -> (Unit -> a) -> a")}], - ["functionWith3Params", { i: functionWith3Params, t: mkType("Int->Int->Int->Int") }], - ["functionWith4Params", { i: functionWith4Params, t: mkType("Int->Int->Int->Int->Int")}] - ]).map(([name, {i,t}]) => [name, { kind: "value", i, t, unification: new Map() }] as [string, any]) - ).name2dyn, - // nextFreeTypeVar: 0, + names: list.fold + (acc => ([name, dynamic]) => trie.insert(acc)(name)(dynamic)) + (trie.emptyTrie) + (mod), typevars: new Set(), }; diff --git a/src/component/expr/LambdaBlock.tsx b/src/component/expr/LambdaBlock.tsx index 292e4eb..a3c1546 100644 --- a/src/component/expr/LambdaBlock.tsx +++ b/src/component/expr/LambdaBlock.tsx @@ -49,7 +49,7 @@ export function LambdaBlock({state, setState, score, typeInfo, evalResult}: Lamb  ::    - : + .  
- + ; }