remove opaque type violations

This commit is contained in:
Umur Ozkul 2022-08-19 23:19:30 +02:00
parent 05ce6d2872
commit 7957b89bb4

View File

@ -100,22 +100,22 @@ type rescriptPointSetDist =
_0: continuousShape; _0: continuousShape;
}; };
type rescriptLambdaDeclaration = { // type rescriptLambdaDeclaration = {
readonly fn: lambdaValue; // readonly fn: lambdaValue;
readonly args: rescriptDeclarationArg[]; // readonly args: rescriptDeclarationArg[];
}; // };
type rescriptDeclarationArg = // type rescriptDeclarationArg =
| { // | {
TAG: 0; // Float // TAG: 0; // Float
min: number; // min: number;
max: number; // max: number;
} // }
| { // | {
TAG: 1; // Date // TAG: 1; // Date
min: Date; // min: Date;
max: Date; // max: Date;
}; // };
// Umur: Squiggle expressions are opaque! // Umur: Squiggle expressions are opaque!
// export type squiggleExpression = // export type squiggleExpression =
@ -200,16 +200,16 @@ export { lambdaValue };
// } // }
// } // }
function convertDeclaration( // function convertDeclaration(
declarationArg: rescriptDeclarationArg // declarationArg: rescriptDeclarationArg
): declarationArg { // ): declarationArg {
switch (declarationArg.TAG) { // switch (declarationArg.TAG) {
case 0: // Float // case 0: // Float
return tag("Float", { min: declarationArg.min, max: declarationArg.max }); // return tag("Float", { min: declarationArg.min, max: declarationArg.max });
case 1: // Date // case 1: // Date
return tag("Date", { min: declarationArg.min, max: declarationArg.max }); // return tag("Date", { min: declarationArg.min, max: declarationArg.max });
} // }
} // }
function convertRawDistributionToGenericDist( function convertRawDistributionToGenericDist(
result: rescriptDist result: rescriptDist
@ -238,35 +238,35 @@ export type jsValue =
| { [key: string]: jsValue } | { [key: string]: jsValue }
| boolean; | boolean;
export function jsValueToBinding(value: jsValue): rescriptExport { // export function jsValueToBinding(value: jsValue): rescriptExport {
if (typeof value === "boolean") { // if (typeof value === "boolean") {
return { TAG: 2, _0: value as boolean }; // return { TAG: 2, _0: value as boolean };
} else if (typeof value === "string") { // } else if (typeof value === "string") {
return { TAG: 8, _0: value as string }; // return { TAG: 8, _0: value as string };
} else if (typeof value === "number") { // } else if (typeof value === "number") {
return { TAG: 6, _0: value as number }; // return { TAG: 6, _0: value as number };
} else if (Array.isArray(value)) { // } else if (Array.isArray(value)) {
return { TAG: 0, _0: value.map(jsValueToBinding) }; // return { TAG: 0, _0: value.map(jsValueToBinding) };
} else { // } else {
// Record // // Record
return { TAG: 7, _0: _.mapValues(value, jsValueToBinding) }; // return { TAG: 7, _0: _.mapValues(value, jsValueToBinding) };
} // }
} // }
export function jsValueToExpressionValue(value: jsValue): expressionValue { // export function jsValueToExpressionValue(value: jsValue): expressionValue {
if (typeof value === "boolean") { // if (typeof value === "boolean") {
return { tag: "EvBool", value: value as boolean }; // return { tag: "EvBool", value: value as boolean };
} else if (typeof value === "string") { // } else if (typeof value === "string") {
return { tag: "EvString", value: value as string }; // return { tag: "EvString", value: value as string };
} else if (typeof value === "number") { // } else if (typeof value === "number") {
return { tag: "EvNumber", value: value as number }; // return { tag: "EvNumber", value: value as number };
} else if (Array.isArray(value)) { // } else if (Array.isArray(value)) {
return { tag: "EvArray", value: value.map(jsValueToExpressionValue) }; // return { tag: "EvArray", value: value.map(jsValueToExpressionValue) };
} else { // } else {
// Record // // Record
return { // return {
tag: "EvRecord", // tag: "EvRecord",
value: _.mapValues(value, jsValueToExpressionValue), // value: _.mapValues(value, jsValueToExpressionValue),
}; // };
} // }
} // }