diff --git a/src/components/DistBuilder.re b/src/components/DistBuilder.re
index 5f3fd6da..adff8715 100644
--- a/src/components/DistBuilder.re
+++ b/src/components/DistBuilder.re
@@ -165,8 +165,8 @@ module DemoDist = {
| Ok(`Function(f, a)) =>
let result1 = DistPlusRenderer.runFunction(inputs1, (f, a), [|`SymbolicDist(`Float(5.0))|],);
- let result2 = DistPlusRenderer.runFunction(inputs1, (f, a), [|`SymbolicDist(`Float(20.0))|],);
- let result3 = DistPlusRenderer.runFunction(inputs1, (f, a), [|`SymbolicDist(`Float(40.0))|],);
+ let result2 = DistPlusRenderer.runFunction(inputs1, (f, a), [|`SymbolicDist(`Float(10.0))|],);
+ let result3 = DistPlusRenderer.runFunction(inputs1, (f, a), [|`SymbolicDist(`Float(20.0))|],);
switch (result1, result2, result3) {
| (Ok(`DistPlus(distPlus1)),Ok(`DistPlus(distPlus2)),Ok(`DistPlus(distPlus3))) =>
<>
@@ -174,6 +174,7 @@ module DemoDist = {
>
+ | (Error(r), _, _) => r |> R.ste
| _ => "Failure " |> R.ste
};
| Error(r) => r |> R.ste
diff --git a/src/components/charts/DistPlusPlot.re b/src/components/charts/DistPlusPlot.re
index ca8c0dc1..e13fcac0 100644
--- a/src/components/charts/DistPlusPlot.re
+++ b/src/components/charts/DistPlusPlot.re
@@ -259,7 +259,6 @@ module DistPlusChart = {
module IntegralChart = {
[@react.component]
let make = (~distPlus: DistTypes.distPlus, ~config: chartConfig, ~onHover) => {
- open DistPlus;
let integral = distPlus.integralCache;
let continuous =
integral
diff --git a/src/distPlus/expressionTree/ExpressionTree.re b/src/distPlus/expressionTree/ExpressionTree.re
index b61d04ce..3e7193ab 100644
--- a/src/distPlus/expressionTree/ExpressionTree.re
+++ b/src/distPlus/expressionTree/ExpressionTree.re
@@ -9,7 +9,7 @@ let toLeaf = (samplingInputs, environment, node: node) =>
let rec toString: node => string =
fun
| `SymbolicDist(d) => SymbolicDist.T.toString(d)
- | `RenderedDist(_) => "[shape]"
+ | `RenderedDist(_) => "[renderedShape]"
| `AlgebraicCombination(op, t1, t2) =>
Operation.Algebraic.format(op, toString(t1), toString(t2))
| `PointwiseCombination(op, t1, t2) =>
diff --git a/src/distPlus/expressionTree/Functions.re b/src/distPlus/expressionTree/Functions.re
index 64dca1fe..1f7a6dd2 100644
--- a/src/distPlus/expressionTree/Functions.re
+++ b/src/distPlus/expressionTree/Functions.re
@@ -93,5 +93,5 @@ let fnn =
| _ => Error("Needs 3 valid arguments")
}
| ("to", _) => to_(args)
- | _ => Error("Function not found")
+ | _ => Error("Function " ++ name ++ " not found")
};
diff --git a/src/distPlus/renderers/DistPlusRenderer.re b/src/distPlus/renderers/DistPlusRenderer.re
index 4765722d..e8c97342 100644
--- a/src/distPlus/renderers/DistPlusRenderer.re
+++ b/src/distPlus/renderers/DistPlusRenderer.re
@@ -144,24 +144,31 @@ let run = (inputs: Inputs.inputs) => {
|> E.R.bind(_, r =>
switch (r) {
| `RenderedDist(n) => Ok(n)
- | _ => Error("Didn't output renderedDist")
+ | n =>
+ Error(
+ "Didn't output a rendered distribution. Format:"
+ ++ ExpressionTree.toString(n),
+ )
}
)
|> E.R.fmap(Internals.outputToDistPlus(inputs));
};
+let exportDistPlus = inputs =>
+ fun
+ | `RenderedDist(n) => Ok(`DistPlus(Internals.outputToDistPlus(inputs, n)))
+ | `Function(n) => Ok(`Function(n))
+ | n =>
+ Error(
+ "Didn't output a rendered distribution. Format:"
+ ++ ExpressionTree.toString(n),
+ );
+
let run2 = (inputs: Inputs.inputs) => {
inputs
|> Internals.distPlusRenderInputsToInputs
|> Internals.inputsToLeaf
- |> E.R.bind(_, r =>
- switch (r) {
- | `RenderedDist(n) =>
- Ok(`DistPlus(Internals.outputToDistPlus(inputs, n)))
- | `Function(n) => Ok(`Function(n))
- | _ => Error("Didn't output renderedDist")
- }
- );
+ |> E.R.bind(_, exportDistPlus(inputs));
};
let runFunction =
@@ -185,10 +192,5 @@ let runFunction =
fnInputs,
fn,
);
- Js.log2("GOt output", output);
- switch (output) {
- | Ok(`RenderedDist(n)) => Ok(`DistPlus(Internals.outputToDistPlus(ins, n)))
- | Ok(`Function(n)) => Ok(`Function(n))
- | _ => Error("Didn't output renderedDist")
- };
+ output |> E.R.bind(_, exportDistPlus(ins));
};