add interactive prompt
This commit is contained in:
parent
ce192b49f2
commit
94efde3e65
22 changed files with 599 additions and 138 deletions
|
|
@ -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