You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
31 lines
800 B
31 lines
800 B
import { toNative as $$, L, P, _, fromNative as __ } from './core';
|
|
import { Bool, False, True } from './bool';
|
|
|
|
export type Ord = L<<T extends P>(lt: T) => L<(eq: T) => L<(gt: T) => T>>>;
|
|
|
|
export const enum NOrd {
|
|
LT,
|
|
EQ,
|
|
GT,
|
|
};
|
|
|
|
export const LT: Ord
|
|
= _(lt => _(_eq => _(_gt => lt))) as Ord;
|
|
|
|
export const EQ: Ord
|
|
= _(_lt => _(eq => _(_gt => eq)));
|
|
|
|
export const GT: Ord
|
|
= _(_lt => _(_eq => _(gt => gt)));
|
|
|
|
export const eq: L<(l: Ord) => L<(r: Ord) => Bool>>
|
|
= _(l => _(r => l
|
|
._(r._(True)._(False)._(False))
|
|
._(r._(False)._(True)._(False))
|
|
._(r._(False)._(False)._(True))));
|
|
|
|
export const fromNOrd: (b: NOrd) => Ord
|
|
= o => o === NOrd.LT ? LT : o === NOrd.EQ ? EQ : GT;
|
|
|
|
export const toNOrd: (b: Ord) => NOrd
|
|
= o => $$(o._(__(NOrd.LT))._(__(NOrd.EQ))._(__(NOrd.GT)));
|
|
|