progress with versioning
This commit is contained in:
parent
e106ced1ec
commit
d30f1312b6
2 changed files with 15 additions and 19 deletions
|
|
@ -1,5 +1,5 @@
|
|||
import { emptySet, add, length, forEach, union, has } from "../structures/set.js";
|
||||
import { getDepth, Slot, Value, Write } from "./value_slot.js";
|
||||
import { emptySet, add, length, forEach, has, remove } from "../structures/set.js";
|
||||
import { getDepth, Slot } from "./value_slot.js";
|
||||
import { compareSlot } from "./compare.js";
|
||||
import { makeTypeParser } from "../parser/type_parser.js";
|
||||
import { newDynamic } from "../primitives/dynamic.js";
|
||||
|
|
@ -20,6 +20,10 @@ export const findLCA = slotA => slotB => {
|
|||
}
|
||||
};
|
||||
|
||||
// returns
|
||||
// {slotA} if slotA is younger
|
||||
// {slotB} if slotB is younger
|
||||
// {slotA, slotB} if they are concurrent (conflicting)
|
||||
export const merge = slotA => slotB => {
|
||||
const lca = findLCA(slotA)(slotB);
|
||||
if (compareSlot(lca)(slotA) === 0) {
|
||||
|
|
@ -34,7 +38,7 @@ export const merge = slotA => slotB => {
|
|||
};
|
||||
|
||||
export const mergeN = slots => {
|
||||
let toDelete = emptySetOfSlots;
|
||||
let result = slots;
|
||||
forEach(slots)(slotA => {
|
||||
forEach(slots)(slotB => {
|
||||
// compare all non-identical pairs
|
||||
|
|
@ -44,26 +48,18 @@ export const mergeN = slots => {
|
|||
// if in the pair, one is an ancestor of the other,
|
||||
// only keep the other
|
||||
if (has(m)(slotA)) {
|
||||
toDelete = add(toDelete)(slotB);
|
||||
result = remove(result)(slotB);
|
||||
}
|
||||
}
|
||||
}
|
||||
});
|
||||
});
|
||||
let result = emptySetOfSlots;
|
||||
forEach(slots)(slot => {
|
||||
if (!has(toDelete)(slot)) {
|
||||
result = add(result)(slot);
|
||||
}
|
||||
})
|
||||
return result;
|
||||
};
|
||||
|
||||
const mkType = makeTypeParser({
|
||||
extraPrimitives: [
|
||||
["Value", Value],
|
||||
["Slot" , Slot ],
|
||||
["Write", Write],
|
||||
["Slot" , Slot],
|
||||
],
|
||||
});
|
||||
|
||||
|
|
|
|||
|
|
@ -20,8 +20,8 @@ const [
|
|||
[, {i: matchValue}],
|
||||
] = makeModuleEnum(Value)([
|
||||
{l: "literal" , r: Dynamic},
|
||||
{l: "read" , r: Write}, // a 'read' reads the result of a Write
|
||||
{l: "transform", r: Transformation},
|
||||
{l: "read" , r: Write}, // <- a 'read' reads the result of a Write (to a Slot)
|
||||
{l: "transform", r: Transformation}, // <- result of a function call
|
||||
]);
|
||||
|
||||
// Enum: Slot
|
||||
|
|
@ -36,7 +36,7 @@ const [
|
|||
{l: "write", r: Write},
|
||||
]);
|
||||
|
||||
// Struct: Transformation
|
||||
// Struct: Transformation (i.e., a function call)
|
||||
const [
|
||||
// constructor
|
||||
[, {i: newTransformation}],
|
||||
|
|
@ -45,9 +45,9 @@ const [
|
|||
// [, {i: getFn}],
|
||||
// [, {i: getOutput}],
|
||||
] = makeModuleStruct(Transformation)([
|
||||
{l: "input" , r: Value },
|
||||
{l: "fn" , r: Value },
|
||||
{l: "output", r: Dynamic},
|
||||
{l: "input" , r: Value }, // <- the input is a value (e.g., could be the result of a Transformation itself)
|
||||
{l: "fn" , r: Value }, // <- the function is also a value (e.g., could also be result of a transformation, e.g., when currying)
|
||||
{l: "output", r: Dynamic}, // <- the result
|
||||
]);
|
||||
|
||||
// Struct: Write
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue