progress with versioning lib
This commit is contained in:
parent
3623988f86
commit
618cdf7314
7 changed files with 236 additions and 91 deletions
|
|
@ -1,10 +1,10 @@
|
|||
import { eqType } from "../primitives/type.js";
|
||||
import { isTypeVar } from "../primitives/typevars.js";
|
||||
import { prettyT } from "../util/pretty.js";
|
||||
import { pretty, prettyT } from "../util/pretty.js";
|
||||
import { indent, zip } from "../util/util.js";
|
||||
import { compareStrings } from "../compare/primitives.js";
|
||||
import { getHumanReadableName } from "../primitives/symbol.js";
|
||||
import { occurring, substitute } from "./generics.js";
|
||||
import { occurring, recomputeTypeVars, substitute } from "./generics.js";
|
||||
|
||||
export const prettyS = (typevar, type) => {
|
||||
return `${getHumanReadableName(typevar)} ↦ ${prettyT(type)}`;
|
||||
|
|
@ -180,3 +180,13 @@ export const unify = (typeA, typeB) => {
|
|||
throw e;
|
||||
}
|
||||
};
|
||||
|
||||
export const assignFn = (functionType, parameterType) => {
|
||||
const [rFunctionType, rParameterType] = recomputeTypeVars([functionType, parameterType]);
|
||||
console.log(pretty(rFunctionType));
|
||||
const rFunctionInType = rFunctionType.params[0](rFunctionType);
|
||||
const rFunctionOutType = rFunctionType.params[1](rFunctionType);
|
||||
const subs = unify(rFunctionInType, rParameterType);
|
||||
const result = substitute(rFunctionOutType, subs);
|
||||
return recomputeTypeVars([result])[0];
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue