diff --git a/index.d.ts b/index.d.ts index a6fe6e2..40e7384 100644 --- a/index.d.ts +++ b/index.d.ts @@ -160,6 +160,11 @@ export const symbolUUID: string; export const symbolUnit: string; +export const symbolSlot: String; +export const symbolValue: String; +export const symbolTransformation: String; +export const symbolWrite: String; + export const unit: { }; diff --git a/index.js b/index.js index 3b3934c..b352e7f 100644 --- a/index.js +++ b/index.js @@ -21,7 +21,6 @@ export * from "./lib/stdlib.js"; export * from "./lib/compare/type.js"; export * from "./lib/compare/dynamic.js"; export * from "./lib/compare/dynamic.types.js"; -export * from "./lib/compare/versioning.js"; export * from "./lib/compare/type.types.js"; export * from "./lib/compare/structures.js"; export * from "./lib/compare/primitives.js"; @@ -49,6 +48,9 @@ export * from "./lib/util/pretty.js"; export * from "./lib/environment/env.js"; export * from "./lib/meta/type_constructor.types.js"; export * from "./lib/meta/type_constructor.js"; +export * from "./lib/versioning/static/value_slot.js"; +export * from "./lib/versioning/static/merge.js"; +export * from "./lib/versioning/static/compare.js"; // wrap these in namespace (their names overlap) export * as list from "./lib/structures/list.js"; diff --git a/lib/compare/versioning.js b/lib/compare/versioning.js deleted file mode 100644 index e483d5a..0000000 --- a/lib/compare/versioning.js +++ /dev/null @@ -1,35 +0,0 @@ -// Total ordering of slots and values (versioning library). -// Problem: A Value produced by a transformation can depend on other Values of any type! -// So, we cannot statically know the entire type -> resort to dynamic typing for these? - -export const compareSlots = compareElems => slotA => slotB => { - if (slotA.depth < slotB.depth) { - return -1; - } - if (slotB.depth < slotA.depth) { - return 1; - } - return compareValues(compareElems)(slotA.value)(slotB.value); -}; - -export const compareValues = compareElems => valA => valB => { - if (valA.kind < valB.kind) { - return -1; - } - if (valB.kind < valA.kind) { - return 1; - } - if (valA.kind === "literal") { - return compareElems(valA.out)(valB.out); - } - if (valA.kind === "read") { - return compareSlots(compareElems)(valA.slot)(valB.slot); - } - if (valA.kind === "transformation") { - const cmpIn = compareValues(compareElems)(valA.in)(valB.in); - if (cmpIn !== 0) { - return cmpIn; - } - return compareValues(compareElems)(valA.fn)(valB.fn); - } -}; diff --git a/lib/versioning/static/value_slot.js b/lib/versioning/static/value_slot.js index 3dd9b21..6b1a7b3 100644 --- a/lib/versioning/static/value_slot.js +++ b/lib/versioning/static/value_slot.js @@ -7,15 +7,20 @@ import { makeModuleEnum } from "../../structures/enum.types.js"; import { makeModuleStruct } from "../../structures/struct.types.js"; import { fnType } from "../../structures/type_constructors.types.js"; +export const symbolSlot = "Slot__318d1c1a9336c141336c461c6a3207b0"; +export const symbolValue = "Value__23fc00a2db1374bd3dc1a0ad2d8517ab"; +export const symbolTransformation = "Transformation__9eac70d7020c7c45d5a16f3f14b13083"; +export const symbolWrite = "Write__abaef8ddb5c167b5d2cedac111fcefd3"; + // Value and Slot each take 1 type parameter -export const Slot = makeTypeConstructor("Slot__318d1c1a9336c141336c461c6a3207b0")(1); -export const Value = makeTypeConstructor("Value__23fc00a2db1374bd3dc1a0ad2d8517ab")(1); +export const Slot = makeTypeConstructor(symbolSlot)(1); +export const Value = makeTypeConstructor(symbolValue)(1); // Transformation takes 2 type parameters -export const Transformation = makeTypeConstructor("Transformation__9eac70d7020c7c45d5a16f3f14b13083")(2); +export const Transformation = makeTypeConstructor(symbolTransformation)(2); // A Write-operation writes a value to a slot. The inner type of the Value and Slot must match. -export const Write = makeTypeConstructor("Write__abaef8ddb5c167b5d2cedac111fcefd3")(1); +export const Write = makeTypeConstructor(symbolWrite)(1); // Enum: Value const [