add export

This commit is contained in:
Joeri Exelmans 2025-05-19 19:39:37 +02:00
parent 4fcfea409a
commit 8cfbd6116f
2 changed files with 11 additions and 3 deletions

View file

@ -93,16 +93,22 @@ export const assignFn = (funType, paramType, skip=0) => {
// Ensures that no type variables overlap
export const recomputeTypeVars = (types, skip=0) => {
return recomputeTypeVarsWithInverse(types, skip)[0];
};
export const recomputeTypeVarsWithInverse = (types, skip=0) => {
let nextIdx = skip;
return types.map(type => {
const inverse = new Map();
return [types.map(type => {
const substitutions = new Map();
const typeVars = occurring(type);
for (const typeVar of typeVars) {
const idx = nextIdx++;
if (typeVar !== UNBOUND_SYMBOLS[idx]) {
substitutions.set(typeVar, TYPE_VARS[idx]);
inverse.set(UNBOUND_SYMBOLS[idx], typeVar);
}
}
return substitute(type, substitutions);
});
};
}), inverse];
}