(broken) modules are mappings from name to typed value
This commit is contained in:
parent
c27c7d3648
commit
639d70afa5
21 changed files with 125 additions and 132 deletions
|
|
@ -16,15 +16,15 @@ const mkType = makeTypeParser({
|
|||
});
|
||||
|
||||
export const ModulePointNominal = [
|
||||
newDynamic(PointCartesian2D )(Type),
|
||||
newDynamic(PointPolar2D )(Type),
|
||||
["PointCartesian2D" , newDynamic(PointCartesian2D )(Type)],
|
||||
["PointPolar2D" , newDynamic(PointPolar2D )(Type)],
|
||||
|
||||
newDynamic(examplePoint )(PointCartesian2D),
|
||||
["examplePoint" , newDynamic(examplePoint )(PointCartesian2D)],
|
||||
|
||||
newDynamic(cart2polar)(mkType("PointCartesian2D -> PointPolar2D")),
|
||||
newDynamic(polar2cart)(mkType("PointPolar2D -> PointCartesian2D")),
|
||||
["cart2polar", newDynamic(cart2polar)(mkType("PointCartesian2D -> PointPolar2D"))],
|
||||
["polar2cart", newDynamic(polar2cart)(mkType("PointPolar2D -> PointCartesian2D"))],
|
||||
|
||||
newDynamic(translate)(mkType("Double -> Double -> PointCartesian2D")),
|
||||
newDynamic(rotate )(mkType("Double -> PointPolar2D -> PointPolar2D")),
|
||||
newDynamic(scale )(mkType("Double -> PointPolar2D -> PointPolar2D")),
|
||||
["translate", newDynamic(translate)(mkType("Double -> Double -> PointCartesian2D"))],
|
||||
["rotate" , newDynamic(rotate )(mkType("Double -> PointPolar2D -> PointPolar2D"))],
|
||||
["scale" , newDynamic(scale )(mkType("Double -> PointPolar2D -> PointPolar2D"))],
|
||||
];
|
||||
|
|
|
|||
|
|
@ -57,20 +57,20 @@ const mkType = makeTypeParser({
|
|||
});
|
||||
|
||||
const ModuleConversions = [
|
||||
newDynamic(NPoint2DCartesian )(mkType("NPoint2DCartesian") ),
|
||||
newDynamic(NPoint2DPolar )(mkType("NPoint2DPolar") ),
|
||||
newDynamic(cart2polar )(mkType("NPoint2DCartesian -> NPoint2DPolar") ),
|
||||
newDynamic(polar2cart )(mkType("NPoint2DPolar -> NPoint2DCartesian") ),
|
||||
["NPoint2DCartesian" , newDynamic(NPoint2DCartesian )(mkType("NPoint2DCartesian" ))],
|
||||
["NPoint2DPolar" , newDynamic(NPoint2DPolar )(mkType("NPoint2DPolar" ))],
|
||||
["cart2polar" , newDynamic(cart2polar )(mkType("NPoint2DCartesian -> NPoint2DPolar"))],
|
||||
["polar2cart" , newDynamic(polar2cart )(mkType("NPoint2DPolar -> NPoint2DCartesian"))],
|
||||
];
|
||||
|
||||
const examplePointCart = newCartesian(1)(2);
|
||||
const examplePointPolar = newPolar(0)(5);
|
||||
|
||||
const ModuleExamples = [
|
||||
newDynamic(examplePointCart )(SPoint2DCartesian ),
|
||||
newDynamic(examplePointCart )(NPoint2DCartesian ),
|
||||
newDynamic(examplePointPolar )(SPoint2DPolar ),
|
||||
newDynamic(examplePointPolar )(NPoint2DPolar ),
|
||||
["examplePointCart" , newDynamic(examplePointCart )(SPoint2DCartesian )],
|
||||
["examplePointCart" , newDynamic(examplePointCart )(NPoint2DCartesian )],
|
||||
["examplePointPolar" , newDynamic(examplePointPolar )(SPoint2DPolar )],
|
||||
["examplePointPolar" , newDynamic(examplePointPolar )(NPoint2DPolar )],
|
||||
];
|
||||
|
||||
export const ModuleAll = [
|
||||
|
|
|
|||
|
|
@ -5,6 +5,6 @@ import { compareDynamic, makeCompareFn } from "./dynamic.js";
|
|||
const mkType = getDefaultTypeParser();
|
||||
|
||||
export const ModuleCompareDynamic = [
|
||||
newDynamic(makeCompareFn )(mkType("Type -> a -> a -> Ordering")),
|
||||
newDynamic(compareDynamic)(mkType("Dynamic -> Dynamic -> Ordering")),
|
||||
["makeCompareFn" , newDynamic(makeCompareFn )(mkType("Type -> a -> a -> Ordering" ))],
|
||||
["compareDynamic", newDynamic(compareDynamic)(mkType("Dynamic -> Dynamic -> Ordering"))],
|
||||
];
|
||||
|
|
@ -5,10 +5,10 @@ import { compareBools, compareDoubles, compareInts, compareOrderings, compareSym
|
|||
const mkType = getDefaultTypeParser();
|
||||
|
||||
export const ModuleComparePrimitives = [
|
||||
newDynamic(compareInts )(mkType("Int -> Int -> Ordering" )),
|
||||
newDynamic(compareDoubles )(mkType("Double -> Double -> Ordering" )),
|
||||
newDynamic(compareBools )(mkType("Bool -> Bool -> Ordering" )),
|
||||
newDynamic(compareUnits )(mkType("Unit -> Unit -> Ordering" )),
|
||||
newDynamic(compareSymbols )(mkType("UUID -> UUID -> Ordering" )),
|
||||
newDynamic(compareOrderings)(mkType("Ordering -> Ordering -> Ordering")),
|
||||
["compareInts" , newDynamic(compareInts )(mkType("Int -> Int -> Ordering" ))],
|
||||
["compareDoubles" , newDynamic(compareDoubles )(mkType("Double -> Double -> Ordering" ))],
|
||||
["compareBools" , newDynamic(compareBools )(mkType("Bool -> Bool -> Ordering" ))],
|
||||
["compareUnits" , newDynamic(compareUnits )(mkType("Unit -> Unit -> Ordering" ))],
|
||||
["compareSymbols" , newDynamic(compareSymbols )(mkType("UUID -> UUID -> Ordering" ))],
|
||||
["compareOrderings", newDynamic(compareOrderings)(mkType("Ordering -> Ordering -> Ordering"))],
|
||||
];
|
||||
|
|
|
|||
|
|
@ -5,13 +5,9 @@ import { compareDicts, compareLists, compareProducts, compareSets, compareSums }
|
|||
const mkType = getDefaultTypeParser();
|
||||
|
||||
export const ModuleCompareStructures = [
|
||||
newDynamic(compareLists)(mkType("(a -> a -> Ordering) -> [a] -> [a] -> Ordering")),
|
||||
|
||||
newDynamic(compareProducts)(mkType("(a -> a -> Ordering) -> (b -> b -> Ordering) -> (a*b) -> (a*b) -> Ordering")),
|
||||
|
||||
newDynamic(compareSums)(mkType("(a -> a -> Ordering) -> (b -> b -> Ordering) -> (a+b) -> (a+b) -> Ordering")),
|
||||
|
||||
newDynamic(compareSets)(mkType("(a -> a -> Ordering) -> {a} -> {a} -> Ordering")),
|
||||
|
||||
newDynamic(compareDicts)(mkType("(a -> a -> Ordering) -> (b -> b-> Ordering) -> (a => b) -> (a => b) -> Ordering"))
|
||||
["compareLists" , newDynamic(compareLists )(mkType("(a -> a -> Ordering) -> [a] -> [a] -> Ordering" ))],
|
||||
["compareProducts", newDynamic(compareProducts)(mkType("(a -> a -> Ordering) -> (b -> b -> Ordering) -> (a*b) -> (a*b) -> Ordering" ))],
|
||||
["compareSums" , newDynamic(compareSums )(mkType("(a -> a -> Ordering) -> (b -> b -> Ordering) -> (a+b) -> (a+b) -> Ordering" ))],
|
||||
["compareSets" , newDynamic(compareSets )(mkType("(a -> a -> Ordering) -> {a} -> {a} -> Ordering" ))],
|
||||
["compareDicts" , newDynamic(compareDicts )(mkType("(a -> a -> Ordering) -> (b -> b-> Ordering) -> (a => b) -> (a => b) -> Ordering"))],
|
||||
];
|
||||
|
|
|
|||
|
|
@ -5,5 +5,5 @@ import { compareTypes } from "./type.js";
|
|||
const mkType = getDefaultTypeParser();
|
||||
|
||||
export const ModuleCompareTypes = [
|
||||
newDynamic(compareTypes)(mkType("Type -> Type -> Ordering")),
|
||||
["compareTypes", newDynamic(compareTypes)(mkType("Type -> Type -> Ordering"))],
|
||||
];
|
||||
|
|
|
|||
|
|
@ -5,7 +5,7 @@ import { newDynamic } from "./dynamic.js";
|
|||
const mkType = getDefaultTypeParser();
|
||||
|
||||
export const ModuleDouble = [
|
||||
newDynamic(addDouble)(mkType("Double -> Double -> Double")),
|
||||
newDynamic(mulDouble)(mkType("Double -> Double -> Double")),
|
||||
newDynamic(eqDouble )(mkType("Double -> Double -> Bool" )),
|
||||
["addDouble", newDynamic(addDouble)(mkType("Double -> Double -> Double"))],
|
||||
["mulDouble", newDynamic(mulDouble)(mkType("Double -> Double -> Double"))],
|
||||
["eqDouble" , newDynamic(eqDouble )(mkType("Double -> Double -> Bool" ))],
|
||||
];
|
||||
|
|
|
|||
|
|
@ -3,14 +3,11 @@ import { apply, getInst, getType, newDynamic } from "./dynamic.js";
|
|||
|
||||
const mkType = getDefaultTypeParser();
|
||||
|
||||
// Not sure if the type var 'a' is the right way to go...
|
||||
|
||||
export const ModuleDynamic = [
|
||||
newDynamic(newDynamic)(mkType("a -> Type -> Dynamic")),
|
||||
|
||||
// allows us to (unsafely) cast the result to the specific type...
|
||||
// (not sure if this is the right way to go)
|
||||
newDynamic(getInst)(mkType("Dynamic -> a") ),
|
||||
|
||||
newDynamic(getType)(mkType("Dynamic -> Type") ),
|
||||
|
||||
newDynamic(apply)(mkType("Dynamic -> Dynamic -> Dynamic") ),
|
||||
["newDynamic", newDynamic(newDynamic)(mkType("a -> Type -> Dynamic" ))],
|
||||
["getInst" , newDynamic(getInst )(mkType("Dynamic -> a" ))],
|
||||
["getType" , newDynamic(getType )(mkType("Dynamic -> Type" ))],
|
||||
["apply" , newDynamic(apply )(mkType("Dynamic -> Dynamic -> Dynamic"))],
|
||||
];
|
||||
|
|
|
|||
|
|
@ -5,7 +5,7 @@ import { addInt, eqInt, mulInt } from "./int.js";
|
|||
const mkType = getDefaultTypeParser();
|
||||
|
||||
export const ModuleInt = [
|
||||
newDynamic(addInt)(mkType("Int -> Int -> Int") ),
|
||||
newDynamic(mulInt)(mkType("Int -> Int -> Int") ),
|
||||
newDynamic(eqInt)(mkType("Int -> Int -> Bool") ),
|
||||
["addInt", newDynamic(addInt)(mkType("Int -> Int -> Int" ))],
|
||||
["mulInt", newDynamic(mulInt)(mkType("Int -> Int -> Int" ))],
|
||||
["eqInt" , newDynamic(eqInt )(mkType("Int -> Int -> Bool"))],
|
||||
];
|
||||
|
|
|
|||
|
|
@ -2,31 +2,31 @@ import { newDynamic } from "./dynamic.js";
|
|||
import { SymbolInt, UUID, SymbolBool, SymbolDouble, SymbolByte, SymbolChar, SymbolUnit, SymbolBottom, SymbolUUID, SymbolType, SymbolTop, Type, Int, Bool, Double, Byte, Char, Unit, Bottom, Top, SymbolDynamic, Dynamic, SymbolOrdering, Ordering } from "./primitive_types.js";
|
||||
|
||||
export const ModulePrimitiveSymbols = [
|
||||
newDynamic(SymbolInt )(UUID),
|
||||
newDynamic(SymbolBool )(UUID),
|
||||
newDynamic(SymbolDouble )(UUID),
|
||||
newDynamic(SymbolByte )(UUID),
|
||||
newDynamic(SymbolChar )(UUID),
|
||||
newDynamic(SymbolUnit )(UUID),
|
||||
newDynamic(SymbolBottom )(UUID),
|
||||
newDynamic(SymbolUUID )(UUID),
|
||||
newDynamic(SymbolType )(UUID),
|
||||
newDynamic(SymbolTop )(UUID),
|
||||
newDynamic(SymbolDynamic )(UUID),
|
||||
newDynamic(SymbolOrdering)(UUID),
|
||||
["SymbolInt" , newDynamic(SymbolInt )(UUID)],
|
||||
["SymbolBool" , newDynamic(SymbolBool )(UUID)],
|
||||
["SymbolDouble" , newDynamic(SymbolDouble )(UUID)],
|
||||
["SymbolByte" , newDynamic(SymbolByte )(UUID)],
|
||||
["SymbolChar" , newDynamic(SymbolChar )(UUID)],
|
||||
["SymbolUnit" , newDynamic(SymbolUnit )(UUID)],
|
||||
["SymbolBottom" , newDynamic(SymbolBottom )(UUID)],
|
||||
["SymbolUUID" , newDynamic(SymbolUUID )(UUID)],
|
||||
["SymbolType" , newDynamic(SymbolType )(UUID)],
|
||||
["SymbolTop" , newDynamic(SymbolTop )(UUID)],
|
||||
["SymbolDynamic" , newDynamic(SymbolDynamic )(UUID)],
|
||||
["SymbolOrdering", newDynamic(SymbolOrdering)(UUID)],
|
||||
];
|
||||
|
||||
export const ModulePrimitiveTypes = [
|
||||
newDynamic(Int )(Type),
|
||||
newDynamic(Bool )(Type),
|
||||
newDynamic(Double )(Type),
|
||||
newDynamic(Byte )(Type),
|
||||
newDynamic(Char )(Type),
|
||||
newDynamic(Unit )(Type),
|
||||
newDynamic(Bottom )(Type),
|
||||
newDynamic(UUID )(Type),
|
||||
newDynamic(Type )(Type),
|
||||
newDynamic(Top )(Type),
|
||||
newDynamic(Dynamic )(Type),
|
||||
newDynamic(Ordering)(Type),
|
||||
["Int" , newDynamic(Int )(Type)],
|
||||
["Bool" , newDynamic(Bool )(Type)],
|
||||
["Double" , newDynamic(Double )(Type)],
|
||||
["Byte" , newDynamic(Byte )(Type)],
|
||||
["Char" , newDynamic(Char )(Type)],
|
||||
["Unit" , newDynamic(Unit )(Type)],
|
||||
["Bottom" , newDynamic(Bottom )(Type)],
|
||||
["UUID" , newDynamic(UUID )(Type)],
|
||||
["Type" , newDynamic(Type )(Type)],
|
||||
["Top" , newDynamic(Top )(Type)],
|
||||
["Dynamic" , newDynamic(Dynamic )(Type)],
|
||||
["Ordering", newDynamic(Ordering)(Type)],
|
||||
];
|
||||
|
|
|
|||
|
|
@ -5,6 +5,6 @@ import { eqSymbol, getHumanReadableName } from "./symbol.js";
|
|||
const mkType = getDefaultTypeParser();
|
||||
|
||||
export const ModuleSymbol = [
|
||||
newDynamic(getHumanReadableName)(mkType("UUID -> String")),
|
||||
newDynamic(eqSymbol)(mkType("UUID -> UUID -> Bool")),
|
||||
["getHumanReadableName", newDynamic(getHumanReadableName)(mkType("UUID -> String" ))],
|
||||
["eqSymbol" , newDynamic(eqSymbol )(mkType("UUID -> UUID -> Bool"))],
|
||||
];
|
||||
|
|
|
|||
|
|
@ -8,7 +8,7 @@ const mkType = getDefaultTypeParser();
|
|||
|
||||
// each 'typed object' is implicitly an instance of TypeLink (defined below)
|
||||
export const ModuleType = [
|
||||
newDynamic(eqType )(mkType("Type -> Type -> Bool")),
|
||||
newDynamic(getSymbol)(mkType("Type -> UUID")),
|
||||
newDynamic(getParams)(mkType("Type -> [Type -> Type]")),
|
||||
["eqType" , newDynamic(eqType )(mkType("Type -> Type -> Bool" ))],
|
||||
["getSymbol", newDynamic(getSymbol)(mkType("Type -> UUID" ))],
|
||||
["getParams", newDynamic(getParams)(mkType("Type -> [Type -> Type]"))],
|
||||
];
|
||||
|
|
|
|||
|
|
@ -5,6 +5,6 @@ import { eqUnit, unit } from "./unit.js";
|
|||
const mkType = getDefaultTypeParser();
|
||||
|
||||
export const ModuleUnit = [
|
||||
newDynamic(unit )(mkType("Unit")),
|
||||
newDynamic(eqUnit)(mkType("Unit -> Unit -> Bool")),
|
||||
["unit" , newDynamic(unit )(mkType("Unit" ))],
|
||||
["eqUnit", newDynamic(eqUnit)(mkType("Unit -> Unit -> Bool"))],
|
||||
];
|
||||
|
|
|
|||
|
|
@ -13,13 +13,13 @@ const mkType = makeTypeParser({
|
|||
});
|
||||
|
||||
export const ModuleDict = [
|
||||
newDynamic(emptyDict)(mkType("(a -> a -> Int) -> (a => b) ")),
|
||||
newDynamic(has )(mkType("(a => b) -> a -> Bool ")),
|
||||
newDynamic(set )(mkType("(a => b) -> a -> b -> (a => b) ")),
|
||||
newDynamic(remove )(mkType("(a => b) -> a -> (a => b) ")),
|
||||
newDynamic(length )(mkType("(a => b) -> Int ")),
|
||||
newDynamic(fold )(mkType("(c -> a -> b -> c) -> c -> (a => b) -> c ")),
|
||||
newDynamic(first )(mkType("(a => b) -> (a |=>| b) ")),
|
||||
newDynamic(last )(mkType("(a => b) -> (a |=>| b) ")),
|
||||
newDynamic(read )(mkType("(a |=>| b) -> (Unit + ((a*b) * (a |=>| b)))")),
|
||||
["emptyDict", newDynamic(emptyDict)(mkType("(a -> a -> Int) -> (a => b) "))],
|
||||
["has" , newDynamic(has )(mkType("(a => b) -> a -> Bool "))],
|
||||
["set" , newDynamic(set )(mkType("(a => b) -> a -> b -> (a => b) "))],
|
||||
["remove" , newDynamic(remove )(mkType("(a => b) -> a -> (a => b) "))],
|
||||
["length" , newDynamic(length )(mkType("(a => b) -> Int "))],
|
||||
["fold" , newDynamic(fold )(mkType("(c -> a -> b -> c) -> c -> (a => b) -> c "))],
|
||||
["first" , newDynamic(first )(mkType("(a => b) -> (a |=>| b) "))],
|
||||
["last" , newDynamic(last )(mkType("(a => b) -> (a |=>| b) "))],
|
||||
["read" , newDynamic(read )(mkType("(a |=>| b) -> (Unit + ((a*b) * (a |=>| b)))"))],
|
||||
];
|
||||
|
|
|
|||
|
|
@ -65,11 +65,11 @@ export const makeModuleEnum = type => variants => {
|
|||
const matchFn = makeMatchFn(variants);
|
||||
const matchFnType = makeMatchFnType(type)(variants);
|
||||
const module = [
|
||||
// newDynamic(type)(Type),
|
||||
// ["type", newDynamic(type)(Type)],
|
||||
|
||||
// constructors:
|
||||
...zip(ctors, ctorTypes)
|
||||
.map(([ctor, ctorType]) => newDynamic(ctor)(ctorType)),
|
||||
.map(([ctor, ctorType]) => ["ctor", newDynamic(ctor)(ctorType)]),
|
||||
|
||||
// match-function:
|
||||
newDynamic(matchFn, matchFnType),
|
||||
|
|
|
|||
|
|
@ -5,12 +5,12 @@ import { emptyList, fold, get, length, map, pop, push, put } from "./list.js";
|
|||
const mkType = getDefaultTypeParser();
|
||||
|
||||
export const ModuleList = [
|
||||
newDynamic(emptyList)(mkType("[a]")),
|
||||
newDynamic(get )(mkType("[a] -> Int -> a")),
|
||||
newDynamic(put )(mkType("[a] -> Int -> a -> [a]")),
|
||||
newDynamic(push )(mkType("[a] -> a -> [a]")),
|
||||
newDynamic(pop )(mkType("[a] -> a")),
|
||||
newDynamic(map )(mkType("[a] -> (a -> b) -> [b]")),
|
||||
newDynamic(length )(mkType("[a] -> Int")),
|
||||
newDynamic(fold )(mkType("(b -> a -> b) -> b -> [a] -> b")),
|
||||
["emptyList", newDynamic(emptyList)(mkType("[a]" ))],
|
||||
["get" , newDynamic(get )(mkType("[a] -> Int -> a" ))],
|
||||
["put" , newDynamic(put )(mkType("[a] -> Int -> a -> [a]" ))],
|
||||
["push" , newDynamic(push )(mkType("[a] -> a -> [a]" ))],
|
||||
["pop" , newDynamic(pop )(mkType("[a] -> a" ))],
|
||||
["map" , newDynamic(map )(mkType("[a] -> (a -> b) -> [b]" ))],
|
||||
["length" , newDynamic(length )(mkType("[a] -> Int" ))],
|
||||
["fold" , newDynamic(fold )(mkType("(b -> a -> b) -> b -> [a] -> b"))],
|
||||
];
|
||||
|
|
|
|||
|
|
@ -5,7 +5,7 @@ import { newProduct, getLeft, getRight } from "./product.js";
|
|||
const mkType = getDefaultTypeParser();
|
||||
|
||||
export const ModuleProduct = [
|
||||
newDynamic(newProduct)(mkType("a -> b -> (a * b)") ),
|
||||
newDynamic(getLeft )(mkType("(a * b) -> a" ) ),
|
||||
newDynamic(getRight )(mkType("(a * b) -> b" ) ),
|
||||
["newProduct", newDynamic(newProduct)(mkType("a -> b -> (a * b)"))],
|
||||
["getLeft" , newDynamic(getLeft )(mkType("(a * b) -> a" ))],
|
||||
["getRight" , newDynamic(getRight )(mkType("(a * b) -> b" ))],
|
||||
];
|
||||
|
|
|
|||
|
|
@ -13,13 +13,13 @@ const mkType = makeTypeParser({
|
|||
});
|
||||
|
||||
export const ModuleSet = [
|
||||
newDynamic(emptySet)(mkType("(a -> a -> Int) -> {a}" )),
|
||||
newDynamic(has )(mkType("{a} -> a -> Bool" )),
|
||||
newDynamic(add )(mkType("{a} -> a -> {a}" )),
|
||||
newDynamic(remove )(mkType("{a} -> a -> {a}" )),
|
||||
newDynamic(length )(mkType("{a} -> Int" )),
|
||||
newDynamic(fold )(mkType("(b -> a -> b) -> b -> {a} -> b")),
|
||||
newDynamic(first )(mkType("{a} -> <a>" )),
|
||||
newDynamic(last )(mkType("{a} -> <a>" )),
|
||||
newDynamic(read )(mkType("<a> -> (Unit + (a * <a>))" )),
|
||||
["emptySet", newDynamic(emptySet)(mkType("(a -> a -> Int) -> {a}" ))],
|
||||
["has" , newDynamic(has )(mkType("{a} -> a -> Bool" ))],
|
||||
["add" , newDynamic(add )(mkType("{a} -> a -> {a}" ))],
|
||||
["remove" , newDynamic(remove )(mkType("{a} -> a -> {a}" ))],
|
||||
["length" , newDynamic(length )(mkType("{a} -> Int" ))],
|
||||
["fold" , newDynamic(fold )(mkType("(b -> a -> b) -> b -> {a} -> b"))],
|
||||
["first" , newDynamic(first )(mkType("{a} -> <a>" ))],
|
||||
["last" , newDynamic(last )(mkType("{a} -> <a>" ))],
|
||||
["read" , newDynamic(read )(mkType("<a> -> (Unit + (a * <a>))" ))],
|
||||
];
|
||||
|
|
|
|||
|
|
@ -57,14 +57,14 @@ export const makeModuleStruct = type => fields => {
|
|||
const getterTypes = makeGettersTypes(fields);
|
||||
const getters = makeGetters(fieldNames);
|
||||
const module = [
|
||||
// newDynamic(type)(Type),
|
||||
// ["type", newDynamic(type)(Type)],
|
||||
|
||||
// constructor
|
||||
newDynamic(ctor)(ctorType),
|
||||
["ctor", newDynamic(ctor)(ctorType)],
|
||||
|
||||
// getters:
|
||||
...zip(getters, getterTypes)
|
||||
.map(([getter, getterType]) => newDynamic(getter)(getterType)),
|
||||
.map(([getter, getterType]) => ["getter", newDynamic(getter)(getterType)]),
|
||||
];
|
||||
return module;
|
||||
};
|
||||
|
|
@ -72,6 +72,6 @@ export const makeModuleStruct = type => fields => {
|
|||
const mkType = getDefaultTypeParser();
|
||||
|
||||
export const ModuleStruct = [
|
||||
newDynamic(structType)(mkType("[String*Type] -> Type")),
|
||||
newDynamic(makeModuleStruct)(mkType("[String*Type] -> [Dynamic]")),
|
||||
["structType" , newDynamic(structType )(mkType("[String*Type] -> Type" ))],
|
||||
["makeModuleStruct", newDynamic(makeModuleStruct)(mkType("[String*Type] -> [Dynamic]"))],
|
||||
];
|
||||
|
|
|
|||
|
|
@ -5,7 +5,7 @@ import { match, newLeft, newRight } from "./sum.js";
|
|||
const mkType = getDefaultTypeParser();
|
||||
|
||||
export const ModuleSum = [
|
||||
newDynamic(newLeft )(mkType("a -> (a + b)") ),
|
||||
newDynamic(newRight )(mkType("b -> (a + b)") ),
|
||||
newDynamic(match )(mkType("(a + b) -> (a -> c) -> (b -> c) -> c") ),
|
||||
["newLeft" , newDynamic(newLeft )(mkType("a -> (a + b)" ))],
|
||||
["newRight" , newDynamic(newRight )(mkType("b -> (a + b)" ))],
|
||||
["match" , newDynamic(match )(mkType("(a + b) -> (a -> c) -> (b -> c) -> c"))],
|
||||
];
|
||||
|
|
|
|||
|
|
@ -11,12 +11,12 @@ export const setType = makeTypeConstructor(symbolSet)(1);
|
|||
export const dictType = makeTypeConstructor(symbolDict)(2);
|
||||
|
||||
export const ModuleStructuralSymbols = [
|
||||
newDynamic(symbolSet )(UUID),
|
||||
newDynamic(symbolList )(UUID),
|
||||
newDynamic(symbolProduct )(UUID),
|
||||
newDynamic(symbolSum )(UUID),
|
||||
newDynamic(symbolDict )(UUID),
|
||||
newDynamic(symbolFunction)(UUID),
|
||||
["symbolSet" , newDynamic(symbolSet )(UUID)],
|
||||
["symbolList" , newDynamic(symbolList )(UUID)],
|
||||
["symbolProduct" , newDynamic(symbolProduct )(UUID)],
|
||||
["symbolSum" , newDynamic(symbolSum )(UUID)],
|
||||
["symbolDict" , newDynamic(symbolDict )(UUID)],
|
||||
["symbolFunction", newDynamic(symbolFunction)(UUID)],
|
||||
];
|
||||
|
||||
const unaryTypeConstructor = fnType
|
||||
|
|
@ -28,10 +28,10 @@ const binaryTypeConstructor = fnType
|
|||
(_ => unaryTypeConstructor);
|
||||
|
||||
export const ModuleTypeConstructors = [
|
||||
newDynamic(setType )(unaryTypeConstructor ),
|
||||
newDynamic(lsType )(unaryTypeConstructor ),
|
||||
newDynamic(prodType)(binaryTypeConstructor),
|
||||
newDynamic(sumType )(binaryTypeConstructor),
|
||||
newDynamic(dictType)(binaryTypeConstructor),
|
||||
newDynamic(fnType )(binaryTypeConstructor),
|
||||
["setType" , newDynamic(setType )(unaryTypeConstructor )],
|
||||
["lsType" , newDynamic(lsType )(unaryTypeConstructor )],
|
||||
["prodType", newDynamic(prodType)(binaryTypeConstructor)],
|
||||
["sumType" , newDynamic(sumType )(binaryTypeConstructor)],
|
||||
["dictType", newDynamic(dictType)(binaryTypeConstructor)],
|
||||
["fnType" , newDynamic(fnType )(binaryTypeConstructor)],
|
||||
];
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue