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,7 +1,14 @@
|
|||
import { fnType, prodType, sumType } from "../type_registry.js";
|
||||
import { sumType } from "../type_registry.js";
|
||||
import { prodType } from "./product.js";
|
||||
import { fnType } from "../metacircular.js";
|
||||
import { Function, Type } from "../metacircular.js";
|
||||
import { Module } from "./list_types/module.js";
|
||||
|
||||
const sumTypeRegistry = new DefaultMap(leftType => new DefaultMap(rightType => ({ operator: "sum", leftType, rightType })));
|
||||
|
||||
// type constructor
|
||||
export const sumType = (leftType, rightType) => sumTypeRegistry.getdefault(leftType, true).getdefault(rightType, true);
|
||||
|
||||
const constructorLeft = left => ({variant: "L", value: left });
|
||||
const constructorRight = right => ({variant: "R", value: right});
|
||||
|
||||
|
|
@ -43,4 +50,4 @@ export const makeSumType = (leftType, rightType) => {
|
|||
|
||||
{i: makeMatchFn, t: fnType({in: Type, out: Module})},
|
||||
]};
|
||||
};
|
||||
};
|
||||
Loading…
Add table
Add a link
Reference in a new issue