diff --git a/examples/environment.js b/examples/environment.js
index 6ff41fa..d79748e 100644
--- a/examples/environment.js
+++ b/examples/environment.js
@@ -3,25 +3,17 @@ import { ModuleStd } from "../lib/stdlib.js";
import { emptyDict, get, set } from "../lib/structures/dict.js";
import { emptySet, add } from "../lib/structures/set.js";
import { makeCompareFn } from "../lib/compare/dynamic.js"
-import { Type } from "../lib/primitives/primitive_types.js";
-console.log(ModuleStd);
-
-const addEntry = dict => i => t => {
- const setOfInstances = get(dict)(t) || emptySet(makeCompareFn(t));
- return set(dict)(t)(add(setOfInstances)(i));
-}
+// console.log(ModuleStd);
const typeDict = ModuleStd.reduce((typeDict, {i, t}) => {
try {
- // add instance to type:
- return addEntry(
- addEntry(typeDict)(i)(t)
- )(t)(Type);
+ const instances = get(typeDict)(t) || emptySet(makeCompareFn(t));
+ return set(typeDict)(t)(add(instances)(i));
} catch (e) {
console.log('warning:',e.message);
return typeDict;
}
}, emptyDict(compareTypes));
-console.log(typeDict);
+console.log(typeDict);
\ No newline at end of file
diff --git a/extra/point/nominal.types.js b/extra/point/nominal.types.js
index 2820937..06ff6dc 100644
--- a/extra/point/nominal.types.js
+++ b/extra/point/nominal.types.js
@@ -16,15 +16,15 @@ const mkType = makeTypeParser({
});
export const ModulePointNominal = [
- newDynamic(PointCartesian2D )(Type),
- newDynamic(PointPolar2D )(Type),
+ {i: PointCartesian2D , t: Type},
+ {i: PointPolar2D , t: Type},
- newDynamic(examplePoint )(PointCartesian2D),
+ {i: examplePoint , t: PointCartesian2D},
- newDynamic(cart2polar)(mkType("PointCartesian2D -> PointPolar2D")),
- newDynamic(polar2cart)(mkType("PointPolar2D -> PointCartesian2D")),
+ {i: cart2polar, t: mkType("PointCartesian2D -> PointPolar2D")},
+ {i: polar2cart, t: mkType("PointPolar2D -> PointCartesian2D")},
- newDynamic(translate)(mkType("Double -> Double -> PointCartesian2D")),
- newDynamic(rotate )(mkType("Double -> PointPolar2D -> PointPolar2D")),
- newDynamic(scale )(mkType("Double -> PointPolar2D -> PointPolar2D")),
+ {i: translate, t: mkType("Double -> Double -> PointCartesian2D")},
+ {i: rotate , t: mkType("Double -> PointPolar2D -> PointPolar2D")},
+ {i: scale , t: mkType("Double -> PointPolar2D -> PointPolar2D")},
];
diff --git a/extra/point/structural.types.js b/extra/point/structural.types.js
index 69b2dbc..2904966 100644
--- a/extra/point/structural.types.js
+++ b/extra/point/structural.types.js
@@ -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") ),
+ { i: NPoint2DCartesian , t: mkType("NPoint2DCartesian") },
+ { i: NPoint2DPolar , t: mkType("NPoint2DPolar") },
+ { i: cart2polar , t: mkType("NPoint2DCartesian -> NPoint2DPolar") },
+ { i: polar2cart , t: 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 ),
+ { i: examplePointCart , t: SPoint2DCartesian },
+ { i: examplePointCart , t: NPoint2DCartesian },
+ { i: examplePointPolar , t: SPoint2DPolar },
+ { i: examplePointPolar , t: NPoint2DPolar },
];
export const ModuleAll = [
diff --git a/lib/compare/dynamic.types.js b/lib/compare/dynamic.types.js
index 9b6bcef..157ef2d 100644
--- a/lib/compare/dynamic.types.js
+++ b/lib/compare/dynamic.types.js
@@ -4,6 +4,6 @@ import { compareDynamic, makeCompareFn } from "./dynamic.js";
const mkType = getDefaultTypeParser();
export const ModuleCompareDynamic = [
- newDynamic(makeCompareFn )(mkType("Type -> a -> a -> Int")),
- newDynamic(compareDynamic)(mkType("Dynamic -> Dynamic -> Int")),
+ {i: makeCompareFn , t: mkType("Type -> a -> a -> Int")},
+ {i: compareDynamic, t: mkType("Dynamic -> Dynamic -> Int")},
];
\ No newline at end of file
diff --git a/lib/compare/primitives.types.js b/lib/compare/primitives.types.js
index c3e45c9..77a92cd 100644
--- a/lib/compare/primitives.types.js
+++ b/lib/compare/primitives.types.js
@@ -1,12 +1,11 @@
import { getDefaultTypeParser } from "../parser/type_parser.js";
-import { newDynamic } from "../primitives/dynamic.js";
import { compareBools, compareNumbers, compareSymbols, compareUnits } from "./primitives.js";
const mkType = getDefaultTypeParser();
export const ModuleComparePrimitives = [
- newDynamic(compareNumbers)(mkType("Double -> Double -> Int")),
- newDynamic(compareBools )(mkType("Bool -> Bool -> Int")),
- newDynamic(compareUnits )(mkType("Unit -> Unit -> Int")),
- newDynamic(compareSymbols)(mkType("UUID -> UUID -> Int")),
+ {i: compareNumbers, t: mkType("Double -> Double -> Int")},
+ {i: compareBools , t: mkType("Bool -> Bool -> Int")},
+ {i: compareUnits , t: mkType("Unit -> Unit -> Int")},
+ {i: compareSymbols, t: mkType("UUID -> UUID -> Int")},
];
diff --git a/lib/compare/structures.types.js b/lib/compare/structures.types.js
index 890bb94..199ae27 100644
--- a/lib/compare/structures.types.js
+++ b/lib/compare/structures.types.js
@@ -1,17 +1,16 @@
import { getDefaultTypeParser } from "../parser/type_parser.js";
-import { newDynamic } from "../primitives/dynamic.js";
import { compareDicts, compareLists, compareProducts, compareSets, compareSums } from "./structures.js";
const mkType = getDefaultTypeParser();
export const ModuleCompareStructures = [
- newDynamic(compareLists)(mkType("(a -> a -> Int) -> [a] -> [a] -> Int")),
+ {i: compareLists, t: mkType("(a -> a -> Int) -> [a] -> [a] -> Int")},
- newDynamic(compareProducts)(mkType("(a -> a -> Int) -> (b -> b -> Int) -> (a*b) -> (a*b) -> Int")),
+ {i: compareProducts, t: mkType("(a -> a -> Int) -> (b -> b -> Int) -> (a*b) -> (a*b) -> Int")},
- newDynamic(compareSums)(mkType("(a -> a -> Int) -> (b -> b -> Int) -> (a+b) -> (a+b) -> Int")),
+ {i: compareSums, t: mkType("(a -> a -> Int) -> (b -> b -> Int) -> (a+b) -> (a+b) -> Int")},
- newDynamic(compareSets)(mkType("(a -> a -> Int) -> {a} -> {a} -> Int")),
+ {i: compareSets, t: mkType("(a -> a -> Int) -> {a} -> {a} -> Int")},
- newDynamic(compareDicts)(mkType("(a -> a -> Int) -> (b -> b-> Int) -> (a => b) -> (a => b) -> Int"))
+ {i: compareDicts, t: mkType("(a -> a -> Int) -> (b -> b-> Int) -> (a => b) -> (a => b) -> Int")}
];
diff --git a/lib/compare/type.types.js b/lib/compare/type.types.js
index e7674ef..ad11e3c 100644
--- a/lib/compare/type.types.js
+++ b/lib/compare/type.types.js
@@ -1,9 +1,8 @@
import { getDefaultTypeParser } from "../parser/type_parser.js";
-import { newDynamic } from "../primitives/dynamic.js";
import { compareTypes } from "./type.js";
const mkType = getDefaultTypeParser();
export const ModuleCompareTypes = [
- newDynamic(compareTypes)(mkType("Type -> Type -> Int")),
+ {i: compareTypes, t: mkType("Type -> Type -> Int")},
];
diff --git a/lib/meta/type_constructor.types.js b/lib/meta/type_constructor.types.js
index 8c687b4..c16b03f 100644
--- a/lib/meta/type_constructor.types.js
+++ b/lib/meta/type_constructor.types.js
@@ -5,5 +5,5 @@ const mkType = getDefaultTypeParser();
export const ModuleTypeConstructor = [
// Problem: number of parameters of returned function depends on the 'Int' parameter...
- // newDynamic(makeTypeConstructor)(mkType("UUID -> Int -> ??"))
+ // {i: makeTypeConstructor, t: mkType("UUID -> Int -> ??")}
];
diff --git a/lib/parser/type_parser.js b/lib/parser/type_parser.js
index 40b47bc..0a35c45 100644
--- a/lib/parser/type_parser.js
+++ b/lib/parser/type_parser.js
@@ -7,7 +7,6 @@ import { getSymbol } from "../primitives/type.js";
import { TYPE_VARS } from "../primitives/typevars.js";
import { dictType, fnType, lsType, prodType, sumType } from "../structures/type_constructors.types.js";
import { setType } from "../structures/type_constructors.types.js";
-import { prettyT } from "../util/pretty.js";
// A very stupid little parser, that can only parse:
// - primitives => simply maps onto types.
@@ -127,12 +126,12 @@ export const makeTypeParser = ({
}
}
- const parseGroup = (expr, tokensInGroup, fn, labels, label) => {
+ const parseGroup = (tokensInGroup, fn, labels, label) => {
// console.log('parseGroup ', tokensInGroup, fn);
return (fn === null)
- ? __parse(expr, tokensInGroup, labels, label)
+ ? __parse(tokensInGroup, labels, label)
: fn(self => {
- return __parse(expr, tokensInGroup, extendLabels(labels, label, self));
+ return __parse(tokensInGroup, extendLabels(labels, label, self));
});
}
@@ -140,7 +139,7 @@ export const makeTypeParser = ({
return (label === null) ? labels : new Map([...labels, [label, self]])
};
- const __parse = (expr, tokens, labels = new Map(), label = null) => {
+ const __parse = (tokens, labels = new Map(), label = null) => {
// console.log('parse ', tokens);
if (tokens[0].startsWith('#')) {
if (labels.has(tokens[0])) {
@@ -148,7 +147,7 @@ export const makeTypeParser = ({
}
else {
// pass label and parse 'rest'
- return __parse(expr, tokens.slice(1), labels, tokens[0]);
+ return __parse(tokens.slice(1), labels, tokens[0]);
}
}
if (tokens.length === 1) {
@@ -157,28 +156,26 @@ export const makeTypeParser = ({
else {
const [lhsTokens, fnGrp, rest] = consumeGroup(tokens);
if (rest.length === 0) {
- return parseGroup(expr, lhsTokens, fnGrp, labels, label);
+ return parseGroup(lhsTokens, fnGrp, labels, label);
}
const [operator, ...rhsTokens] = rest;
for (const [operatorChar, fn] of infixOperators) {
if (operator === operatorChar) {
return fn
(self => {
- return parseGroup(expr, lhsTokens, fnGrp, extendLabels(labels, label, self));
+ return parseGroup(lhsTokens, fnGrp, extendLabels(labels, label, self));
})(self => {
- return __parse(expr, rhsTokens, extendLabels(labels, label, self));
+ return __parse(rhsTokens, extendLabels(labels, label, self));
});
}
}
- throw new Error("unknown operator: "+operator+" in expression "+expr)
+ throw new Error("unknown operator: "+operator)
}
};
const parse = expr => {
const tokens = tokenize(expr);
- const parsed = __parse(expr, tokens);
- prettyT(parsed); // force evaluation
- return parsed;
+ return __parse(tokens);
}
return parse;
diff --git a/lib/primitives/double.types.js b/lib/primitives/double.types.js
index e0301a8..6e64769 100644
--- a/lib/primitives/double.types.js
+++ b/lib/primitives/double.types.js
@@ -1,11 +1,10 @@
import { getDefaultTypeParser } from "../parser/type_parser.js";
import { addDouble, eqDouble, mulDouble } from "./double.js";
-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") ),
+ { i: addDouble, t: mkType("Double -> Double -> Double") },
+ { i: mulDouble, t: mkType("Double -> Double -> Double") },
+ { i: eqDouble, t: mkType("Double -> Double -> Bool") },
];
diff --git a/lib/primitives/dynamic.js b/lib/primitives/dynamic.js
index 3ef2769..e00e67e 100644
--- a/lib/primitives/dynamic.js
+++ b/lib/primitives/dynamic.js
@@ -1,14 +1,6 @@
-import { inspect } from "node:util";
import { assignFn } from "../generics/generics.js";
-function inspectDynamic(_depth, options, inspect) {
- return `${inspect(this.i, options)} :: ${inspect(this.t, options)}`;
-}
-
-export const newDynamic = i => t => ({
- i, t,
- [inspect.custom]: inspectDynamic,
-});
+export const newDynamic = i => t => ({i, t});
export const getInst = lnk => lnk.i;
export const getType = lnk => lnk.t;
diff --git a/lib/primitives/dynamic.types.js b/lib/primitives/dynamic.types.js
index b3360a1..c36af30 100644
--- a/lib/primitives/dynamic.types.js
+++ b/lib/primitives/dynamic.types.js
@@ -4,13 +4,13 @@ import { apply, getInst, getType, newDynamic } from "./dynamic.js";
const mkType = getDefaultTypeParser();
export const ModuleDynamic = [
- newDynamic(newDynamic)(mkType("a -> Type -> Dynamic")),
+ { i: newDynamic, t: 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") ),
+ { i: getInst, t: mkType("Dynamic -> a") },
- newDynamic(getType)(mkType("Dynamic -> Type") ),
+ { i: getType, t: mkType("Dynamic -> Type") },
- newDynamic(apply)(mkType("Dynamic -> Dynamic -> Dynamic") ),
+ { i: apply, t: mkType("Dynamic -> Dynamic -> Dynamic") },
];
diff --git a/lib/primitives/int.types.js b/lib/primitives/int.types.js
index 4946edf..dd3a2b8 100644
--- a/lib/primitives/int.types.js
+++ b/lib/primitives/int.types.js
@@ -1,11 +1,10 @@
import { getDefaultTypeParser }from "../parser/type_parser.js";
-import { newDynamic } from "./dynamic.js";
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") ),
+ { i: addInt, t: mkType("Int -> Int -> Int") },
+ { i: mulInt, t: mkType("Int -> Int -> Int") },
+ { i: eqInt, t: mkType("Int -> Int -> Bool") },
];
diff --git a/lib/primitives/primitive_types.types.js b/lib/primitives/primitive_types.types.js
index 936247a..6bc2bca 100644
--- a/lib/primitives/primitive_types.types.js
+++ b/lib/primitives/primitive_types.types.js
@@ -1,30 +1,29 @@
-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 } 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 ),
+ { i: SymbolInt , t: UUID },
+ { i: SymbolBool , t: UUID },
+ { i: SymbolDouble , t: UUID },
+ { i: SymbolByte , t: UUID },
+ { i: SymbolChar , t: UUID },
+ { i: SymbolUnit , t: UUID },
+ { i: SymbolBottom , t: UUID },
+ { i: SymbolUUID , t: UUID },
+ { i: SymbolType , t: UUID },
+ { i: SymbolTop , t: UUID },
+ { i: SymbolDynamic , t: 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 ),
+ { i: Int , t: Type },
+ { i: Bool , t: Type },
+ { i: Double , t: Type },
+ { i: Byte , t: Type },
+ { i: Char , t: Type },
+ { i: Unit , t: Type },
+ { i: Bottom , t: Type },
+ { i: UUID , t: Type },
+ { i: Type , t: Type },
+ { i: Top , t: Type },
+ { i: Dynamic , t: Type },
];
diff --git a/lib/primitives/symbol.types.js b/lib/primitives/symbol.types.js
index 23ff8f8..31453c2 100644
--- a/lib/primitives/symbol.types.js
+++ b/lib/primitives/symbol.types.js
@@ -1,10 +1,9 @@
import { getDefaultTypeParser } from "../parser/type_parser.js"
-import { newDynamic } from "./dynamic.js";
import { eqSymbol, getHumanReadableName } from "./symbol.js";
const mkType = getDefaultTypeParser();
export const ModuleSymbol = [
- newDynamic(getHumanReadableName)(mkType("UUID -> String")),
- newDynamic(eqSymbol)(mkType("UUID -> UUID -> Bool")),
+ { i: getHumanReadableName, t: mkType("UUID -> String")},
+ { i: eqSymbol, t: mkType("UUID -> UUID -> Bool")},
];
diff --git a/lib/primitives/type.types.js b/lib/primitives/type.types.js
index 20f6893..a840c79 100644
--- a/lib/primitives/type.types.js
+++ b/lib/primitives/type.types.js
@@ -1,14 +1,13 @@
// a module is just a set of typed objects
import { getDefaultTypeParser } from "../parser/type_parser.js";
-import { newDynamic } from "./dynamic.js";
import { eqType, getParams, getSymbol } from "./type.js";
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]")),
+ {i: eqType , t: mkType("Type -> Type -> Bool")},
+ {i: getSymbol, t: mkType("Type -> UUID")},
+ {i: getParams, t: mkType("Type -> [Type -> Type]")},
];
diff --git a/lib/primitives/unit.types.js b/lib/primitives/unit.types.js
index 664aba6..33f64e5 100644
--- a/lib/primitives/unit.types.js
+++ b/lib/primitives/unit.types.js
@@ -1,10 +1,9 @@
import { getDefaultTypeParser } from "../parser/type_parser.js";
-import { newDynamic } from "./dynamic.js";
import { eqUnit, unit } from "./unit.js";
const mkType = getDefaultTypeParser();
export const ModuleUnit = [
- newDynamic(unit )(mkType("Unit")),
- newDynamic(eqUnit)(mkType("Unit -> Unit -> Bool")),
+ {i: unit , t: mkType("Unit")},
+ {i: eqUnit, t: mkType("Unit -> Unit -> Bool")},
];
diff --git a/lib/structures/dict.types.js b/lib/structures/dict.types.js
index cfab95c..c27ff43 100644
--- a/lib/structures/dict.types.js
+++ b/lib/structures/dict.types.js
@@ -1,7 +1,6 @@
import { makeTypeParser } from "../parser/type_parser.js";
import { makeTypeConstructor } from "../meta/type_constructor.js";
import { emptyDict, first, has, last, length, read, remove, set } from "./dict.js";
-import { newDynamic } from "../primitives/dynamic.js";
export const symbolDictIterator = 'DictIterator__d9d175b6bfd1283f00851a99787d0499';
@@ -13,12 +12,12 @@ 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(first )(mkType("(a => b) -> (a |=>| b)")),
- newDynamic(last )(mkType("(a => b) -> (a |=>| b)")),
- newDynamic(read )(mkType("(a |=>| b) -> (Unit + ((a*b) * (a |=>| b)))")),
+ { i: emptyDict , t: mkType("(a -> a -> Int) -> (a => b)") },
+ { i: has , t: mkType("(a => b) -> a -> Bool")},
+ { i: set , t: mkType("(a => b) -> a -> b -> (a => b)")},
+ { i: remove , t: mkType("(a => b) -> a -> (a => b)")},
+ { i: length , t: mkType("(a => b) -> Int")},
+ { i: first , t: mkType("(a => b) -> (a |=>| b)")},
+ { i: last , t: mkType("(a => b) -> (a |=>| b)")},
+ { i: read , t: mkType("(a |=>| b) -> (Unit + ((a*b) * (a |=>| b)))")},
];
diff --git a/lib/structures/list.types.js b/lib/structures/list.types.js
index 6ccb965..8801276 100644
--- a/lib/structures/list.types.js
+++ b/lib/structures/list.types.js
@@ -1,16 +1,15 @@
import { getDefaultTypeParser }from "../parser/type_parser.js";
-import { newDynamic } from "../primitives/dynamic.js";
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("[a] -> (b -> a -> b) -> b -> b")),
+ { i: emptyList, t: mkType("[a]")},
+ { i: get , t: mkType("[a] -> Int -> a")},
+ { i: put , t: mkType("[a] -> Int -> a -> [a]")},
+ { i: push , t: mkType("[a] -> a -> [a]")},
+ { i: pop , t: mkType("[a] -> a")},
+ { i: map , t: mkType("[a] -> (a -> b) -> [b]")},
+ { i: length , t: mkType("[a] -> Int")},
+ { i: fold , t: mkType("[a] -> (b -> a -> b) -> b -> b")},
];
diff --git a/lib/structures/product.types.js b/lib/structures/product.types.js
index 7489c3f..3e44a99 100644
--- a/lib/structures/product.types.js
+++ b/lib/structures/product.types.js
@@ -1,11 +1,10 @@
import { getDefaultTypeParser } from "../parser/type_parser.js";
-import { newDynamic } from "../primitives/dynamic.js";
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" ) ),
+ { i: newProduct, t: mkType("a -> b -> (a * b)") },
+ { i: getLeft , t: mkType("(a * b) -> a" ) },
+ { i: getRight , t: mkType("(a * b) -> b" ) },
];
diff --git a/lib/structures/set.types.js b/lib/structures/set.types.js
index 1f02388..82827a8 100644
--- a/lib/structures/set.types.js
+++ b/lib/structures/set.types.js
@@ -1,7 +1,6 @@
import { makeTypeParser } from "../parser/type_parser.js";
import { makeTypeConstructor } from "../meta/type_constructor.js";
import { emptySet, has, add, remove, length, first, read, last, fold } from "./set.js";
-import { newDynamic } from "../primitives/dynamic.js";
export const symbolSetIterator = 'SetIterator__f6b0ddd78ed41c58e5a442f2681da011';
@@ -12,13 +11,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("{a} -> (b -> a -> b) -> b")),
- newDynamic(first )(mkType("{a} -> ")),
- newDynamic(last )(mkType("{a} -> ")),
- newDynamic(read )(mkType(" -> (Unit + (a * ))")),
+ { i: emptySet , t: mkType("(a -> a -> Int) -> {a}") },
+ { i: has , t: mkType("{a} -> a -> Bool")},
+ { i: add , t: mkType("{a} -> a -> {a}")},
+ { i: remove , t: mkType("{a} -> a -> {a}")},
+ { i: length , t: mkType("{a} -> Int")},
+ { i: fold , t: mkType("{a} -> (b -> a -> b) -> b")},
+ { i: first , t: mkType("{a} -> ")},
+ { i: last , t: mkType("{a} -> ")},
+ { i: read , t: mkType(" -> (Unit + (a * ))")},
];
diff --git a/lib/structures/struct.types.js b/lib/structures/struct.types.js
index 209a4e0..88b149c 100644
--- a/lib/structures/struct.types.js
+++ b/lib/structures/struct.types.js
@@ -57,10 +57,10 @@ export const makeModuleStruct = type => fields => {
const getterTypes = makeGettersTypes(fields);
const getters = makeGetters(fieldNames);
const module = [
- // newDynamic(type)(Type),
+ // {i: type, t: Type},
// constructor
- newDynamic(ctor)(ctorType),
+ {i: ctor, t: ctorType},
// getters:
...zip(getters, getterTypes)
@@ -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]")),
+ {i: structType, t: mkType("[String*Type] -> Type")},
+ {i: makeModuleStruct, t: mkType("[String*Type] -> [Dynamic]")},
];
diff --git a/lib/structures/sum.types.js b/lib/structures/sum.types.js
index a9fd8ac..38741e0 100644
--- a/lib/structures/sum.types.js
+++ b/lib/structures/sum.types.js
@@ -1,11 +1,10 @@
import { getDefaultTypeParser }from "../parser/type_parser.js";
-import { newDynamic } from "../primitives/dynamic.js";
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") ),
+ { i: newLeft , t: mkType("a -> (a + b)") },
+ { i: newRight , t: mkType("b -> (a + b)") },
+ { i: match , t: mkType("(a + b) -> (a -> c) -> (b -> c) -> c") },
];
diff --git a/lib/structures/type_constructors.types.js b/lib/structures/type_constructors.types.js
index bbc7b85..d0acf22 100644
--- a/lib/structures/type_constructors.types.js
+++ b/lib/structures/type_constructors.types.js
@@ -1,5 +1,4 @@
import { makeTypeConstructor } from "../meta/type_constructor.js";
-import { newDynamic } from "../primitives/dynamic.js";
import { Type, UUID } from "../primitives/primitive_types.js";
import { symbolDict, symbolFunction, symbolList, symbolProduct, symbolSet, symbolSum } from "./type_constructors.js";
@@ -11,12 +10,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 ),
+ { i: symbolSet , t: UUID },
+ { i: symbolList , t: UUID },
+ { i: symbolProduct , t: UUID },
+ { i: symbolSum , t: UUID },
+ { i: symbolDict , t: UUID },
+ { i: symbolFunction , t: UUID },
];
const unaryTypeConstructor = fnType(_ => Type)(_ => Type);
@@ -24,10 +23,10 @@ const unaryTypeConstructor = fnType(_ => Type)(_ => Type);
const binaryTypeConstructor = fnType(_ => Type)(_ => unaryTypeConstructor);
export const ModuleTypeConstructors = [
- newDynamic(setType )(unaryTypeConstructor ),
- newDynamic(lsType )(unaryTypeConstructor ),
- newDynamic(prodType )(binaryTypeConstructor ),
- newDynamic(sumType )(binaryTypeConstructor ),
- newDynamic(dictType )(binaryTypeConstructor ),
- newDynamic(fnType )(binaryTypeConstructor ),
+ { i: setType , t: unaryTypeConstructor },
+ { i: lsType , t: unaryTypeConstructor },
+ { i: prodType , t: binaryTypeConstructor },
+ { i: sumType , t: binaryTypeConstructor },
+ { i: dictType , t: binaryTypeConstructor },
+ { i: fnType , t: binaryTypeConstructor },
];