use newDynamic() everywhere instead of { i: ... , t: ... }

This commit is contained in:
Joeri Exelmans 2025-05-08 23:56:58 +02:00
parent 34d06aa82a
commit e1a2139cb4
22 changed files with 141 additions and 124 deletions

View file

@ -6,6 +6,6 @@ const mkType = getDefaultTypeParser();
export const ModuleDouble = [
newDynamic(addDouble)(mkType("Double -> Double -> Double")),
{ i: mulDouble, t: mkType("Double -> Double -> Double") },
{ i: eqDouble, t: mkType("Double -> Double -> Bool") },
newDynamic(mulDouble)(mkType("Double -> Double -> Double") ),
newDynamic(eqDouble)(mkType("Double -> Double -> Bool") ),
];

View file

@ -4,13 +4,13 @@ import { apply, getInst, getType, newDynamic } from "./dynamic.js";
const mkType = getDefaultTypeParser();
export const ModuleDynamic = [
{ i: newDynamic, t: mkType("a -> Type -> Dynamic")},
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)
{ i: getInst, t: mkType("Dynamic -> a") },
newDynamic(getInst)(mkType("Dynamic -> a") ),
{ i: getType, t: mkType("Dynamic -> Type") },
newDynamic(getType)(mkType("Dynamic -> Type") ),
{ i: apply, t: mkType("Dynamic -> Dynamic -> Dynamic") },
newDynamic(apply)(mkType("Dynamic -> Dynamic -> Dynamic") ),
];

View file

@ -1,10 +1,11 @@
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 = [
{ i: addInt, t: mkType("Int -> Int -> Int") },
{ i: mulInt, t: mkType("Int -> Int -> Int") },
{ i: eqInt, t: mkType("Int -> Int -> Bool") },
newDynamic(addInt)(mkType("Int -> Int -> Int") ),
newDynamic(mulInt)(mkType("Int -> Int -> Int") ),
newDynamic(eqInt)(mkType("Int -> Int -> Bool") ),
];

View file

@ -1,29 +1,30 @@
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 = [
{ 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 },
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 ),
];
export const ModulePrimitiveTypes = [
{ 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 },
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 ),
];

View file

@ -1,9 +1,10 @@
import { getDefaultTypeParser } from "../parser/type_parser.js"
import { newDynamic } from "./dynamic.js";
import { eqSymbol, getHumanReadableName } from "./symbol.js";
const mkType = getDefaultTypeParser();
export const ModuleSymbol = [
{ i: getHumanReadableName, t: mkType("UUID -> String")},
{ i: eqSymbol, t: mkType("UUID -> UUID -> Bool")},
newDynamic(getHumanReadableName)(mkType("UUID -> String")),
newDynamic(eqSymbol)(mkType("UUID -> UUID -> Bool")),
];

View file

@ -1,13 +1,14 @@
// 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 = [
{i: eqType , t: mkType("Type -> Type -> Bool")},
{i: getSymbol, t: mkType("Type -> UUID")},
{i: getParams, t: mkType("Type -> [Type -> Type]")},
newDynamic(eqType )(mkType("Type -> Type -> Bool")),
newDynamic(getSymbol)(mkType("Type -> UUID")),
newDynamic(getParams)(mkType("Type -> [Type -> Type]")),
];

View file

@ -1,9 +1,10 @@
import { getDefaultTypeParser } from "../parser/type_parser.js";
import { newDynamic } from "./dynamic.js";
import { eqUnit, unit } from "./unit.js";
const mkType = getDefaultTypeParser();
export const ModuleUnit = [
{i: unit , t: mkType("Unit")},
{i: eqUnit, t: mkType("Unit -> Unit -> Bool")},
newDynamic(unit )(mkType("Unit")),
newDynamic(eqUnit)(mkType("Unit -> Unit -> Bool")),
];