Compare commits
No commits in common. "3be17c11485a48b4cf5d33f9fb507ddce10690b9" and "bc9dce4b9cab7bd24f4eb62db1c15954a6bb2ff0" have entirely different histories.
3be17c1148
...
bc9dce4b9c
10 changed files with 11 additions and 15 deletions
|
|
@ -1,4 +1,4 @@
|
||||||
// Total ordering of primitive types
|
import { Char, Double, Int, Unit } from "../primitives/types.js";
|
||||||
|
|
||||||
export const compareNumbers = x => y => {
|
export const compareNumbers = x => y => {
|
||||||
if (typeof(x) !== 'number' || typeof(y) !== 'number') {
|
if (typeof(x) !== 'number' || typeof(y) !== 'number') {
|
||||||
|
|
|
||||||
|
|
@ -1,10 +1,10 @@
|
||||||
// Total ordering of composed types
|
|
||||||
|
|
||||||
import { compareNumbers } from "./primitives.js"
|
import { compareNumbers } from "./primitives.js"
|
||||||
import { get, length as lengthLs } from "../structures/list.js";
|
import { get, length as lengthLs } from "../structures/list.js";
|
||||||
import { read, length as lengthSet } from "../structures/set.js";
|
import { read, length as lengthSet } from "../structures/set.js";
|
||||||
import { constructorProduct, getLeft, getRight } from "../structures/product.js";
|
import { constructorProduct, getLeft, getRight } from "../structures/product.js";
|
||||||
import { match } from "../structures/sum.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
|
// (a -> a -> Int) -> [a] -> [a] -> Int
|
||||||
export const compareLists = compareElems => x => y => {
|
export const compareLists = compareElems => x => y => {
|
||||||
|
|
@ -54,7 +54,7 @@ export const compareSets = compareElems => x => y => {
|
||||||
// but to be consistent with the other comparison-functions, we don't.
|
// but to be consistent with the other comparison-functions, we don't.
|
||||||
(keyY => nextY => compareElems(keyX)(keyY) || iterate(nextX)(nextY))
|
(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 y (we'll never get here because sets are same size)
|
||||||
(0); // end of set x
|
(0) // end of set x;
|
||||||
return iterate(first(x))(first(y));
|
iterate(first(x))(first(y));
|
||||||
})();
|
})();
|
||||||
};
|
};
|
||||||
|
|
|
||||||
|
|
@ -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 => {
|
export const compareSlots = compareElems => slotA => slotB => {
|
||||||
if (slotA.depth < slotB.depth) {
|
if (slotA.depth < slotB.depth) {
|
||||||
return -1;
|
return -1;
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue