import { useContext } from "react"; import { EnvContext } from "../../context/EnvContext"; import { GlobalContext } from "../../context/GlobalContext"; import { type TypeInfoLet } from "../../eval/infer_type"; import { Input } from "../other/Input"; import { Type, TypeInfoBlock } from "../other/Type"; import { ExprBlock, type ExprBlockState, type State2Props } from "./ExprBlock"; import "./LetInBlock.css"; export interface LetInBlockState { kind: "let"; name: string; focus: boolean; value: ExprBlockState; inner: ExprBlockState; } export interface LetInBlockProps extends State2Props { typeInfo: TypeInfoLet; } export function LetInBlock(props: LetInBlockProps) { return
} function DeclColumns({state, setState, score, typeInfo}) { const globalContext = useContext(GlobalContext); const setInner = callback => setState(state => ({...state, inner: callback(state.inner)})); const setValue = callback => setState(state => ({...state, value: callback(state.value)})); return <> let  {}} onCancel={() => {}} onTextChange={name => setState(state => ({...state, name}))} extraHandlers={{}} />
::
 =  score({ ...state, value: suggestion })} onCancel={() => setState(state => state.inner)} // keep inner typeInfo={typeInfo.value} /> {state.inner.kind === "let" && globalContext?.syntacticSugar && score({ ...state, inner: suggestion })} typeInfo={typeInfo.inner} /> } ; } function InnerMost({state, setState, score, typeInfo}) { const globalContext = useContext(GlobalContext); const setInner = callback => setState(state => ({...state, inner: callback(state.inner)})); const onCancel = () => setState(state => state.value); if (state.inner.kind === "let" && globalContext?.syntacticSugar) { return score({ ...state, inner: suggestion })} typeInfo={typeInfo.inner} /> ; } else { return score({ ...state, inner: suggestion })} onCancel={onCancel} // keep value typeInfo={typeInfo.inner} /> } }