From 639d70afa5371b13f515fe397bd0a7a3766298d1 Mon Sep 17 00:00:00 2001 From: Joeri Exelmans Date: Sat, 10 May 2025 09:14:58 +0200 Subject: [PATCH] (broken) modules are mappings from name to typed value --- extra/point/nominal.types.js | 16 ++++---- extra/point/structural.types.js | 16 ++++---- lib/compare/dynamic.types.js | 6 +-- lib/compare/primitives.types.js | 12 +++--- lib/compare/structures.types.js | 14 +++---- lib/compare/type.types.js | 2 +- lib/primitives/double.types.js | 6 +-- lib/primitives/dynamic.types.js | 15 +++---- lib/primitives/int.types.js | 6 +-- lib/primitives/primitive_types.types.js | 48 +++++++++++------------ lib/primitives/symbol.types.js | 4 +- lib/primitives/type.types.js | 6 +-- lib/primitives/unit.types.js | 4 +- lib/structures/dict.types.js | 18 ++++----- lib/structures/enum.types.js | 4 +- lib/structures/list.types.js | 16 ++++---- lib/structures/product.types.js | 6 +-- lib/structures/set.types.js | 18 ++++----- lib/structures/struct.types.js | 10 ++--- lib/structures/sum.types.js | 6 +-- lib/structures/type_constructors.types.js | 24 ++++++------ 21 files changed, 125 insertions(+), 132 deletions(-) diff --git a/extra/point/nominal.types.js b/extra/point/nominal.types.js index 2820937..3eb837a 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), + ["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"))], ]; diff --git a/extra/point/structural.types.js b/extra/point/structural.types.js index 69b2dbc..06d96f8 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") ), + ["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 = [ diff --git a/lib/compare/dynamic.types.js b/lib/compare/dynamic.types.js index 2dc1d4b..b71c07d 100644 --- a/lib/compare/dynamic.types.js +++ b/lib/compare/dynamic.types.js @@ -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")), -]; \ No newline at end of file + ["makeCompareFn" , newDynamic(makeCompareFn )(mkType("Type -> a -> a -> Ordering" ))], + ["compareDynamic", newDynamic(compareDynamic)(mkType("Dynamic -> Dynamic -> Ordering"))], +]; diff --git a/lib/compare/primitives.types.js b/lib/compare/primitives.types.js index 0895b14..93790cf 100644 --- a/lib/compare/primitives.types.js +++ b/lib/compare/primitives.types.js @@ -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"))], ]; diff --git a/lib/compare/structures.types.js b/lib/compare/structures.types.js index b1ee099..275716e 100644 --- a/lib/compare/structures.types.js +++ b/lib/compare/structures.types.js @@ -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"))], ]; diff --git a/lib/compare/type.types.js b/lib/compare/type.types.js index 306bc04..18fbe96 100644 --- a/lib/compare/type.types.js +++ b/lib/compare/type.types.js @@ -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"))], ]; diff --git a/lib/primitives/double.types.js b/lib/primitives/double.types.js index b13f3ba..2ffc40c 100644 --- a/lib/primitives/double.types.js +++ b/lib/primitives/double.types.js @@ -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" ))], ]; diff --git a/lib/primitives/dynamic.types.js b/lib/primitives/dynamic.types.js index b3360a1..ca472d1 100644 --- a/lib/primitives/dynamic.types.js +++ b/lib/primitives/dynamic.types.js @@ -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"))], ]; diff --git a/lib/primitives/int.types.js b/lib/primitives/int.types.js index 4946edf..b35ba88 100644 --- a/lib/primitives/int.types.js +++ b/lib/primitives/int.types.js @@ -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"))], ]; diff --git a/lib/primitives/primitive_types.types.js b/lib/primitives/primitive_types.types.js index 59d1a97..3a570a0 100644 --- a/lib/primitives/primitive_types.types.js +++ b/lib/primitives/primitive_types.types.js @@ -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)], ]; diff --git a/lib/primitives/symbol.types.js b/lib/primitives/symbol.types.js index 23ff8f8..72b5b6e 100644 --- a/lib/primitives/symbol.types.js +++ b/lib/primitives/symbol.types.js @@ -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"))], ]; diff --git a/lib/primitives/type.types.js b/lib/primitives/type.types.js index 20f6893..0f94708 100644 --- a/lib/primitives/type.types.js +++ b/lib/primitives/type.types.js @@ -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]"))], ]; diff --git a/lib/primitives/unit.types.js b/lib/primitives/unit.types.js index 664aba6..4926e9e 100644 --- a/lib/primitives/unit.types.js +++ b/lib/primitives/unit.types.js @@ -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"))], ]; diff --git a/lib/structures/dict.types.js b/lib/structures/dict.types.js index 11fd6ac..5aec705 100644 --- a/lib/structures/dict.types.js +++ b/lib/structures/dict.types.js @@ -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)))"))], ]; diff --git a/lib/structures/enum.types.js b/lib/structures/enum.types.js index 3c3fd6c..2c999b7 100644 --- a/lib/structures/enum.types.js +++ b/lib/structures/enum.types.js @@ -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), diff --git a/lib/structures/list.types.js b/lib/structures/list.types.js index cf30b5c..4a6abc9 100644 --- a/lib/structures/list.types.js +++ b/lib/structures/list.types.js @@ -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"))], ]; diff --git a/lib/structures/product.types.js b/lib/structures/product.types.js index 7489c3f..3b852f9 100644 --- a/lib/structures/product.types.js +++ b/lib/structures/product.types.js @@ -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" ))], ]; diff --git a/lib/structures/set.types.js b/lib/structures/set.types.js index 5e3556b..00c3483 100644 --- a/lib/structures/set.types.js +++ b/lib/structures/set.types.js @@ -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} -> " )), - newDynamic(last )(mkType("{a} -> " )), - newDynamic(read )(mkType(" -> (Unit + (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} -> " ))], + ["last" , newDynamic(last )(mkType("{a} -> " ))], + ["read" , newDynamic(read )(mkType(" -> (Unit + (a * ))" ))], ]; diff --git a/lib/structures/struct.types.js b/lib/structures/struct.types.js index 209a4e0..726cad4 100644 --- a/lib/structures/struct.types.js +++ b/lib/structures/struct.types.js @@ -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]"))], ]; diff --git a/lib/structures/sum.types.js b/lib/structures/sum.types.js index a9fd8ac..64aaae2 100644 --- a/lib/structures/sum.types.js +++ b/lib/structures/sum.types.js @@ -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"))], ]; diff --git a/lib/structures/type_constructors.types.js b/lib/structures/type_constructors.types.js index 32a42e1..08f57bb 100644 --- a/lib/structures/type_constructors.types.js +++ b/lib/structures/type_constructors.types.js @@ -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)], ];