diff --git a/compare/primitives.js b/compare/primitives.js index cac01e7..d0aa60d 100644 --- a/compare/primitives.js +++ b/compare/primitives.js @@ -1,4 +1,4 @@ -// Total ordering of primitive types +import { Char, Double, Int, Unit } from "../primitives/types.js"; export const compareNumbers = x => y => { if (typeof(x) !== 'number' || typeof(y) !== 'number') { diff --git a/compare/structures.js b/compare/structures.js index d1f669d..6db9640 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 - return 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; + iterate(first(x))(first(y)); })(); }; diff --git a/compare/versioning.js b/compare/versioning.js index e483d5a..b546655 100644 --- a/compare/versioning.js +++ b/compare/versioning.js @@ -1,7 +1,3 @@ -// 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; diff --git a/examples/enum.js b/scripts/enum.js similarity index 100% rename from examples/enum.js rename to scripts/enum.js diff --git a/examples/generics.js b/scripts/generics.js similarity index 100% rename from examples/generics.js rename to scripts/generics.js diff --git a/examples/int_or_bool.js b/scripts/int_or_bool.js similarity index 100% rename from examples/int_or_bool.js rename to scripts/int_or_bool.js diff --git a/examples/main.js b/scripts/main.js similarity index 100% rename from examples/main.js rename to scripts/main.js diff --git a/examples/num.js b/scripts/num.js similarity index 100% rename from examples/num.js rename to scripts/num.js diff --git a/examples/rbtree_bench.js b/scripts/rbtree_bench.js similarity index 100% rename from examples/rbtree_bench.js rename to scripts/rbtree_bench.js diff --git a/examples/versioning.js b/scripts/versioning.js similarity index 100% rename from examples/versioning.js rename to scripts/versioning.js