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.
29 lines
1.0 KiB
29 lines
1.0 KiB
import { $, Term, _, g, l, n } from './core';
|
|
import { fromChar as _c, cmp as cmpc, eq as eqc, fromChar, toChar } from './char';
|
|
import { Cons, Nil, append, cmp as cmpl, eq as eql, ge as gel, gt as gtl, le as lel, lt as ltl, nul } from './list';
|
|
|
|
export { len, Cons, cons, snoc, append, repeat, iterate, get, update, set } from './list';
|
|
|
|
n('string');
|
|
|
|
export const Empty = g('Empty', Nil);
|
|
|
|
export const empty = g('empty', nul);
|
|
|
|
export const cmp = g('cmp', cmpl._(cmpc));
|
|
|
|
export const lt = g('lt', ltl._(cmpc));
|
|
|
|
export const le = g('le', lel._(cmpc));
|
|
|
|
export const eq = g('eq', eql._(eqc));
|
|
|
|
export const ge = g('ge', gel._(cmpc));
|
|
|
|
export const gt = g('gt', gtl._(cmpc));
|
|
|
|
export const wrap = g('wrap', l('w', l('c', append._('w')._(append._('c')._('w')))));
|
|
|
|
export const fromString: (xs: string) => Term = s => !s.length ? Nil : Cons._(fromChar(s[0]))._(_(() => fromString(s.slice(1))));
|
|
|
|
export const toString: (xs: Term) => string = s => $(s._(_(''))._(l('x', l('xs', _(({ x, xs }) => _(toChar(x) + toString(xs)))))));
|
|
|