rename Editor -> ExprBlock
This commit is contained in:
parent
fe83532261
commit
93f665ba8f
9 changed files with 55 additions and 56 deletions
10
src/eval.ts
10
src/eval.ts
|
|
@ -1,6 +1,6 @@
|
|||
import { assignFnSubstitutions, dict, Double, fnType, getSymbol, growEnv, Int, NotAFunctionError, prettyT, substitute, symbolFunction, trie, TYPE_VARS, UnifyError } from "dope2";
|
||||
|
||||
import type { EditorState } from "./Editor";
|
||||
import type { ExprBlockState } from "./ExprBlock";
|
||||
import type { InputValueType, SuggestionType } from "./InputBlock";
|
||||
|
||||
interface Type {
|
||||
|
|
@ -39,7 +39,7 @@ export const entirelyUnknown = env => ({
|
|||
// the value of every block is either known (Dynamic), an error, or unknown
|
||||
export type ResolvedType = Dynamic | DeepError | Unknown;
|
||||
|
||||
export const evalEditorBlock = (s: EditorState, env): ResolvedType => {
|
||||
export const evalEditorBlock = (s: ExprBlockState, env): ResolvedType => {
|
||||
if (s.kind === "input") {
|
||||
return evalInputBlock(s.text, s.value, env);
|
||||
}
|
||||
|
|
@ -157,13 +157,13 @@ export function evalCallBlock2(fnResolved: ResolvedType, inputResolved: Resolved
|
|||
}
|
||||
}
|
||||
|
||||
export function evalCallBlock(fn: EditorState, input: EditorState, env): ResolvedType {
|
||||
export function evalCallBlock(fn: ExprBlockState, input: ExprBlockState, env): ResolvedType {
|
||||
const fnResolved = evalEditorBlock(fn, env);
|
||||
const inputResolved = evalEditorBlock(input, env);
|
||||
return evalCallBlock2(fnResolved, inputResolved, env);
|
||||
}
|
||||
|
||||
export function evalLetInBlock(value: EditorState, name: string, inner: EditorState, env): ResolvedType {
|
||||
export function evalLetInBlock(value: ExprBlockState, name: string, inner: ExprBlockState, env): ResolvedType {
|
||||
const valueResolved = evalEditorBlock(value, env);
|
||||
// console.log('eval', name, '...', valueResolved.kind, valueResolved.e);
|
||||
// const innerEnv = growEnv(env)(name)(valueResolved);
|
||||
|
|
@ -183,7 +183,7 @@ export function getUnusedTypeVar(env) {
|
|||
return TYPE_VARS[getUnusedTypeVarIdx(env)];
|
||||
}
|
||||
|
||||
export function evalLambdaBlock(paramName: string, expr: EditorState, env): ResolvedType {
|
||||
export function evalLambdaBlock(paramName: string, expr: ExprBlockState, env): ResolvedType {
|
||||
const paramType = getUnusedTypeVar(env);
|
||||
// static env: we only know the name and the type
|
||||
const staticInnerEnv = growEnv(env)(paramName)({
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue