From 28f60e77be6b300247f648791951846bd073678c Mon Sep 17 00:00:00 2001 From: Joeri Exelmans Date: Fri, 18 Apr 2025 09:14:09 +0200 Subject: [PATCH 1/3] rename dir scripts -> examples --- {scripts => examples}/enum.js | 0 {scripts => examples}/generics.js | 0 {scripts => examples}/int_or_bool.js | 0 {scripts => examples}/main.js | 0 {scripts => examples}/num.js | 0 {scripts => examples}/rbtree_bench.js | 0 {scripts => examples}/versioning.js | 0 7 files changed, 0 insertions(+), 0 deletions(-) rename {scripts => examples}/enum.js (100%) rename {scripts => examples}/generics.js (100%) rename {scripts => examples}/int_or_bool.js (100%) rename {scripts => examples}/main.js (100%) rename {scripts => examples}/num.js (100%) rename {scripts => examples}/rbtree_bench.js (100%) rename {scripts => examples}/versioning.js (100%) diff --git a/scripts/enum.js b/examples/enum.js similarity index 100% rename from scripts/enum.js rename to examples/enum.js diff --git a/scripts/generics.js b/examples/generics.js similarity index 100% rename from scripts/generics.js rename to examples/generics.js diff --git a/scripts/int_or_bool.js b/examples/int_or_bool.js similarity index 100% rename from scripts/int_or_bool.js rename to examples/int_or_bool.js diff --git a/scripts/main.js b/examples/main.js similarity index 100% rename from scripts/main.js rename to examples/main.js diff --git a/scripts/num.js b/examples/num.js similarity index 100% rename from scripts/num.js rename to examples/num.js diff --git a/scripts/rbtree_bench.js b/examples/rbtree_bench.js similarity index 100% rename from scripts/rbtree_bench.js rename to examples/rbtree_bench.js diff --git a/scripts/versioning.js b/examples/versioning.js similarity index 100% rename from scripts/versioning.js rename to examples/versioning.js From c51e517b66f92a36aa3f7393af6fae7d16ad6292 Mon Sep 17 00:00:00 2001 From: Joeri Exelmans Date: Fri, 18 Apr 2025 09:14:42 +0200 Subject: [PATCH 2/3] fix missing return stmt --- compare/structures.js | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/compare/structures.js b/compare/structures.js index 6db9640..d1f669d 100644 --- a/compare/structures.js +++ b/compare/structures.js @@ -1,10 +1,10 @@ +// Total ordering of composed types + import { compareNumbers } from "./primitives.js" import { get, length as lengthLs } from "../structures/list.js"; import { read, length as lengthSet } from "../structures/set.js"; import { constructorProduct, getLeft, getRight } from "../structures/product.js"; import { match } from "../structures/sum.js"; -import { makeGeneric } from "../generics/generics.js"; -import { lsType } from "../structures/types.js"; // (a -> a -> Int) -> [a] -> [a] -> Int export const compareLists = compareElems => x => y => { @@ -48,13 +48,13 @@ export const compareSets = compareElems => x => y => { // because of the underlying red-black tree, iteration happens in ordered fashion const iterate = iterX => iterY => read(iterX) - (keyX => nextX => - read(iterY) - // we could also use the comparison function that is embedded in the set object, - // but to be consistent with the other comparison-functions, we don't. - (keyY => nextY => compareElems(keyX)(keyY) || iterate(nextX)(nextY)) - (0)) // end of set y (we'll never get here because sets are same size) - (0) // end of set x; - iterate(first(x))(first(y)); + (keyX => nextX => + read(iterY) + // we could also use the comparison function that is embedded in the set object, + // but to be consistent with the other comparison-functions, we don't. + (keyY => nextY => compareElems(keyX)(keyY) || iterate(nextX)(nextY)) + (0)) // end of set y (we'll never get here because sets are same size) + (0); // end of set x + return iterate(first(x))(first(y)); })(); }; From 3be17c11485a48b4cf5d33f9fb507ddce10690b9 Mon Sep 17 00:00:00 2001 From: Joeri Exelmans Date: Fri, 18 Apr 2025 09:14:55 +0200 Subject: [PATCH 3/3] doc --- compare/primitives.js | 2 +- compare/versioning.js | 4 ++++ 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/compare/primitives.js b/compare/primitives.js index d0aa60d..cac01e7 100644 --- a/compare/primitives.js +++ b/compare/primitives.js @@ -1,4 +1,4 @@ -import { Char, Double, Int, Unit } from "../primitives/types.js"; +// Total ordering of primitive types export const compareNumbers = x => y => { if (typeof(x) !== 'number' || typeof(y) !== 'number') { diff --git a/compare/versioning.js b/compare/versioning.js index b546655..e483d5a 100644 --- a/compare/versioning.js +++ b/compare/versioning.js @@ -1,3 +1,7 @@ +// 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;