infer all types once at the root level, and pass the result down deeply
This commit is contained in:
parent
b2584a2495
commit
d000839878
6 changed files with 75 additions and 80 deletions
|
|
@ -1,15 +1,12 @@
|
|||
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 { ExprBlock, type ExprBlockState, type State2Props } from "./ExprBlock";
|
||||
|
||||
import "./LambdaBlock.css";
|
||||
import { Type } from "../other/Type";
|
||||
import { type TypeInfoLambda } from "../../eval/infer_type";
|
||||
import { Input } from "../other/Input";
|
||||
import { inferTypeLambda } from "../../eval/infer_type";
|
||||
import { Type } from "../other/Type";
|
||||
import "./LambdaBlock.css";
|
||||
|
||||
export interface LambdaBlockState {
|
||||
kind: "lambda";
|
||||
|
|
@ -22,10 +19,11 @@ export interface LambdaBlockProps<
|
|||
FnState=ExprBlockState,
|
||||
InputState=ExprBlockState,
|
||||
> extends State2Props<LambdaBlockState,ExprBlockState> {
|
||||
typeInfo: TypeInfoLambda;
|
||||
}
|
||||
|
||||
|
||||
export function LambdaBlock({state, setState, score}: LambdaBlockProps) {
|
||||
export function LambdaBlock({state, setState, score, typeInfo}: LambdaBlockProps) {
|
||||
const env = useContext(EnvContext);
|
||||
|
||||
const setParamName = paramName => setState(state => ({
|
||||
|
|
@ -37,14 +35,6 @@ export function LambdaBlock({state, setState, score}: LambdaBlockProps) {
|
|||
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">λ</span>
|
||||
|
||||
|
|
@ -60,18 +50,19 @@ export function LambdaBlock({state, setState, score}: LambdaBlockProps) {
|
|||
/>
|
||||
</span>
|
||||
<div className="typeSignature">
|
||||
:: <Type type={paramType} />
|
||||
:: <Type type={typeInfo.paramType} />
|
||||
</div>
|
||||
|
||||
<span className="keyword">:</span>
|
||||
|
||||
<div className="lambdaInner">
|
||||
<EnvContext value={innerEnv}>
|
||||
<EnvContext value={typeInfo.innerEnv}>
|
||||
<ExprBlock
|
||||
state={state.expr}
|
||||
setState={setExpr}
|
||||
onCancel={() => setState(state => state.expr)}
|
||||
score={suggestion => score({...state, expr: suggestion})}
|
||||
typeInfo={typeInfo.inner}
|
||||
/>
|
||||
</EnvContext>
|
||||
</div>
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue