add interactive prompt

This commit is contained in:
Joeri Exelmans 2025-03-20 09:54:11 +01:00
parent ce192b49f2
commit 94efde3e65
22 changed files with 599 additions and 138 deletions

View file

@ -32,8 +32,8 @@ import {Function} from "../metacircular.js";
export const makeIdFn = typ => {
const Typ_to_Typ = fnType({in: typ, out: typ});
const id = x => x;
return [
return {l:[
{i: id , t: Typ_to_Typ},
{i: Typ_to_Typ, t: Function},
];
]};
};

View file

@ -36,15 +36,15 @@ export const makeSquare = ({i: mul, t: mulFunction}) => {
}
const square = x => mul(x)(x);
const squareFunction = fnType({in: numType, out: numType});
return [
return {l:[
{i: square , t: squareFunction},
{i: squareFunction, t: Function},
];
]};
};
const makeSquareType = fnType({in: Typed, out: Module});
export const ModuleSquare = [
export const ModuleSquare = {l:[
{i: makeSquare , t: makeSquareType},
{i: makeSquareType, t: Function},
];
]};

View file

@ -1,39 +0,0 @@
import {Int, Bool, Double, Byte} from "../primitives/symbols.js";
import { makeListModule } from "../structures/list_common.js";
import { makeProductType } from "../structures/product.js";
import { makeSumType } from "../structures/sum.js";
import { lsType, prodType, sumType } from "../type_registry.js";
const ListOfDouble = lsType(Double);
const ListOfDoubleModule = makeListModule(Double);
const ListOfListOfDouble = lsType(ListOfDouble);
const ListOfListOfDoubleModule = makeListModule(ListOfDouble);
const ListOfByte = lsType(Byte);
const ListOfByteModule = makeListModule(Byte);
export const ModuleValues = [
{i: 0n, t: Int},
{i: 42n, t: Int},
{i: false, t: Bool},
{i: 3.14159265359, t: Double},
{i: {l:[4.2, 7.6]} , t: ListOfDouble},
{i: {l:[{l:[4.2, 7.6]}, {l:[4.3]}]}, t: ListOfListOfDouble},
{i: new Uint8Array([1,2,3]), t: ListOfByte},
// i'm lazy
...ListOfDoubleModule,
...ListOfListOfDoubleModule,
...ListOfByteModule,
...makeProductType(Int, Bool),
...makeSumType(Int, Bool),
{i: {left: 42n, right: true}, t: prodType(Int, Bool)},
{i: {variant: "L", value: 100n}, t: sumType(Int, Bool)},
];