This commit is contained in:
Joeri Exelmans 2025-03-24 08:25:53 +01:00
parent 3596e01c28
commit 6af72e525c
3 changed files with 31 additions and 5 deletions

14
main.js
View file

@ -7,6 +7,7 @@ import { Type } from './type.js';
class Context {
constructor(mod) {
this.mod = mod;
this.types = new DefaultMap(() => new Set()); // instance to type
this.instances = new DefaultMap(() => new Set()); // type to instance
@ -26,11 +27,18 @@ class Context {
this.functionsTo .getdefault(t.params[1], true).add(fn);
}
}
}
}
}
addToCtx({i, t}) {
return new Context({l:[
...this.mod.l,
{i, t},
]})
}
}
const ctx = new Context({l:[
let ctx = new Context({l:[
...ModuleStd.l,
...ModulePoint.l,
]});
@ -257,6 +265,8 @@ async function transform(i, t) {
async function apply(i, fn, fnT) {
const result = fn(i);
const resultType = fnT.params[1];
// update context with newly produced value
ctx = ctx.addToCtx({i: result, t: resultType});
const {strI: strResult, strT: strResultType} = prettyIT({i: result, t: resultType});
console.log(`result = ${strResult} :: ${strResultType}`);
return instanceOrTypeOrFnOptions({i: result, t: resultType});