Using ! for effectful host functions
This commit is contained in:
parent
8be7bf43a2
commit
afb26a32fd
4 changed files with 9 additions and 9 deletions
|
|
@ -1,5 +1,5 @@
|
||||||
inspector = config \
|
inspector = config \
|
||||||
val = eval config.name;
|
val = eval! config.name;
|
||||||
|
|
||||||
reflected = val
|
reflected = val
|
||||||
| Value v \ reflect v
|
| Value v \ reflect v
|
||||||
|
|
|
||||||
|
|
@ -75,7 +75,7 @@ treeNode = config \
|
||||||
isExp = contains config.path config.expanded;
|
isExp = contains config.path config.expanded;
|
||||||
|
|
||||||
onSubmit = text \ (
|
onSubmit = text \ (
|
||||||
(eval text)
|
(eval! text)
|
||||||
| Value v \ batch [rebindAt config.path v, config.onDoneEditing {}]
|
| Value v \ batch [rebindAt config.path v, config.onDoneEditing {}]
|
||||||
| _ \ config.onDoneEditing {});
|
| _ \ config.onDoneEditing {});
|
||||||
|
|
||||||
|
|
@ -204,7 +204,7 @@ tree = config \
|
||||||
view = state emit \
|
view = state emit \
|
||||||
onToggle = path \ emit (Toggle path);
|
onToggle = path \ emit (Toggle path);
|
||||||
onEditLeaf = path \
|
onEditLeaf = path \
|
||||||
_ = debug "onEditLeaf" path;
|
_ = debug! "onEditLeaf" path;
|
||||||
emit (EditLeaf path);
|
emit (EditLeaf path);
|
||||||
onDoneEditing = _ \ emit DoneEditing;
|
onDoneEditing = _ \ emit DoneEditing;
|
||||||
totalH = treeNodeHeight config.value config.path state.expanded;
|
totalH = treeNodeHeight config.value config.path state.expanded;
|
||||||
|
|
|
||||||
|
|
@ -174,14 +174,14 @@ os =
|
||||||
| None \ openWindow title content;
|
| None \ openWindow title content;
|
||||||
|
|
||||||
onSelect = input \
|
onSelect = input \
|
||||||
result = eval input;
|
result = eval! input;
|
||||||
result
|
result
|
||||||
| Defined name \ openOrFocus name (size \ inspector { name = name, w = size.w, h = size.h })
|
| Defined name \ openOrFocus name (size \ inspector { name = name, w = size.w, h = size.h })
|
||||||
|
|
||||||
| Value v \ (getSource input == ""
|
| Value v \ (getSource input == ""
|
||||||
| True \ openOrFocus input (_ \ ui.text { content = show v, color = "white" })
|
| True \ openOrFocus input (_ \ ui.text { content = show v, color = "white" })
|
||||||
| False \ openOrFocus input (size \ inspector { name = input, w = size.w, h = size.h }))
|
| False \ openOrFocus input (size \ inspector { name = input, w = size.w, h = size.h }))
|
||||||
| Err msg \ (_ = debug "Error" msg; noOp);
|
| Err msg \ (_ = debug! "Error" msg; noOp);
|
||||||
|
|
||||||
handleFocusLeftEvent = state \
|
handleFocusLeftEvent = state \
|
||||||
newIndex = max 0 (osState.wm.focusedIndex - 1);
|
newIndex = max 0 (osState.wm.focusedIndex - 1);
|
||||||
|
|
|
||||||
|
|
@ -82,7 +82,7 @@ export const _rt = {
|
||||||
join: (delim: string) => (xs: string[]) => xs.join(delim),
|
join: (delim: string) => (xs: string[]) => xs.join(delim),
|
||||||
split: (delim: string) => (xs: string) => xs.split(delim),
|
split: (delim: string) => (xs: string) => xs.split(delim),
|
||||||
slice: (s: string | any[]) => (start: number) => (end: number) => s.slice(start, end),
|
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) => {
|
fuzzyMatch: (query: string) => (target: string) => {
|
||||||
const q = query.toLowerCase();
|
const q = query.toLowerCase();
|
||||||
const t = target.toLowerCase();
|
const t = target.toLowerCase();
|
||||||
|
|
@ -101,7 +101,7 @@ export const _rt = {
|
||||||
const printed = prettyPrint(ast);
|
const printed = prettyPrint(ast);
|
||||||
return printed;
|
return printed;
|
||||||
},
|
},
|
||||||
saveImage: () => {
|
"saveImage!": () => {
|
||||||
const saved: Record<string, string> = {};
|
const saved: Record<string, string> = {};
|
||||||
for (const [name, ast] of definitions) {
|
for (const [name, ast] of definitions) {
|
||||||
const source = prettyPrint({ kind: 'definition', name, body: ast });
|
const source = prettyPrint({ kind: 'definition', name, body: ast });
|
||||||
|
|
@ -137,7 +137,7 @@ export const _rt = {
|
||||||
|
|
||||||
return { _tag: 'Rebind', _0: name, _1: path, _2: value };
|
return { _tag: 'Rebind', _0: name, _1: path, _2: value };
|
||||||
},
|
},
|
||||||
undefine: (name: string) => {
|
"undefine": (name: string) => {
|
||||||
delete store[name];
|
delete store[name];
|
||||||
definitions.delete(name);
|
definitions.delete(name);
|
||||||
dependencies.delete(name);
|
dependencies.delete(name);
|
||||||
|
|
@ -171,7 +171,7 @@ export const _rt = {
|
||||||
return { _tag: 'NoneValue' };
|
return { _tag: 'NoneValue' };
|
||||||
},
|
},
|
||||||
|
|
||||||
eval: (code: string) => {
|
"eval!": (code: string) => {
|
||||||
const trimmed = code.trim();
|
const trimmed = code.trim();
|
||||||
|
|
||||||
// is it a definition
|
// is it a definition
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue