interactive prompt

This commit is contained in:
Joeri Exelmans 2025-03-23 17:46:39 +01:00
parent bc91d9bf39
commit 3596e01c28
9 changed files with 298 additions and 105 deletions

View file

@ -2,6 +2,7 @@ import { Type } from "../type.js";
import { typedFnType } from "./types.js";
import { fnType } from "./types.js";
// export const pprintFn = fnT => ``
export const ModuleFunction = {l:[
// binary type constructor: Type -> Type -> Type

View file

@ -1,5 +1,6 @@
// to break up dependency cycles, type constructors are defined in their own JS module
import { Type } from "../type.js";
import { DefaultMap } from "../util.js";
@ -36,14 +37,14 @@ export const typedFnType2 = callback => {
const t = callback(wrappedFnType); // force evaluation
return [
t,
fnTs.map(fnT => ({ i: fnT, t: Function })),
fnTs.map(fnT => ({ i: fnT, t: Type })),
];
};
// Sum type
const symbolSum = Symbol("Sum");
export const symbolSum = Symbol("Sum");
const sumTypeRegistry = new DefaultMap(leftType => new DefaultMap(rightType => ({
symbol: symbolSum,
params: [leftType, rightType],
@ -54,7 +55,7 @@ export const sumType = leftType => rightType => sumTypeRegistry.getdefault(leftT
// Product type
const symbolProduct = Symbol("Product");
export const symbolProduct = Symbol("Product");
const productTypeRegistry = new DefaultMap(leftType => new DefaultMap(rightType => ({
symbol: symbolProduct,
params: [leftType, rightType],
@ -65,7 +66,7 @@ export const prodType = leftType => rightType => productTypeRegistry.getdefault(
// List type
const symbolList = Symbol('List');
export const symbolList = Symbol('List');
const listTypeRegistry = new DefaultMap(elementType => ({
symbol: symbolList,
params: [elementType],