(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
|
|
@ -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"))],
|
||||
];
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue