Added very simple lambdaDeclaration to React components

This commit is contained in:
Ozzie Gooen 2022-05-24 17:23:37 -04:00
parent d1f2f71912
commit 533c97c41c
4 changed files with 32 additions and 0 deletions

View File

@ -202,6 +202,25 @@ const SquiggleItem: React.FC<SquiggleItemProps> = ({
</VariableBox> </VariableBox>
); );
} }
case "lambdaDeclaration": {
switch (expression.value.tag) {
case "Continuous": {
return (
<FunctionChart
fn={expression.value.value.fn}
chartSettings={chartSettings}
environment={{
sampleCount: environment.sampleCount / 10,
xyPointLength: environment.xyPointLength / 10,
}}
/>
);
}
case "RelativeComparison": {
return <></>;
}
}
}
case "lambda": case "lambda":
return ( return (
<FunctionChart <FunctionChart

View File

@ -185,5 +185,7 @@ function createTsExport(
return tag("date", x.value); return tag("date", x.value);
case "EvTimeDuration": case "EvTimeDuration":
return tag("timeDuration", x.value); return tag("timeDuration", x.value);
case "EvDeclaration":
return tag("lambdaDeclaration", x.value);
} }
} }

View File

@ -9,6 +9,7 @@ import {
discreteShape, discreteShape,
continuousShape, continuousShape,
lambdaValue, lambdaValue,
lambdaDeclaration
} from "../rescript/TypescriptInterface.gen"; } from "../rescript/TypescriptInterface.gen";
import { Distribution } from "./distribution"; import { Distribution } from "./distribution";
import { tagged, tag } from "./types"; import { tagged, tag } from "./types";
@ -63,6 +64,10 @@ export type rescriptExport =
| { | {
TAG: 11; // EvTimeDuration TAG: 11; // EvTimeDuration
_0: number; _0: number;
}
| {
TAG: 12; // EvDeclaration
_0: lambdaDeclaration;
}; };
type rescriptDist = type rescriptDist =
@ -96,6 +101,7 @@ export type squiggleExpression =
| tagged<"number", number> | tagged<"number", number>
| tagged<"date", Date> | tagged<"date", Date>
| tagged<"timeDuration", number> | tagged<"timeDuration", number>
| tagged<"lambdaDeclaration", lambdaDeclaration>
| tagged<"record", { [key: string]: squiggleExpression }>; | tagged<"record", { [key: string]: squiggleExpression }>;
export { lambdaValue }; export { lambdaValue };
@ -141,6 +147,8 @@ export function convertRawToTypescript(
return tag("date", result._0); return tag("date", result._0);
case 11: // EvTimeDuration case 11: // EvTimeDuration
return tag("number", result._0); return tag("number", result._0);
case 12: // EvDeclaration
return tag("lambdaDeclaration", result._0);
} }
} }

View File

@ -76,6 +76,9 @@ let distributionErrorToString = DistributionTypes.Error.toString
@genType @genType
type lambdaValue = ReducerInterface_ExpressionValue.lambdaValue type lambdaValue = ReducerInterface_ExpressionValue.lambdaValue
@genType
type lambdaDeclaration = ReducerInterface_ExpressionValue.lambdaDeclaration
@genType @genType
let defaultSamplingEnv = DistributionOperation.defaultEnv let defaultSamplingEnv = DistributionOperation.defaultEnv