import { useContext } from "react"; import { getType } from "dope2"; import { CallBlock, type CallBlockProps, type CallBlockState } from "./CallBlock"; import { EnvContext } from "./EnvContext"; import { GlobalContext } from "./GlobalContext"; import { InputBlock, type InputBlockProps, type InputBlockState } from "./InputBlock"; import { LambdaBlock, type LambdaBlockProps, type LambdaBlockState } from "./LambdaBlock"; import { LetInBlock, type LetInBlockProps, type LetInBlockState } from "./LetInBlock"; import { Type } from "./Type"; // import { evalExprBlock, type ResolvedType } from "./eval"; import "./ExprBlock.css"; import { Input } from "./Input"; import { getActions } from "./actions"; import { inferType } from "./infer_type"; export type ExprBlockState = InputBlockState | CallBlockState | LetInBlockState | LambdaBlockState; export type SetStateFn = (state: InType) => OutType; export interface State2Props { state: InType; setState: (callback: SetStateFn) => void; score: (suggestion: ExprBlockState) => number; } interface ExprBlockProps extends State2Props { onCancel: () => void; } export function ExprBlock(props: ExprBlockProps) { const env = useContext(EnvContext); const globalContext = useContext(GlobalContext); const renderBlock = { input: () => , call: () => , let: () => , lambda: () => , }; // const [resolved] = evalExprBlock(props.state, env); // const typeInfo = inferType(props.state, env); const actions = getActions(globalContext, props.setState); const extraHandlers = Object.fromEntries(Object.entries(actions).map(([shortcut, action]) => [shortcut, (e) => { e.preventDefault(); action(); }])) // return return {renderBlock[props.state.kind]()} {/* @ts-ignore */} {/*
*/} {/*  ::  */} {/* @ts-ignore */} {/* {resolved.__debug &&
{resolved.__debug}
} */} {/*
*/} {}} onCancel={props.onCancel} onTextChange={() => {}} extraHandlers={extraHandlers} />
; }