Fix linter errors

This commit is contained in:
Freywar Ulvnaudgari
2024-08-09 18:05:07 +03:00
parent ba013e3344
commit f8b5333c1c
11 changed files with 41 additions and 41 deletions
+12 -12
View File
@@ -4,7 +4,7 @@ import { Num, Zero, ge, ifz, pred, succ } from './num';
import { x00 } from './byte';
import { Char, fromChar as _c, dec as cdec, inc as cinc, eq, ifn } from './char';
import { Pair, first, fst, second, snd, uncurry } from './pair';
import { List, Nil, cons, head, repeat, set, singleton, tail, update } from './list';
import { List, cons, head, repeat, set, singleton, tail, update } from './list';
import { Empty, String, get, len, snoc } from './string';
type Program = Pair<List<Num>, String>;
@@ -57,8 +57,8 @@ const prev: L<(t: State) => State>
const jump: L<(d: Num) => L<(s: State) => State>>
= _(d => _(s =>
iif(command(_c('['))(s))(jump(succ(d)))
(iif(command(_c(']'))(s))(ifz(pred(d))(cnst(s))(jump(pred(d))))
(jump(d)))(advance(s))));
(iif(command(_c(']'))(s))(ifz(pred(d))(cnst(s))(jump(pred(d))))
(jump(d)))(advance(s))));
const whlnz: L<(t: State) => State>
= _(s => ifn(read(s))(jump(Zero))(save)(s));
@@ -68,15 +68,15 @@ const endwhl: L<(t: State) => State>
const exec: L<(s: State) => State>
= _(s => iif<State>(done(s))(s)(exec(advance
(iif(command(_c('>'))(s))(next)
(iif(command(_c('<'))(s))(prev)
(iif(command(_c('+'))(s))(inc)
(iif(command(_c('-'))(s))(dec)
(iif(command(_c('.'))(s))(output)
(iif(command(_c(','))(s))(input)
(iif(command(_c('['))(s))(whlnz)
(iif(command(_c(']'))(s))(endwhl)
(id))))))))(s)))));
(iif(command(_c('>'))(s))(next)
(iif(command(_c('<'))(s))(prev)
(iif(command(_c('+'))(s))(inc)
(iif(command(_c('-'))(s))(dec)
(iif(command(_c('.'))(s))(output)
(iif(command(_c(','))(s))(input)
(iif(command(_c('['))(s))(whlnz)
(iif(command(_c(']'))(s))(endwhl)
(id))))))))(s)))));
export const run: L<(p: String) => L<(i: String) => String>>
= _(p => _(i => snd(snd(snd(exec(Pair(Pair(singleton(Zero))(p))(Pair(Pair(Zero)(repeat(x00)))(Pair(i)(Empty)))))))));
+3 -3
View File
@@ -1,10 +1,10 @@
export type L<T extends (v: P) => L<any>> = T & { run: () => T; }
export type L<T extends (v: P) => L<any>> = T & { run: () => T };
export function ___<T extends (v: P) => L<any>>(run: () => T): L<T>{
export function ___<T extends (v: P) => L<any>>(run: () => T): L<T> {
const r: T = ((p: Parameters<T>[0]) => {
let v: any;
return ___(() => run()(
___(() => v ??= p.run())
___(() => v ??= p.run()),
).run());
}) as T;
+7 -7
View File
@@ -66,11 +66,11 @@ export const cmp: L<<T extends P>(ecmp: L<(l: T) => L <(r: T) => Ord>>) => L<(l:
= _(<T extends P>(ecmp: L<(l: T) => L<(r: T) => Ord>>) =>
_((l: List<T>) =>
_((r: List<T>) => l
(r(EQ)(cnst(cnst(LT))))
(_(lx => _(lxs => r(GT)(_(rx => _(rxs => iif
(eqc(EQ)(ecmp(lx)(rx)))
(cmp(ecmp)(lxs)(rxs))
(ecmp(lx)(rx)))))))))));
(r(EQ)(cnst(cnst(LT))))
(_(lx => _(lxs => r(GT)(_(rx => _(rxs => iif
(eqc(EQ)(ecmp(lx)(rx)))
(cmp(ecmp)(lxs)(rxs))
(ecmp(lx)(rx)))))))))));
export const lt: L<<T extends P>(ecmp: L<(l: T) => L <(r: T) => Ord>>) => L<(l: List<T>) => L<(r: List<T>) => Bool>>>
= _(<T extends P>(ecmp: L<(l: T) => L<(r: T) => Ord>>) =>
@@ -88,8 +88,8 @@ export const eq: L<<T extends P>(eeq: L<(l: T) => L <(r: T) => Bool>>) => L<(l:
= _(<T extends P>(eeq: L<(l: T) => L<(r: T) => Bool>>) =>
_((l: List<T>) =>
_((r: List<T>) => l
(r(True)(cnst(cnst(False))))
(_(lx => _(lxs => r(False)(_(rx => _(rxs => and(eeq(lx)(rx))(eq(eeq)(lxs)(rxs)))))))))));
(r(True)(cnst(cnst(False))))
(_(lx => _(lxs => r(False)(_(rx => _(rxs => and(eeq(lx)(rx))(eq(eeq)(lxs)(rxs)))))))))));
export const ge: L<<T extends P>(ecmp: L<(l: T) => L <(r: T) => Ord>>) => L<(l: List<T>) => L<(r: List<T>) => Bool>>>
= _(<T extends P>(ecmp: L<(l: T) => L<(r: T) => Ord>>) =>
+2 -2
View File
@@ -61,8 +61,8 @@ export const mod: L<(l: Num) => L<(r: Num) => Num>>
export const show: L<(n: Num) => String>
= _(n => iif(lt(n)(fromNumber(10)))
(cons(sum(n)(fromNumber(48)))(Empty))
(append(show(div(n)(fromNumber(10))))(show(mod(n)(fromNumber(10))))));
(cons(sum(n)(fromNumber(48)))(Empty))
(append(show(div(n)(fromNumber(10))))(show(mod(n)(fromNumber(10))))));
export const fromNumber: (n: number) => Num
= n => !n ? Zero : Succ(___(() => fromNumber(n - 1).run()));
+3 -3
View File
@@ -21,9 +21,9 @@ export const GT: Ord
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))));
(r(True)(False)(False))
(r(False)(True)(False))
(r(False)(False)(True))));
export const show: L<(o: Ord) => String>
= _(o => o(_s('LT'))(_s('EQ'))(_s('GT')));
+2 -2
View File
@@ -3,7 +3,7 @@ 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, append, cmp as cmpl, concat, cons, eq as eql, ge as gel, gt as gtl, le as lel, lt as ltl } from './list';
import { Cons, List, Nil, append, cmp as cmpl, eq as eql, ge as gel, gt as gtl, le as lel, lt as ltl } from './list';
export type String = List<Char>;
@@ -27,7 +27,7 @@ export const ge: L<(l: String) => L<(r: String) => Bool>>
export const gt: L<(l: String) => L<(r: String) => Bool>>
= gtl(cmpc);
export const wrap: L<(w: String) => L<(c: String) => String>>
export const wrap: L<(w: String) => L<(c: String) => String>>
= _(w => _(c => append(w)(append(c)(w))));
export const fromString: (xs: string) => String