reorganize directory and file structure

This commit is contained in:
Joeri Exelmans 2025-05-07 13:44:49 +02:00
parent 1d826ea8d4
commit 48390b8556
99 changed files with 1155 additions and 1629 deletions

View 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, []);

View 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 -> ??")}
];