Lambda calculus-like library written in TypeScript.
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.
 
 
jlc/src/char.ts

19 lines
547 B

import { L, _ } from './core';
import { toNumber as $n, Byte, fromNumber as _n, x00 } from './byte';
import { Empty, String, cons, fromString as _s, wrap } from './string';
export type Char = Byte;
export const Null: Char
= x00;
export { inc, dec, ifz as ifn, cmp, lt, le, eq, ge, gt } from './byte';
export const show: L<(c: Char) => String>
= _(c => wrap(_s('\''))(cons(c)(Empty)));
export const fromChar: (c: string) => Char
= c => _n(c.charCodeAt(0));
export const toChar: (c: Char) => string
= c => String.fromCharCode($n(c));