move everything

This commit is contained in:
Joeri Exelmans 2025-05-23 22:35:47 +02:00
parent 3ff7e76694
commit 9050581a10
25 changed files with 37 additions and 42 deletions

View file

@ -0,0 +1,82 @@
import { useContext } from "react";
// import { eqType, getSymbol, reduceUnification } from "dope2";
import { ExprBlock, type ExprBlockState, type State2Props } from "./ExprBlock";
import { EnvContext } from "../../context/EnvContext";
// import { evalExprBlock, evalLambdaBlock, makeInnerEnv, makeTypeVar } from "./eval";
import "./LambdaBlock.css";
import { Type } from "../other/Type";
import { Input } from "../other/Input";
import { inferTypeLambda } from "../../eval/infer_type";
export interface LambdaBlockState {
kind: "lambda";
paramName: string;
focus: boolean;
expr: ExprBlockState;
}
export interface LambdaBlockProps<
FnState=ExprBlockState,
InputState=ExprBlockState,
> extends State2Props<LambdaBlockState,ExprBlockState> {
}
export function LambdaBlock({state, setState, score}: LambdaBlockProps) {
const env = useContext(EnvContext);
const setParamName = paramName => setState(state => ({
...state,
paramName,
}));
const setExpr = callback => setState(state => ({
...state,
expr: callback(state.expr),
}));
const {paramType, innerEnv} = inferTypeLambda(state, env);
// const [lambdaResolved, _, innerEnv] = evalLambdaBlock(state.paramName, state.expr, env);
// const inferredParamType = lambdaResolved.t.params[0](lambdaResolved.t);
// const innerEnv = env; // todo: change this
return <span className="lambdaBlock">
<span className="keyword">&#955;</span>
&nbsp;
<span className="lambdaInputParam">
<Input
placeholder="<name>"
text={state.paramName}
suggestion=""
onEnter={() => {}}
onCancel={() => {}}
onTextChange={txt => setParamName(txt)}
extraHandlers={{}}
/>
</span>
<div className="typeSignature">
&nbsp;::&nbsp;<Type type={paramType} />
</div>
&nbsp;
<span className="keyword">:</span>
&nbsp;
<div className="lambdaInner">
<EnvContext value={innerEnv}>
<ExprBlock
state={state.expr}
setState={setExpr}
onCancel={() => setState(state => state.expr)}
score={(s) => {
// console.log('suggestionPriority of lambdaInner... just passing through');
return score(s);
}}
/>
</EnvContext>
</div>
</span>
}