simplify: no distinction between generic types and 'normal' types.

This commit is contained in:
Joeri Exelmans 2025-05-08 16:58:07 +02:00
parent b4826605af
commit a664ddac8a
27 changed files with 535 additions and 360 deletions

View file

@ -1,25 +1,31 @@
import { add, emptySet, forEach } from "../../structures/set.js";
import { add, emptySet, forEach } from "../structures/set.js";
import { deepEqual } from "../util/util.js";
import {inspect} from "node:util";
import { compareSlots } from "../compare/versioning.js";
// UUID -> Value<a> -> Slot<a>
export const newSlot = uuid => value => ({
overwrites: uuid,
value,
depth: 1,
export const newSlot = uuid => ({
kind: "new",
uuid,
depth: 0,
[inspect.custom]: (depth, options, inspect) => `newSlot(${inspect(uuid)}, ${inspect(value)})`,
});
// Slot<a> -> Value<a> -> Slot<a>
export const overwrite = slot => value => ({
kind: "overwrite",
overwrites: slot,
value,
depth: slot.depth + 1,
// [inspect.custom]: (depth, options, inspect) => `overwrite(${inspect(slot)}, ${inspect(value)})`,
});
const slotsEqual = slotA => slotB => {
}
const findLCA = slotA => slotB => {
if (slotA.depth === slotB.depth) {
}
if (deepEqual(slotA, slotB)) {
return slotA;
}
@ -31,7 +37,6 @@ const findLCA = slotA => slotB => {
}
};
// Slot<a> -> Slot<a> -> MergeResult<a>
export const merge = compareElems => slotA => slotB => {
const lca = findLCA(slotA)(slotB);
if (lca === undefined) {
@ -49,7 +54,6 @@ export const merge = compareElems => slotA => slotB => {
// return new Set([slotA, slotB]);
};
// MergeResult<a> -> MergeResult<a> -> MergeResult<a>
export const merge2 = compareElems => mA => mB => {
let result = emptySet(compareSlots(compareElems));
forEach(mA)(slotOfA => {