rename function + update index
This commit is contained in:
parent
c1da60b71c
commit
28909d88b9
3 changed files with 10 additions and 4 deletions
6
index.d.ts
vendored
6
index.d.ts
vendored
|
|
@ -348,6 +348,12 @@ export function sumType(typeParam: any): any;
|
||||||
|
|
||||||
export function unify(fType: any, aType: any): any;
|
export function unify(fType: any, aType: any): any;
|
||||||
|
|
||||||
|
export function unifyLL(typeA: any, typeB: any): any;
|
||||||
|
|
||||||
|
export function mergeUnifications(uniA: any, uniB: any): any;
|
||||||
|
|
||||||
|
export function reduceUnification(uni: any): any;
|
||||||
|
|
||||||
export function zip(a: any, b: any): any;
|
export function zip(a: any, b: any): any;
|
||||||
|
|
||||||
export namespace dict {
|
export namespace dict {
|
||||||
|
|
|
||||||
|
|
@ -4,7 +4,7 @@ import { getSymbol } from "../primitives/type.js";
|
||||||
import { isTypeVar, TYPE_VARS, UNBOUND_SYMBOLS } from "../primitives/typevars.js";
|
import { isTypeVar, TYPE_VARS, UNBOUND_SYMBOLS } from "../primitives/typevars.js";
|
||||||
import { symbolFunction } from "../structures/type_constructors.js";
|
import { symbolFunction } from "../structures/type_constructors.js";
|
||||||
import { prettyT } from '../util/pretty.js';
|
import { prettyT } from '../util/pretty.js';
|
||||||
import { reduceUnif, unifyLL } from "./low_level.js";
|
import { reduceUnification, unifyLL } from "./low_level.js";
|
||||||
|
|
||||||
// helper for creating generic types
|
// helper for creating generic types
|
||||||
// for instance, the type:
|
// for instance, the type:
|
||||||
|
|
@ -41,7 +41,7 @@ export class NotAFunctionError extends Error {}
|
||||||
export const unify = (fType, aType) => {
|
export const unify = (fType, aType) => {
|
||||||
[fType, aType] = recomputeTypeVars([fType, aType]);
|
[fType, aType] = recomputeTypeVars([fType, aType]);
|
||||||
const unification = unifyLL(fType, aType);
|
const unification = unifyLL(fType, aType);
|
||||||
const substitutions = reduceUnif(unification);
|
const substitutions = reduceUnification(unification);
|
||||||
const uType = substitute(fType, // or aType, doesn't matter here
|
const uType = substitute(fType, // or aType, doesn't matter here
|
||||||
substitutions);
|
substitutions);
|
||||||
return recomputeTypeVars([uType])[0];
|
return recomputeTypeVars([uType])[0];
|
||||||
|
|
@ -83,7 +83,7 @@ export const assignFn = (funType, paramType, skip=0) => {
|
||||||
const unifInType1 = unifyLL(inType1, paramType1);
|
const unifInType1 = unifyLL(inType1, paramType1);
|
||||||
|
|
||||||
// Step 4: Substitute typevars in output type
|
// Step 4: Substitute typevars in output type
|
||||||
const substInType1 = reduceUnif(unifInType1);
|
const substInType1 = reduceUnification(unifInType1);
|
||||||
const reducedOutType1 = substitute(outType1, substInType1);
|
const reducedOutType1 = substitute(outType1, substInType1);
|
||||||
|
|
||||||
// Step 5: 'Normalize' output type
|
// Step 5: 'Normalize' output type
|
||||||
|
|
|
||||||
|
|
@ -130,7 +130,7 @@ export const reduce = (setOfTypes) => {
|
||||||
|
|
||||||
// Reduce a unification to a mapping: {symbol => Type}
|
// Reduce a unification to a mapping: {symbol => Type}
|
||||||
// this mapping can then be used for substituting the typevars (=symbols) in a type by concrete types
|
// this mapping can then be used for substituting the typevars (=symbols) in a type by concrete types
|
||||||
export const reduceUnif = (unif) => {
|
export const reduceUnification = (unif) => {
|
||||||
// console.log('b4 grown:', prettyU(unif));
|
// console.log('b4 grown:', prettyU(unif));
|
||||||
const grown = transitivelyGrow(unif);
|
const grown = transitivelyGrow(unif);
|
||||||
// console.log('grown:', prettyU(grown));
|
// console.log('grown:', prettyU(grown));
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue