import { int } from "./primitives.js"; export declare enum Relation { UNRELATED = 0, LESS = 1, EQUAL = 2, GREATER = 3 } export type Total = Relation.LESS | Relation.EQUAL | Relation.GREATER; export declare function relationAsNumber(r: Relation): number | undefined; export declare function invertRelation(relation: Relation): Relation; export interface Thing { name: string; is(value: any): value is T; assert(value: any): asserts value is T; display(value: T): string; } export interface Equality extends Thing { /** Here we can assume that `is(x)` and `is(y)` both hold. */ equal(x: T, y: T): boolean; } export interface Compare { compare(x: T, y: T): Relation; } export interface Order extends Equality, Compare { /** * Here we can assume that `is(x)` and `is(y)` both hold. * Must be compatible with {@link Equality.equals}: * `equal(x, y) === (compare(x, y) === Relation.EQUAL)` **/ compare(x: T, y: T): Relation; } export interface Hash extends Equality { /** * Here we can assume that `is(x)` holds. * Must be compatible with {@link Equality.equals}: * `equal(x, y)` implies `hash(x) === hash(y)` */ hash(x: T): int; } export interface Data extends Order, Hash { } export declare function mkThing(name: string | undefined, check: (value: any) => boolean, display?: (value: T) => string): Thing; export declare function assertThings(thing: Thing, ...values: T[]): void; export declare function mkEquality(name: string | undefined, check: (x: T) => boolean, equal: (x: T, y: T) => boolean, display?: (value: T) => string): Equality; export declare function mkOrder(name: string | undefined, check: (x: T) => boolean, compare: (x: T, y: T) => Relation, display?: (value: T) => string): Order; export declare function mkHash(name: string | undefined, check: (x: T) => boolean, equal: (x: T, y: T) => boolean, hashing: (x: T) => int, display?: (value: T) => string): Hash; export declare function mkOrderAndHash(name: string | undefined, check: (x: T) => boolean, compare: (x: T, y: T) => Relation, hash: (x: T) => int, display?: (value: T) => string): Order & Hash; export declare function mkData(name: string | undefined, check: (x: T) => boolean, compare: (x: T, y: T) => Relation, hash: (x: T) => int, display?: (value: T) => string): Data;