Formalized export type of ProgramEvaluator

This commit is contained in:
Ozzie Gooen 2020-11-13 00:21:21 -08:00
parent 9520175795
commit e37d77d2de
2 changed files with 13 additions and 2 deletions

View File

@ -38,6 +38,15 @@ module Inputs = {
}; };
}; };
type export = [
| `DistPlus(ProbExample.DistPlus.t)
| `Float(float)
| `Function(
(array(string), ProbExample.ExpressionTypes.ExpressionTree.node),
ProbExample.ExpressionTypes.ExpressionTree.environment,
)
];
module Internals = { module Internals = {
let addVariable = let addVariable =
( (
@ -122,12 +131,14 @@ let renderIfNeeded =
| n => Ok(n) | n => Ok(n)
); );
// TODO: Consider using ExpressionTypes.ExpressionTree.getFloat or similar in this function
let coersionToExportedTypes = let coersionToExportedTypes =
( (
inputs, inputs,
env: ProbExample.ExpressionTypes.ExpressionTree.environment, env: ProbExample.ExpressionTypes.ExpressionTree.environment,
node: ExpressionTypes.ExpressionTree.node, node: ExpressionTypes.ExpressionTree.node,
) => )
: result(export, string) =>
node node
|> renderIfNeeded(inputs) |> renderIfNeeded(inputs)
|> E.R.bind( |> E.R.bind(

View File

@ -124,7 +124,7 @@ module ExpressionTree = {
type t = node; type t = node;
let render = (evaluationParams: evaluationParams, r) => let render = (evaluationParams: evaluationParams, r) =>
`Render(r) |> evaluateNode(evaluationParams) `Render(r) |> evaluateNode(evaluationParams);
let ensureIsRendered = (params, t) => let ensureIsRendered = (params, t) =>
switch (t) { switch (t) {