Fix Typescript build errors

This commit is contained in:
Sam Nolan 2022-05-02 14:53:16 +00:00
parent c68138e5f6
commit 946b38fa27
5 changed files with 8 additions and 57 deletions

View File

@ -4,7 +4,9 @@
"homepage": "https://squiggle-language.com",
"license": "MIT",
"scripts": {
"build": "rescript build -with-deps && tsc",
"build": "yarn build:rescript && yarn build:typescript",
"build:rescript": "rescript build -with-deps",
"build:typescript": "tsc",
"bundle": "webpack",
"start": "rescript build -w -with-deps",
"clean": "rescript clean && rm -r dist",

View File

@ -8,15 +8,6 @@ import {
externalBindings,
expressionValue,
errorValue,
distributionError,
toPointSet,
continuousShape,
discreteShape,
distributionErrorToString,
internalCode,
mixedShape,
sampleSetDist,
symbolicDist,
} from "../rescript/TypescriptInterface.gen";
export {
makeSampleSetDist,
@ -46,48 +37,6 @@ export let defaultSamplingInputs: samplingParams = {
xyPointLength: 10000,
};
export type result<a, b> =
| {
tag: "Ok";
value: a;
}
| {
tag: "Error";
value: b;
};
export function resultMap<a, b, c>(
r: result<a, c>,
mapFn: (x: a) => b
): result<b, c> {
if (r.tag === "Ok") {
return { tag: "Ok", value: mapFn(r.value) };
} else {
return r;
}
}
function Ok<a, b>(x: a): result<a, b> {
return { tag: "Ok", value: x };
}
type tagged<a, b> = { tag: a; value: b };
function tag<a, b>(x: a, y: b): tagged<a, b> {
return { tag: x, value: y };
}
export type squiggleExpression =
| tagged<"symbol", string>
| tagged<"string", string>
| tagged<"call", string>
| tagged<"lambda", [string[], internalCode]>
| tagged<"array", squiggleExpression[]>
| tagged<"boolean", boolean>
| tagged<"distribution", Distribution>
| tagged<"number", number>
| tagged<"record", { [key: string]: squiggleExpression }>;
export function run(
squiggleString: string,
bindings?: externalBindings,

View File

@ -5,10 +5,9 @@ import {
genericDist,
environment,
symbolicDist,
recordEV,
internalCode,
discreteShape,
continuousShape,
lambdaValue,
} from "../rescript/TypescriptInterface.gen";
import { Distribution } from "./distribution";
import { tagged, tag } from "./types";
@ -38,7 +37,7 @@ export type rescriptExport =
}
| {
TAG: 5; // EvLambda
_0: [string[], recordEV, internalCode];
_0: lambdaValue;
}
| {
TAG: 6; // EvNumber
@ -80,7 +79,7 @@ export type squiggleExpression =
| tagged<"symbol", string>
| tagged<"string", string>
| tagged<"call", string>
| tagged<"lambda", [string[], recordEV, internalCode]>
| tagged<"lambda", lambdaValue>
| tagged<"array", squiggleExpression[]>
| tagged<"arraystring", string[]>
| tagged<"boolean", boolean>

View File

@ -114,6 +114,7 @@ module DistributionOperation = {
| ToFloat(#Mean) => `mean`
| ToFloat(#Pdf(r)) => `pdf(${E.Float.toFixed(r)})`
| ToFloat(#Sample) => `sample`
| ToFloat(#IntegralSum) => `integralSum`
| ToDist(Normalize) => `normalize`
| ToDist(ToPointSet) => `toPointSet`
| ToDist(ToSampleSet(r)) => `toSampleSet(${E.I.toString(r)})`

View File

@ -74,7 +74,7 @@ let errorValueToString = Reducer_ErrorValue.errorToString
let distributionErrorToString = DistributionTypes.Error.toString
@genType
type internalCode = ReducerInterface_ExpressionValue.internalCode
type lambdaValue = ReducerInterface_ExpressionValue.lambdaValue
@genType
let defaultSamplingEnv = ReducerInterface_GenericDistribution.defaultEnv