add interactive prompt
This commit is contained in:
parent
ce192b49f2
commit
94efde3e65
22 changed files with 599 additions and 138 deletions
|
|
@ -6,10 +6,10 @@ import { Module } from "./module.js";
|
|||
const Type_to_Type = fnType({in: Type, out: Type});
|
||||
const Type_to_Module = fnType({in: Type, out: Module});
|
||||
|
||||
export const ModuleList = [
|
||||
export const ModuleList = {l:[
|
||||
{i: lsType , t: Type_to_Type},
|
||||
{i: Type_to_Type , t: Function},
|
||||
|
||||
{i: makeListModule, t: Type_to_Module},
|
||||
{i: Type_to_Module, t: Function},
|
||||
];
|
||||
]};
|
||||
|
|
|
|||
|
|
@ -50,20 +50,20 @@ export const makeListModule = elementType => {
|
|||
|
||||
if (elementType === Byte) {
|
||||
// specialization: use Uint8Array instead of JS array
|
||||
return [
|
||||
return {l:[
|
||||
...common,
|
||||
{i: byteListImpl.emptyList , t: ListOfElement},
|
||||
{i: byteListImpl.get , t: getFnType},
|
||||
{i: byteListImpl.put , t: putFnType},
|
||||
];
|
||||
]};
|
||||
}
|
||||
else {
|
||||
return [
|
||||
return {l:[
|
||||
...common,
|
||||
{i: emptyList , t: ListOfElement},
|
||||
{i: get , t: getFnType},
|
||||
{i: put , t: putFnType},
|
||||
// {i: push , t: pushFnType},
|
||||
];
|
||||
]};
|
||||
}
|
||||
};
|
||||
|
|
|
|||
|
|
@ -16,7 +16,7 @@ export const makeProductType = (leftType, rightType) => {
|
|||
const constructorBoundType = fnType({in: rightType, out: pType});
|
||||
const constructorType = fnType({in: leftType , out: constructorBoundType});
|
||||
|
||||
return [
|
||||
return {l:[
|
||||
{i: pType, t: Type},
|
||||
|
||||
{i: getLeft , t: leftFnType},
|
||||
|
|
@ -27,5 +27,5 @@ export const makeProductType = (leftType, rightType) => {
|
|||
{i: constructor , t: constructorType},
|
||||
{i: constructorType , t: Function},
|
||||
{i: constructorBoundType, t: Function},
|
||||
];
|
||||
]};
|
||||
};
|
||||
|
|
|
|||
|
|
@ -5,6 +5,8 @@ import { Module } from "./module.js";
|
|||
const constructorLeft = left => ({variant: "L", value: left });
|
||||
const constructorRight = right => ({variant: "R", value: right});
|
||||
|
||||
// (<uuid>, product(double, double)): product(int, type)
|
||||
|
||||
// signature:
|
||||
// sum-type -> (leftType -> resultType, rightType -> resultType) -> resultType
|
||||
const match = sum => handlers => sum.variant === "L"
|
||||
|
|
@ -26,13 +28,13 @@ export const makeSumType = (leftType, rightType) => {
|
|||
fnType({in: rightType, out: returnType}), // handler function for right variant
|
||||
);
|
||||
const matchFnType = fnType({in: sType, out: fnType({in: handlersType, out: returnType})});
|
||||
return [
|
||||
return {l:[
|
||||
{i: match , t: matchFnType},
|
||||
{i: matchFnType, t: Function},
|
||||
];
|
||||
]};
|
||||
};
|
||||
|
||||
return [
|
||||
return {l:[
|
||||
{i: sType , t: Type},
|
||||
{i: constructorLeft , t: constructorLeftType},
|
||||
{i: constructorRight , t: constructorRightType},
|
||||
|
|
@ -40,5 +42,5 @@ export const makeSumType = (leftType, rightType) => {
|
|||
{i: constructorRightType, t: Function},
|
||||
|
||||
{i: makeMatchFn, t: fnType({in: Type, out: Module})},
|
||||
];
|
||||
]};
|
||||
};
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue