interactive prompt
This commit is contained in:
parent
bc91d9bf39
commit
3596e01c28
9 changed files with 298 additions and 105 deletions
|
|
@ -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
|
||||
|
|
|
|||
|
|
@ -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],
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue