306 lines
No EOL
6.3 KiB
TypeScript
306 lines
No EOL
6.3 KiB
TypeScript
import type { ExprBlockState } from "./ExprBlock";
|
|
|
|
export const initialEditorState: ExprBlockState = {
|
|
kind: "input",
|
|
text: "",
|
|
value: { kind: "text" },
|
|
focus: true,
|
|
};
|
|
|
|
export const nonEmptyEditorState: ExprBlockState = {
|
|
kind: "call",
|
|
fn: {
|
|
kind: "call",
|
|
fn: {
|
|
kind: "input",
|
|
text: "list.push",
|
|
value: { kind: "name" },
|
|
focus: false,
|
|
},
|
|
input: {
|
|
kind: "input",
|
|
text: "list.emptyList",
|
|
value: { kind: "name" },
|
|
focus: false,
|
|
},
|
|
},
|
|
input: {
|
|
kind: "input",
|
|
text: "42",
|
|
value: { kind: "literal", type: "Int" },
|
|
focus: false,
|
|
},
|
|
};
|
|
|
|
export const tripleFunctionCallEditorState: ExprBlockState = {
|
|
kind: "call",
|
|
fn: {
|
|
kind: "call",
|
|
fn: {
|
|
kind: "call",
|
|
fn: {
|
|
kind: "call",
|
|
fn: {
|
|
kind: "input",
|
|
text: "functionWith4Params",
|
|
value: { kind: "name" },
|
|
focus: false,
|
|
},
|
|
input: {
|
|
kind: "input",
|
|
text: "42",
|
|
value: { kind: "literal", type: "Int" },
|
|
focus: false,
|
|
},
|
|
},
|
|
input: {
|
|
kind: "input",
|
|
text: "43",
|
|
value: { kind: "literal", type: "Int" },
|
|
focus: false,
|
|
},
|
|
},
|
|
input: {
|
|
kind: "input",
|
|
text: "44",
|
|
value: { kind: "literal", type: "Int" },
|
|
focus: false,
|
|
},
|
|
},
|
|
input: {
|
|
kind: "input",
|
|
text: "45",
|
|
value: { kind: "literal", type: "Int" },
|
|
focus: false,
|
|
},
|
|
};
|
|
|
|
export const biggerExample: ExprBlockState = {
|
|
"kind": "let",
|
|
"inner": {
|
|
"kind": "let",
|
|
"inner": {
|
|
"kind": "let",
|
|
"inner": {
|
|
"kind": "let",
|
|
"inner": {
|
|
"kind": "input",
|
|
"text": "",
|
|
"value": {
|
|
"kind": "text"
|
|
},
|
|
"focus": false
|
|
},
|
|
"name": "myListInc",
|
|
"value": {
|
|
"kind": "call",
|
|
"fn": {
|
|
"kind": "call",
|
|
"fn": {
|
|
"kind": "input",
|
|
"text": "list.map",
|
|
"value": {
|
|
"kind": "name"
|
|
},
|
|
"focus": false
|
|
},
|
|
"input": {
|
|
"kind": "input",
|
|
"text": "myList",
|
|
"value": {
|
|
"kind": "name"
|
|
},
|
|
"focus": false
|
|
}
|
|
},
|
|
"input": {
|
|
"kind": "input",
|
|
"text": "inc",
|
|
"value": {
|
|
"kind": "name"
|
|
},
|
|
"focus": false
|
|
}
|
|
}
|
|
},
|
|
"name": "myList",
|
|
"value": {
|
|
"kind": "call",
|
|
"fn": {
|
|
"kind": "call",
|
|
"fn": {
|
|
"kind": "input",
|
|
"text": "list.push",
|
|
"value": {
|
|
"kind": "name"
|
|
},
|
|
"focus": false
|
|
},
|
|
"input": {
|
|
"kind": "call",
|
|
"fn": {
|
|
"kind": "call",
|
|
"fn": {
|
|
"kind": "input",
|
|
"text": "list.push",
|
|
"value": {
|
|
"kind": "name"
|
|
},
|
|
"focus": false
|
|
},
|
|
"input": {
|
|
"kind": "call",
|
|
"fn": {
|
|
"kind": "call",
|
|
"fn": {
|
|
"kind": "input",
|
|
"text": "list.push",
|
|
"value": {
|
|
"kind": "name"
|
|
},
|
|
"focus": false
|
|
},
|
|
"input": {
|
|
"kind": "input",
|
|
"text": "list.emptyList",
|
|
"value": {
|
|
"kind": "name"
|
|
},
|
|
"focus": false
|
|
}
|
|
},
|
|
"input": {
|
|
"kind": "input",
|
|
"text": "1",
|
|
"value": {
|
|
"kind": "literal",
|
|
"type": "Int"
|
|
},
|
|
"focus": false
|
|
}
|
|
}
|
|
},
|
|
"input": {
|
|
"kind": "input",
|
|
"text": "2",
|
|
"value": {
|
|
"kind": "literal",
|
|
"type": "Int"
|
|
},
|
|
"focus": false
|
|
}
|
|
}
|
|
},
|
|
"input": {
|
|
"kind": "input",
|
|
"text": "3",
|
|
"value": {
|
|
"kind": "literal",
|
|
"type": "Int"
|
|
},
|
|
"focus": false
|
|
}
|
|
}
|
|
},
|
|
"name": "id",
|
|
"value": {
|
|
"kind": "lambda",
|
|
"paramName": "x",
|
|
"expr": {
|
|
"kind": "input",
|
|
"text": "x",
|
|
"value": {
|
|
"kind": "name"
|
|
},
|
|
"focus": false
|
|
}
|
|
}
|
|
},
|
|
"name": "inc",
|
|
"value": {
|
|
"kind": "lambda",
|
|
"paramName": "x",
|
|
"expr": {
|
|
"kind": "call",
|
|
"fn": {
|
|
"kind": "call",
|
|
"fn": {
|
|
"kind": "input",
|
|
"text": "addInt",
|
|
"value": {
|
|
"kind": "name"
|
|
},
|
|
"focus": false
|
|
},
|
|
"input": {
|
|
"kind": "input",
|
|
"text": "x",
|
|
"value": {
|
|
"kind": "name"
|
|
},
|
|
"focus": false
|
|
}
|
|
},
|
|
"input": {
|
|
"kind": "input",
|
|
"text": "1",
|
|
"value": {
|
|
"kind": "literal",
|
|
"type": "Int"
|
|
},
|
|
"focus": true
|
|
}
|
|
}
|
|
}
|
|
};
|
|
|
|
export const lambda2Params: ExprBlockState = {
|
|
"kind": "let",
|
|
"inner": {
|
|
"kind": "input",
|
|
"text": "",
|
|
"value": {
|
|
"kind": "text"
|
|
},
|
|
"focus": false
|
|
},
|
|
"name": "myAddInt",
|
|
"value": {
|
|
"kind": "lambda",
|
|
"paramName": "x",
|
|
"expr": {
|
|
"kind": "lambda",
|
|
"paramName": "y",
|
|
"expr": {
|
|
"kind": "call",
|
|
"fn": {
|
|
"kind": "call",
|
|
"fn": {
|
|
"kind": "input",
|
|
"text": "addInt",
|
|
"value": {
|
|
"kind": "name"
|
|
},
|
|
"focus": false
|
|
},
|
|
"input": {
|
|
"kind": "input",
|
|
"text": "x",
|
|
"value": {
|
|
"kind": "name"
|
|
},
|
|
"focus": false
|
|
}
|
|
},
|
|
"input": {
|
|
"kind": "input",
|
|
"text": "y",
|
|
"value": {
|
|
"kind": "name"
|
|
},
|
|
"focus": false
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}; |