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