Using ! for effectful host functions
This commit is contained in:
parent
8be7bf43a2
commit
afb26a32fd
4 changed files with 9 additions and 9 deletions
|
|
@ -82,7 +82,7 @@ export const _rt = {
|
|||
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; },
|
||||
"debug!": (label: string) => (value: any) => { console.log(label, value); return value; },
|
||||
fuzzyMatch: (query: string) => (target: string) => {
|
||||
const q = query.toLowerCase();
|
||||
const t = target.toLowerCase();
|
||||
|
|
@ -101,7 +101,7 @@ export const _rt = {
|
|||
const printed = prettyPrint(ast);
|
||||
return printed;
|
||||
},
|
||||
saveImage: () => {
|
||||
"saveImage!": () => {
|
||||
const saved: Record<string, string> = {};
|
||||
for (const [name, ast] of definitions) {
|
||||
const source = prettyPrint({ kind: 'definition', name, body: ast });
|
||||
|
|
@ -137,7 +137,7 @@ export const _rt = {
|
|||
|
||||
return { _tag: 'Rebind', _0: name, _1: path, _2: value };
|
||||
},
|
||||
undefine: (name: string) => {
|
||||
"undefine": (name: string) => {
|
||||
delete store[name];
|
||||
definitions.delete(name);
|
||||
dependencies.delete(name);
|
||||
|
|
@ -171,7 +171,7 @@ export const _rt = {
|
|||
return { _tag: 'NoneValue' };
|
||||
},
|
||||
|
||||
eval: (code: string) => {
|
||||
"eval!": (code: string) => {
|
||||
const trimmed = code.trim();
|
||||
|
||||
// is it a definition
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue