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>
);
}
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":
return (
<FunctionChart

View File

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

View File

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