Fixing pretty print ast. adding a few more builtins :( getting further with inspector

This commit is contained in:
Dustin Swan 2026-02-10 16:46:31 -07:00
parent 30234875fe
commit 8bc05efa1e
No known key found for this signature in database
GPG key ID: 30D46587E2100467
9 changed files with 272 additions and 82 deletions

View file

@ -51,8 +51,14 @@ export const _rt = {
rerender: { _tag: 'Rerender' },
focus: (key: string) => ({ _tag: 'Focus', _0: key }),
len: (list: any[]) => list.length,
nth: (i: number) => (xs: any[] | string) => i >= 0 && i < xs.length
? { _tag: 'Some', _0: xs[i] }
: { _tag: 'None' },
len: (xs: any[] | string) => xs.length,
str: (x: any) => String(x),
chars: (s: string) => s.split(''),
join: (delim: string) => (xs: string[]) => xs.join(delim),
split: (delim: string) => (xs: string) => xs.split(delim),
slice: (s: string | any[]) => (start: number) => (end: number) => s.slice(start, end),
debug: (label: string) => (value: any) => { console.log(label, value); return value; },
fuzzyMatch: (query: string) => (target: string) => {
@ -70,7 +76,8 @@ export const _rt = {
getSource: (name: string) => {
const ast = definitions.get(name);
if (!ast) return "";
return prettyPrint(ast);
const printed = prettyPrint(ast);
return printed;
},
rebind: (name: string, pathOrValue: any, maybeValue?: any) => {
if (maybeValue === undefined) {