move 'env' from state to context
This commit is contained in:
parent
9ef160aeb7
commit
f09261df93
13 changed files with 178 additions and 148 deletions
|
|
@ -1,39 +1,30 @@
|
|||
import { getDefaultTypeParser, module2Env, ModuleStd, trie, Int, apply } from "dope2";
|
||||
import { apply, Int, trie } from "dope2";
|
||||
import type { EditorState } from "./Editor";
|
||||
|
||||
const mkType = getDefaultTypeParser();
|
||||
export const extendedEnv = module2Env(ModuleStd.concat([
|
||||
["functionWith3Params", { i: i => j => k => i + j + k, t: mkType("Int->Int->Int->Int") }],
|
||||
]));
|
||||
import { extendedEnv } from "./EnvContext";
|
||||
|
||||
export const initialEditorState: EditorState = {
|
||||
kind: "input",
|
||||
env: extendedEnv,
|
||||
text: "",
|
||||
resolved: undefined,
|
||||
focus: true,
|
||||
};
|
||||
|
||||
const listPush = trie.get(initialEditorState.env.name2dyn)("list.push");
|
||||
const listEmptyList = trie.get(initialEditorState.env.name2dyn)("list.emptyList");
|
||||
const listPush = trie.get(extendedEnv.name2dyn)("list.push");
|
||||
const listEmptyList = trie.get(extendedEnv.name2dyn)("list.emptyList");
|
||||
const fourtyTwo = { i: 42n, t: Int };
|
||||
|
||||
export 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,
|
||||
focus: false,
|
||||
},
|
||||
input: {
|
||||
kind: "input",
|
||||
env: initialEditorState.env,
|
||||
text: "list.emptyList",
|
||||
resolved: listEmptyList,
|
||||
focus: false,
|
||||
|
|
@ -43,7 +34,6 @@ export const nonEmptyEditorState: EditorState = {
|
|||
},
|
||||
input: {
|
||||
kind: "input",
|
||||
env: initialEditorState.env,
|
||||
text: "42",
|
||||
resolved: fourtyTwo,
|
||||
focus: false,
|
||||
|
|
@ -52,29 +42,24 @@ export const nonEmptyEditorState: EditorState = {
|
|||
resolved: undefined,
|
||||
};
|
||||
|
||||
const functionWith3Params = trie.get(initialEditorState.env.name2dyn)("functionWith3Params");
|
||||
const functionWith3Params = trie.get(extendedEnv.name2dyn)("functionWith3Params");
|
||||
const fourtyThree = { i: 43n, t: Int };
|
||||
const fourtyFour = { i: 44n, t: Int };
|
||||
|
||||
export 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,
|
||||
focus: false,
|
||||
},
|
||||
input: {
|
||||
kind: "input",
|
||||
env: initialEditorState.env,
|
||||
text: "42",
|
||||
resolved: fourtyTwo,
|
||||
focus: false,
|
||||
|
|
@ -83,7 +68,6 @@ export const tripleFunctionCallEditorState: EditorState = {
|
|||
},
|
||||
input: {
|
||||
kind: "input",
|
||||
env: initialEditorState.env,
|
||||
text: "43",
|
||||
resolved: fourtyThree,
|
||||
focus: false,
|
||||
|
|
@ -92,7 +76,6 @@ export const tripleFunctionCallEditorState: EditorState = {
|
|||
},
|
||||
input: {
|
||||
kind: "input",
|
||||
env: initialEditorState.env,
|
||||
text: "44",
|
||||
resolved: fourtyFour,
|
||||
focus: false,
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue