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.
34 lines
1.0 KiB
34 lines
1.0 KiB
import { $, Term, _, c, g, id, l, m, pipe } from './core';
|
|
import { EQ, GT, LT } from './ord';
|
|
|
|
m('bool');
|
|
|
|
export const True = g('True', l('t', l('_', 't')));
|
|
|
|
export const False = g('False', l('_', l('f', 'f')));
|
|
|
|
export const iif = g('iif', id);
|
|
|
|
export const not = g('not', l('b', c('b', False, True)));
|
|
|
|
export const cmp = g('cmp', l('l', l('r', c('l', c('r', EQ, GT), c('r', LT, EQ)))));
|
|
|
|
export const lt = g('lt', l('l', c('l', False)));
|
|
|
|
export const le = g('le', l('l', not._('l')._(True)));
|
|
|
|
export const eq = g('eq', l('l', l('r', c('l', 'r', not._('r')))));
|
|
|
|
export const ge = g('ge', l('l', pipe._(not)._(lt._('l'))));
|
|
|
|
export const gt = g('gt', l('l', pipe._(not)._(le._('l'))));
|
|
|
|
export const and = g('and', l('l', not._('l')._(False)));
|
|
|
|
export const or = g('or', l('l', c('l', True)));
|
|
|
|
export const xor = g('xor', l('l', l('r', c('l', not._('r'), 'r'))));
|
|
|
|
export const fromBoolean: (b: boolean) => Term = b => b ? True : False;
|
|
|
|
export const toBoolean: (b: Term) => boolean = b => $(b._(_(true))._(_(false)).reduce());
|
|
|