import { toNative as $$, L, _, fromNative as __ } from './core'; import { Ord } from './ord'; import { Bool } from './bool'; import { fromNumber as _nn } from './num'; import { toChar as $c, Char, fromChar as _c, cmp as cmpc, eq as eqc } from './char'; import { Cons, List, Nil, cmp as cmpl, concat, cons, eq as eql, ge as gel, gt as gtl, le as lel, lt as ltl } from './list'; export type String = List; export { Nil as Empty, nul as empty, len, Cons, cons, snoc, append, get, update, set } from './list'; export const cmp: L<(l: String) => L<(r: String) => Ord>> = cmpl._(cmpc); export const lt: L<(l: String) => L<(r: String) => Bool>> = ltl._(cmpc); export const le: L<(l: String) => L<(r: String) => Bool>> = lel._(cmpc); export const eq: L<(l: String) => L<(r: String) => Bool>> = eql._(eqc); export const ge: L<(l: String) => L<(r: String) => Bool>> = gel._(cmpc); export const gt: L<(l: String) => L<(r: String) => Bool>> = gtl._(cmpc); export const show: L<(s: String) => String> = _(s => concat._(cons._(fromString('"'))._(cons._(s)._(cons._(fromString('"'))._(Nil))))); export const fromString: (xs: string) => String = xs => xs.length === 0 ? Nil : Cons._(_c(xs[0]))._(new L(() => fromString(xs.slice(1)).value)); export const toString: (xs: String) => string = xs => $$(xs._(__(''))._(_(x => _(xs => __($c(x) + toString(xs))))));