Fix Typescript build errors
This commit is contained in:
parent
c68138e5f6
commit
946b38fa27
|
@ -4,7 +4,9 @@
|
||||||
"homepage": "https://squiggle-language.com",
|
"homepage": "https://squiggle-language.com",
|
||||||
"license": "MIT",
|
"license": "MIT",
|
||||||
"scripts": {
|
"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",
|
"bundle": "webpack",
|
||||||
"start": "rescript build -w -with-deps",
|
"start": "rescript build -w -with-deps",
|
||||||
"clean": "rescript clean && rm -r dist",
|
"clean": "rescript clean && rm -r dist",
|
||||||
|
|
|
@ -8,15 +8,6 @@ import {
|
||||||
externalBindings,
|
externalBindings,
|
||||||
expressionValue,
|
expressionValue,
|
||||||
errorValue,
|
errorValue,
|
||||||
distributionError,
|
|
||||||
toPointSet,
|
|
||||||
continuousShape,
|
|
||||||
discreteShape,
|
|
||||||
distributionErrorToString,
|
|
||||||
internalCode,
|
|
||||||
mixedShape,
|
|
||||||
sampleSetDist,
|
|
||||||
symbolicDist,
|
|
||||||
} from "../rescript/TypescriptInterface.gen";
|
} from "../rescript/TypescriptInterface.gen";
|
||||||
export {
|
export {
|
||||||
makeSampleSetDist,
|
makeSampleSetDist,
|
||||||
|
@ -46,48 +37,6 @@ export let defaultSamplingInputs: samplingParams = {
|
||||||
xyPointLength: 10000,
|
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(
|
export function run(
|
||||||
squiggleString: string,
|
squiggleString: string,
|
||||||
bindings?: externalBindings,
|
bindings?: externalBindings,
|
||||||
|
|
|
@ -5,10 +5,9 @@ import {
|
||||||
genericDist,
|
genericDist,
|
||||||
environment,
|
environment,
|
||||||
symbolicDist,
|
symbolicDist,
|
||||||
recordEV,
|
|
||||||
internalCode,
|
|
||||||
discreteShape,
|
discreteShape,
|
||||||
continuousShape,
|
continuousShape,
|
||||||
|
lambdaValue,
|
||||||
} 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";
|
||||||
|
@ -38,7 +37,7 @@ export type rescriptExport =
|
||||||
}
|
}
|
||||||
| {
|
| {
|
||||||
TAG: 5; // EvLambda
|
TAG: 5; // EvLambda
|
||||||
_0: [string[], recordEV, internalCode];
|
_0: lambdaValue;
|
||||||
}
|
}
|
||||||
| {
|
| {
|
||||||
TAG: 6; // EvNumber
|
TAG: 6; // EvNumber
|
||||||
|
@ -80,7 +79,7 @@ export type squiggleExpression =
|
||||||
| tagged<"symbol", string>
|
| tagged<"symbol", string>
|
||||||
| tagged<"string", string>
|
| tagged<"string", string>
|
||||||
| tagged<"call", string>
|
| tagged<"call", string>
|
||||||
| tagged<"lambda", [string[], recordEV, internalCode]>
|
| tagged<"lambda", lambdaValue>
|
||||||
| tagged<"array", squiggleExpression[]>
|
| tagged<"array", squiggleExpression[]>
|
||||||
| tagged<"arraystring", string[]>
|
| tagged<"arraystring", string[]>
|
||||||
| tagged<"boolean", boolean>
|
| tagged<"boolean", boolean>
|
||||||
|
|
|
@ -114,6 +114,7 @@ module DistributionOperation = {
|
||||||
| ToFloat(#Mean) => `mean`
|
| ToFloat(#Mean) => `mean`
|
||||||
| ToFloat(#Pdf(r)) => `pdf(${E.Float.toFixed(r)})`
|
| ToFloat(#Pdf(r)) => `pdf(${E.Float.toFixed(r)})`
|
||||||
| ToFloat(#Sample) => `sample`
|
| ToFloat(#Sample) => `sample`
|
||||||
|
| ToFloat(#IntegralSum) => `integralSum`
|
||||||
| ToDist(Normalize) => `normalize`
|
| ToDist(Normalize) => `normalize`
|
||||||
| ToDist(ToPointSet) => `toPointSet`
|
| ToDist(ToPointSet) => `toPointSet`
|
||||||
| ToDist(ToSampleSet(r)) => `toSampleSet(${E.I.toString(r)})`
|
| ToDist(ToSampleSet(r)) => `toSampleSet(${E.I.toString(r)})`
|
||||||
|
|
|
@ -74,7 +74,7 @@ let errorValueToString = Reducer_ErrorValue.errorToString
|
||||||
let distributionErrorToString = DistributionTypes.Error.toString
|
let distributionErrorToString = DistributionTypes.Error.toString
|
||||||
|
|
||||||
@genType
|
@genType
|
||||||
type internalCode = ReducerInterface_ExpressionValue.internalCode
|
type lambdaValue = ReducerInterface_ExpressionValue.lambdaValue
|
||||||
|
|
||||||
@genType
|
@genType
|
||||||
let defaultSamplingEnv = ReducerInterface_GenericDistribution.defaultEnv
|
let defaultSamplingEnv = ReducerInterface_GenericDistribution.defaultEnv
|
||||||
|
|
Loading…
Reference in New Issue
Block a user