Minor cleanup

This commit is contained in:
Ozzie Gooen 2020-11-08 18:30:25 -08:00
parent d2e7605ffd
commit 27611ee7bf

View File

@ -250,7 +250,6 @@ module FunctionCall = {
}; };
}; };
module Render = { module Render = {
let rec operationToLeaf = let rec operationToLeaf =
(evaluationParams: evaluationParams, t: node): result(t, string) => { (evaluationParams: evaluationParams, t: node): result(t, string) => {
@ -284,18 +283,16 @@ let rec toLeaf =
node: t, node: t,
) )
: result(t, string) => { : result(t, string) => {
Js.log2("node", node);
switch (node) { switch (node) {
// Leaf nodes just stay leaf nodes // Leaf nodes just stay leaf nodes
| `SymbolicDist(_) | `SymbolicDist(_)
| `Function(_) | `Function(_)
| `RenderedDist(_) => Ok(node) | `RenderedDist(_) => Ok(node)
| `Array(args) => | `Array(args) =>
Js.log2("Array!", args);
args args
|> E.A.fmap(toLeaf(evaluationParams)) |> E.A.fmap(toLeaf(evaluationParams))
|> E.A.R.firstErrorOrOpen |> E.A.R.firstErrorOrOpen
|> E.R.fmap(r => `Array(r)); |> E.R.fmap(r => `Array(r))
// Operations nevaluationParamsd to be turned into leaves // Operations nevaluationParamsd to be turned into leaves
| `AlgebraicCombination(algebraicOp, t1, t2) => | `AlgebraicCombination(algebraicOp, t1, t2) =>
AlgebraicCombination.operationToLeaf( AlgebraicCombination.operationToLeaf(
@ -316,24 +313,21 @@ let rec toLeaf =
| `Normalize(t) => Normalize.operationToLeaf(evaluationParams, t) | `Normalize(t) => Normalize.operationToLeaf(evaluationParams, t)
| `Render(t) => Render.operationToLeaf(evaluationParams, t) | `Render(t) => Render.operationToLeaf(evaluationParams, t)
| `Hash(t) => | `Hash(t) =>
Js.log("In hash");
t t
|> E.A.fmap(((name: string, node: node)) => |> E.A.fmap(((name: string, node: node)) =>
toLeaf(evaluationParams, node) |> E.R.fmap(r => (name, r)) toLeaf(evaluationParams, node) |> E.R.fmap(r => (name, r))
) )
|> E.A.R.firstErrorOrOpen |> E.A.R.firstErrorOrOpen
|> E.R.fmap(r => `Hash(r)); |> E.R.fmap(r => `Hash(r))
| `Symbol(r) => | `Symbol(r) =>
Js.log("Symbol");
ExpressionTypes.ExpressionTree.Environment.get( ExpressionTypes.ExpressionTree.Environment.get(
evaluationParams.environment, evaluationParams.environment,
r, r,
) )
|> E.O.toResult("Undeclared variable " ++ r) |> E.O.toResult("Undeclared variable " ++ r)
|> E.R.bind(_, toLeaf(evaluationParams)); |> E.R.bind(_, toLeaf(evaluationParams))
| `FunctionCall(name, args) => | `FunctionCall(name, args) =>
Js.log3("In function call", name, args);
FunctionCall.run(evaluationParams, name, args) FunctionCall.run(evaluationParams, name, args)
|> E.R.bind(_, toLeaf(evaluationParams)); |> E.R.bind(_, toLeaf(evaluationParams))
}; };
}; };