This commit is contained in:
Joeri Exelmans 2025-05-09 16:55:18 +02:00
parent 1f2249e75a
commit 63b1aa6238
2 changed files with 4 additions and 4 deletions

View file

@ -5,7 +5,7 @@ import { symbolDictIterator } from "../structures/dict.types.js";
import { symbolSetIterator } from "../structures/set.types.js"; import { symbolSetIterator } from "../structures/set.types.js";
import { symbolDict, symbolFunction, symbolList, symbolProduct, symbolSet, symbolSum } from "../structures/type_constructors.js"; import { symbolDict, symbolFunction, symbolList, symbolProduct, symbolSet, symbolSum } from "../structures/type_constructors.js";
import { prettyT } from "../util/pretty.js"; import { prettyT } from "../util/pretty.js";
import { compareBools, compareDoubles, compareOrderings, compareStrings, compareSymbols, compareUnits } from "./primitives.js"; import { compareBools, compareDoubles, compareInts, compareOrderings, compareStrings, compareSymbols, compareUnits } from "./primitives.js";
import { compareDictIterators, compareDicts, compareFunctions, compareLists, compareProducts, compareSetIterators, compareSets, compareSums } from "./structures.js"; import { compareDictIterators, compareDicts, compareFunctions, compareLists, compareProducts, compareSetIterators, compareSets, compareSums } from "./structures.js";
import { compareTypes } from "./type.js"; import { compareTypes } from "./type.js";
@ -16,7 +16,7 @@ export const compareDynamic = x => y =>
const cannotCompareTypeVarInstances = _ => _ => { throw new Error("Cannot compare instance of type variables"); } const cannotCompareTypeVarInstances = _ => _ => { throw new Error("Cannot compare instance of type variables"); }
const typeSymbolToCmp = new Map([ const typeSymbolToCmp = new Map([
[SymbolInt , compareDoubles ], [SymbolInt , compareInts ],
[SymbolBool , compareBools ], [SymbolBool , compareBools ],
[SymbolDouble , compareDoubles ], [SymbolDouble , compareDoubles ],
[SymbolByte , compareDoubles ], [SymbolByte , compareDoubles ],

View file

@ -2,14 +2,14 @@
export const compareInts = x => y => { export const compareInts = x => y => {
if (typeof(x) !== 'bigint' || typeof(y) !== 'bigint') { if (typeof(x) !== 'bigint' || typeof(y) !== 'bigint') {
throw new Error(`was only meant to compare bigints! got ${x} and ${y}`); throw new Error(`was only meant to compare bigints! got ${x} (${typeof(x)}) and ${y} (${typeof(y)})`);
} }
return (x < y) ? -1 : (x > y) ? 1 : 0; return (x < y) ? -1 : (x > y) ? 1 : 0;
}; };
export const compareDoubles = x => y => { export const compareDoubles = x => y => {
if (typeof(x) !== 'number' || typeof(y) !== 'number') { if (typeof(x) !== 'number' || typeof(y) !== 'number') {
throw new Error(`was only meant to compare numbers! got ${x} and ${y}`); throw new Error(`was only meant to compare numbers! got ${x} (${typeof(x)}) and ${y} (${typeof(y)})`);
} }
return (x < y) ? -1 : (x > y) ? 1 : 0; return (x < y) ? -1 : (x > y) ? 1 : 0;
}; };