move everything
This commit is contained in:
parent
3ff7e76694
commit
9050581a10
25 changed files with 37 additions and 42 deletions
|
|
@ -1,82 +0,0 @@
|
|||
import { useContext } from "react";
|
||||
|
||||
// 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 "./LambdaBlock.css";
|
||||
import { Type } from "./Type";
|
||||
import { Input } from "./Input";
|
||||
import { inferTypeLambda } from "./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">λ</span>
|
||||
|
||||
<span className="lambdaInputParam">
|
||||
<Input
|
||||
placeholder="<name>"
|
||||
text={state.paramName}
|
||||
suggestion=""
|
||||
onEnter={() => {}}
|
||||
onCancel={() => {}}
|
||||
onTextChange={txt => setParamName(txt)}
|
||||
extraHandlers={{}}
|
||||
/>
|
||||
</span>
|
||||
<div className="typeSignature">
|
||||
:: <Type type={paramType} />
|
||||
</div>
|
||||
|
||||
<span className="keyword">:</span>
|
||||
|
||||
<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>
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue