refactor code: move everything from type_registry to "most appropriate" modules
This commit is contained in:
parent
4ca60784aa
commit
5283be608b
22 changed files with 160 additions and 164 deletions
|
|
@ -1,5 +1,11 @@
|
|||
import { fnType, prodType } from "../type_registry.js";
|
||||
import { fnType } from "../metacircular.js";
|
||||
import { Function, Type } from "../metacircular.js";
|
||||
import { DefaultMap } from "../util.js";
|
||||
|
||||
const productTypeRegistry = new DefaultMap(leftType => new DefaultMap(rightType => ({ operator: "product", leftType, rightType })));
|
||||
|
||||
// type constructor
|
||||
export const prodType = (leftType, rightType) => productTypeRegistry.getdefault(leftType, true).getdefault(rightType, true);
|
||||
|
||||
// In JS, all products are encoded in the same way:
|
||||
const constructor = left => right => ({left, right});
|
||||
|
|
@ -28,4 +34,4 @@ export const makeProductType = (leftType, rightType) => {
|
|||
{i: constructorType , t: Function},
|
||||
{i: constructorBoundType, t: Function},
|
||||
]};
|
||||
};
|
||||
};
|
||||
Loading…
Add table
Add a link
Reference in a new issue