greatly simplify and improve type inferencing - suggestions broken

This commit is contained in:
Joeri Exelmans 2025-05-23 19:48:24 +02:00
parent c3f7cea310
commit c5c5def598
12 changed files with 1022 additions and 694 deletions

View file

@ -1,14 +1,15 @@
import { useContext } from "react";
import { eqType, getSymbol, reduceUnification } from "dope2";
// import { eqType, getSymbol, reduceUnification } from "dope2";
import { ExprBlock, type ExprBlockState, type State2Props } from "./ExprBlock";
import { EnvContext } from "./EnvContext";
import { evalExprBlock, evalLambdaBlock, makeInnerEnv, makeTypeVar } from "./eval";
// import { evalExprBlock, evalLambdaBlock, makeInnerEnv, makeTypeVar } from "./eval";
import "./LambdaBlock.css";
import { Type } from "./Type";
import { Input } from "./Input";
import { inferTypeLambda } from "./infer_type";
export interface LambdaBlockState {
kind: "lambda";
@ -36,9 +37,13 @@ export function LambdaBlock({state, setState, score}: LambdaBlockProps) {
expr: callback(state.expr),
}));
const [lambdaResolved, _, innerEnv] = evalLambdaBlock(state.paramName, state.expr, env);
const {paramType, innerEnv} = inferTypeLambda(state, env);
const inferredParamType = lambdaResolved.t.params[0](lambdaResolved.t);
// 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>
@ -55,7 +60,7 @@ export function LambdaBlock({state, setState, score}: LambdaBlockProps) {
/>
</span>
<div className="typeSignature">
&nbsp;::&nbsp;<Type type={inferredParamType} />
&nbsp;::&nbsp;<Type type={paramType} />
</div>
&nbsp;
<span className="keyword">:</span>