Added evaluateAndRetry function
This commit is contained in:
parent
9d0ecda297
commit
248545ee34
|
@ -174,10 +174,7 @@ module Normalize = {
|
|||
| `RenderedDist(s) =>
|
||||
Ok(`RenderedDist(Distributions.Shape.T.normalize(s)))
|
||||
| `SymbolicDist(_) => Ok(t)
|
||||
| _ =>
|
||||
t
|
||||
|> evaluateNode(evaluationParams)
|
||||
|> E.R.bind(_, operationToLeaf(evaluationParams))
|
||||
| _ => evaluateAndRetry(evaluationParams, operationToLeaf, t)
|
||||
};
|
||||
};
|
||||
};
|
||||
|
@ -195,8 +192,9 @@ module FloatFromDist = {
|
|||
|> (v => Ok(`SymbolicDist(`Float(v))))
|
||||
| _ =>
|
||||
t
|
||||
|> evaluateNode(evaluationParams)
|
||||
|> E.R.bind(_, operationToLeaf(evaluationParams, distToFloatOp))
|
||||
|> evaluateAndRetry(evaluationParams, r =>
|
||||
operationToLeaf(r, distToFloatOp)
|
||||
)
|
||||
};
|
||||
};
|
||||
};
|
||||
|
@ -212,10 +210,7 @@ module Render = {
|
|||
),
|
||||
)
|
||||
| `RenderedDist(_) as t => Ok(t) // already a rendered shape, we're done here
|
||||
| _ =>
|
||||
t
|
||||
|> evaluateNode(evaluationParams)
|
||||
|> E.R.bind(_, operationToLeaf(evaluationParams))
|
||||
| _ => evaluateAndRetry(evaluationParams, operationToLeaf, t)
|
||||
};
|
||||
};
|
||||
};
|
||||
|
|
|
@ -19,7 +19,7 @@ module ExpressionTree = {
|
|||
type dist = [
|
||||
| `SymbolicDist(SymbolicTypes.symbolicDist)
|
||||
| `RenderedDist(DistTypes.shape)
|
||||
]
|
||||
];
|
||||
|
||||
type evaluationParams = {
|
||||
sampleCount: int,
|
||||
|
@ -31,6 +31,9 @@ module ExpressionTree = {
|
|||
|
||||
let render = (evaluationParams: evaluationParams, r) =>
|
||||
evaluateNode(evaluationParams, `Render(r));
|
||||
|
||||
let evaluateAndRetry = (evaluationParams, fn, node) =>
|
||||
node |> evaluationParams.evaluateNode(evaluationParams) |> E.R.bind(_, fn(evaluationParams));
|
||||
};
|
||||
|
||||
type simplificationResult = [
|
||||
|
|
Loading…
Reference in New Issue
Block a user