reorganize directory and file structure
This commit is contained in:
parent
1d826ea8d4
commit
48390b8556
99 changed files with 1155 additions and 1629 deletions
21
lib/meta/type_constructor.js
Normal file
21
lib/meta/type_constructor.js
Normal file
|
|
@ -0,0 +1,21 @@
|
|||
import { getHumanReadableName } from "../primitives/symbol.js";
|
||||
|
||||
const __makeTypeConstructor = (symbol, nAry, params) => {
|
||||
if (nAry === 0) {
|
||||
return { symbol, params };
|
||||
}
|
||||
// only for debugging, do we give the function a name
|
||||
const fName = `${getHumanReadableName(symbol).toLowerCase()}Type${params.length>0?params.length:''}`;
|
||||
return {
|
||||
[fName]: typeParam => {
|
||||
if (typeof typeParam !== 'function') {
|
||||
throw new Error("all type params must be functions");
|
||||
}
|
||||
return __makeTypeConstructor(symbol, nAry-1, params.concat([typeParam]));
|
||||
}
|
||||
}[fName];
|
||||
}
|
||||
|
||||
// Creates a new nominal type
|
||||
// export const makeTypeConstructor = symbol => nAry => makeTypeConstructorInternal(symbol, nAry);
|
||||
export const makeTypeConstructor = symbol => nAry => __makeTypeConstructor(symbol, nAry, []);
|
||||
9
lib/meta/type_constructor.types.js
Normal file
9
lib/meta/type_constructor.types.js
Normal file
|
|
@ -0,0 +1,9 @@
|
|||
import { getDefaultTypeParser } from "../parser/type_parser.js"
|
||||
import { makeTypeConstructor } from "./type_constructor.js";
|
||||
|
||||
const mkType = getDefaultTypeParser();
|
||||
|
||||
export const ModuleTypeConstructor = [
|
||||
// Problem: number of parameters of returned function depends on the 'Int' parameter...
|
||||
// {i: makeTypeConstructor, t: mkType("SymbolT -> Int -> ??")}
|
||||
];
|
||||
Loading…
Add table
Add a link
Reference in a new issue