nicer, nested rendering when currying
This commit is contained in:
parent
f75d0641b4
commit
8744bad0b8
9 changed files with 144 additions and 91 deletions
|
|
@ -1,4 +1,4 @@
|
|||
import { getSymbol, getType, module2Env, ModuleStd, symbolFunction } from "dope2";
|
||||
import { getSymbol, getType, module2Env, ModuleStd, symbolFunction, getDefaultTypeParser } from "dope2";
|
||||
|
||||
import { InputBlock, type InputBlockState } from "./InputBlock";
|
||||
import { type Dynamic, type State2Props } from "./util/extra";
|
||||
|
|
@ -16,7 +16,6 @@ interface LambdaBlockState {
|
|||
paramName: string;
|
||||
expr: EditorState;
|
||||
resolved: undefined | Dynamic;
|
||||
rollback?: EditorState;
|
||||
}
|
||||
|
||||
export type EditorState =
|
||||
|
|
@ -25,12 +24,14 @@ export type EditorState =
|
|||
| LetInBlockState
|
||||
| LambdaBlockState;
|
||||
|
||||
const mkType = getDefaultTypeParser();
|
||||
export const initialEditorState: EditorState = {
|
||||
kind: "input",
|
||||
env: module2Env(ModuleStd),
|
||||
env: module2Env(ModuleStd.concat([
|
||||
["functionWith3Params", {i: i=>j=>k=>i+j+k, t: mkType("Int->Int->Int->Int")}],
|
||||
])),
|
||||
text: "",
|
||||
resolved: undefined,
|
||||
rollback: undefined,
|
||||
};
|
||||
|
||||
interface EditorProps extends State2Props<EditorState> {
|
||||
|
|
@ -84,7 +85,6 @@ export function Editor({state, setState, onResolve, onCancel}: EditorProps) {
|
|||
fn: state,
|
||||
input: initialEditorState,
|
||||
resolved: undefined,
|
||||
rollback: state,
|
||||
});
|
||||
return;
|
||||
}
|
||||
|
|
@ -97,7 +97,6 @@ export function Editor({state, setState, onResolve, onCancel}: EditorProps) {
|
|||
fn: initialEditorState,
|
||||
input: state,
|
||||
resolved: undefined,
|
||||
rollback: state,
|
||||
});
|
||||
return;
|
||||
}
|
||||
|
|
@ -116,7 +115,6 @@ export function Editor({state, setState, onResolve, onCancel}: EditorProps) {
|
|||
name: "",
|
||||
value: state,
|
||||
resolved: undefined,
|
||||
rollback: state,
|
||||
});
|
||||
return;
|
||||
}
|
||||
|
|
@ -141,7 +139,13 @@ export function Editor({state, setState, onResolve, onCancel}: EditorProps) {
|
|||
? <div className="typeSignature">
|
||||
:: <Type type={getType(state.resolved)} />
|
||||
{ (needCommand)
|
||||
? <input autoFocus={true} className="editable command" placeholder="<enter command>" onKeyDown={onCommand} value=""/>
|
||||
? <input
|
||||
spellCheck={false}
|
||||
autoFocus={true}
|
||||
className="editable command"
|
||||
placeholder="<enter command>"
|
||||
onKeyDown={onCommand}
|
||||
value=""/>
|
||||
: <></>
|
||||
}
|
||||
</div>
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue