greatly simplify and improve type inferencing - suggestions broken
This commit is contained in:
parent
c3f7cea310
commit
c5c5def598
12 changed files with 1022 additions and 694 deletions
|
|
@ -9,11 +9,12 @@ import { InputBlock, type InputBlockProps, type InputBlockState } from "./InputB
|
|||
import { LambdaBlock, type LambdaBlockProps, type LambdaBlockState } from "./LambdaBlock";
|
||||
import { LetInBlock, type LetInBlockProps, type LetInBlockState } from "./LetInBlock";
|
||||
import { Type } from "./Type";
|
||||
import { evalExprBlock, type ResolvedType } from "./eval";
|
||||
// import { evalExprBlock, type ResolvedType } from "./eval";
|
||||
|
||||
import "./ExprBlock.css";
|
||||
import { Input } from "./Input";
|
||||
import { getActions } from "./actions";
|
||||
import { inferType } from "./infer_type";
|
||||
|
||||
export type ExprBlockState =
|
||||
InputBlockState
|
||||
|
|
@ -26,7 +27,7 @@ export type SetStateFn<InType = ExprBlockState, OutType = InType> = (state: InTy
|
|||
export interface State2Props<InType, OutType = InType> {
|
||||
state: InType;
|
||||
setState: (callback: SetStateFn<InType, OutType>) => void;
|
||||
score: (suggestion: ResolvedType) => number;
|
||||
score: (suggestion: ExprBlockState) => number;
|
||||
}
|
||||
|
||||
interface ExprBlockProps extends State2Props<ExprBlockState> {
|
||||
|
|
@ -44,19 +45,22 @@ export function ExprBlock(props: ExprBlockProps) {
|
|||
lambda: () => <LambdaBlock {...props as LambdaBlockProps} />,
|
||||
};
|
||||
|
||||
const [resolved] = evalExprBlock(props.state, env);
|
||||
// const [resolved] = evalExprBlock(props.state, env);
|
||||
// const typeInfo = inferType(props.state, env);
|
||||
const actions = getActions(globalContext, props.setState);
|
||||
const extraHandlers = Object.fromEntries(Object.entries(actions).map(([shortcut, action]) =>
|
||||
[shortcut, (e) => { e.preventDefault(); action(); }]))
|
||||
|
||||
return <span className={"editor" + ((resolved.kind!=="value") ? " "+resolved.kind : "")}>
|
||||
// return <span className={"editor" + ((resolved.kind!=="value") ? " "+resolved.kind : "")}>
|
||||
|
||||
return <span className={"editor"}>
|
||||
{renderBlock[props.state.kind]()}
|
||||
{/* @ts-ignore */}
|
||||
<div className={"typeSignature" + (resolved.__debug ? ' gotDebug' : '')}>
|
||||
:: <Type type={getType(resolved)} />
|
||||
{/* <div className={"typeSignature" + (resolved.__debug ? ' gotDebug' : '')}> */}
|
||||
{/* :: <Type type={typeInfo.type} /> */}
|
||||
{/* @ts-ignore */}
|
||||
{resolved.__debug && <div className="typeDebug">{resolved.__debug}</div>}
|
||||
</div>
|
||||
{/* {resolved.__debug && <div className="typeDebug">{resolved.__debug}</div>} */}
|
||||
{/* </div> */}
|
||||
<Input
|
||||
placeholder="<c>"
|
||||
text=""
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue