set default editor state to something non-empty
This commit is contained in:
parent
0a9dbd454f
commit
f75d0641b4
1 changed files with 81 additions and 1 deletions
82
src/App.tsx
82
src/App.tsx
|
|
@ -2,9 +2,89 @@
|
|||
import { useEffect, useState } from 'react';
|
||||
import './App.css'
|
||||
import { Editor, initialEditorState, type EditorState } from './Editor'
|
||||
import { trie, apply, Int } from "dope2";
|
||||
|
||||
const listPush = trie.get(initialEditorState.env.name2dyn)("list.push");
|
||||
const listEmptyList = trie.get(initialEditorState.env.name2dyn)("list.emptyList");
|
||||
const fourtyTwo = {i: 42n, t: Int};
|
||||
|
||||
const nonEmptyEditorState: EditorState = {
|
||||
kind: "call",
|
||||
env: initialEditorState.env,
|
||||
fn: {
|
||||
kind: "call",
|
||||
env: initialEditorState.env,
|
||||
fn: {
|
||||
kind: "input",
|
||||
env: initialEditorState.env,
|
||||
text: "list.push",
|
||||
resolved: listPush,
|
||||
},
|
||||
input: {
|
||||
kind: "input",
|
||||
env: initialEditorState.env,
|
||||
text: "list.emptyList",
|
||||
resolved: listEmptyList,
|
||||
},
|
||||
resolved: apply(listEmptyList)(listPush),
|
||||
},
|
||||
input: {
|
||||
kind: "input",
|
||||
env: initialEditorState.env,
|
||||
text: "42",
|
||||
resolved: fourtyTwo,
|
||||
},
|
||||
resolved: apply(fourtyTwo)(apply(listEmptyList)(listPush)),
|
||||
};
|
||||
|
||||
const functionWith3Params = trie.get(initialEditorState.env.name2dyn)("functionWith3Params");
|
||||
const fourtyThree = {i: 43n, t: Int};
|
||||
const fourtyFour = {i: 44n, t: Int};
|
||||
|
||||
const tripleFunctionCallEditorState: EditorState = {
|
||||
kind: "call",
|
||||
env: initialEditorState.env,
|
||||
fn: {
|
||||
kind: "call",
|
||||
env: initialEditorState.env,
|
||||
fn: {
|
||||
kind: "call",
|
||||
env: initialEditorState.env,
|
||||
fn: {
|
||||
kind: "input",
|
||||
env: initialEditorState.env,
|
||||
text: "functionWith3Params",
|
||||
resolved: functionWith3Params,
|
||||
},
|
||||
input: {
|
||||
kind: "input",
|
||||
env: initialEditorState.env,
|
||||
text: "42",
|
||||
resolved: fourtyTwo,
|
||||
},
|
||||
resolved: apply(fourtyTwo)(functionWith3Params),
|
||||
},
|
||||
input: {
|
||||
kind: "input",
|
||||
env: initialEditorState.env,
|
||||
text: "43",
|
||||
resolved: fourtyThree,
|
||||
},
|
||||
resolved: apply(fourtyThree)(apply(fourtyTwo)(functionWith3Params)),
|
||||
},
|
||||
input: {
|
||||
kind: "input",
|
||||
env: initialEditorState.env,
|
||||
text: "44",
|
||||
resolved: fourtyFour,
|
||||
},
|
||||
resolved: apply(fourtyFour)(apply(fourtyThree)(apply(fourtyTwo)(functionWith3Params))),
|
||||
}
|
||||
|
||||
export function App() {
|
||||
const [state, setState] = useState<EditorState>(initialEditorState);
|
||||
// const [state, setState] = useState<EditorState>(initialEditorState);
|
||||
// const [state, setState] = useState<EditorState>(nonEmptyEditorState);
|
||||
const [state, setState] = useState<EditorState>(tripleFunctionCallEditorState);
|
||||
|
||||
useEffect(() => {
|
||||
window['APP_STATE'] = state;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue