Adding very simple hashes to types

This commit is contained in:
Ozzie Gooen 2020-08-13 18:53:12 +01:00
parent 274b5929a6
commit 6d36284283
3 changed files with 10 additions and 2 deletions

View File

@ -21,6 +21,7 @@ export class CodeEditor extends React.Component {
mode="golang" mode="golang"
height="400px" height="400px"
width="100%" width="100%"
keyboardHandler="vim"
theme="github" theme="github"
showGutter={false} showGutter={false}
highlightActiveLine={false} highlightActiveLine={false}

View File

@ -337,6 +337,13 @@ let rec toLeaf =
FloatFromDist.operationToLeaf(evaluationParams, distToFloatOp, t) FloatFromDist.operationToLeaf(evaluationParams, distToFloatOp, t)
| `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) =>
t
|> E.A.fmap(((name: string, node: node)) =>
toLeaf(evaluationParams, node) |> E.R.fmap(r => (name, r))
)
|> E.A.R.firstErrorOrOpen
|> E.R.fmap(r => `Hash(r))
| `Symbol(r) => | `Symbol(r) =>
ExpressionTypes.ExpressionTree.Environment.get( ExpressionTypes.ExpressionTree.Environment.get(
evaluationParams.environment, evaluationParams.environment,
@ -364,7 +371,6 @@ let rec toLeaf =
(acc, x) => {`PointwiseCombination((`Add, acc, x))}, (acc, x) => {`PointwiseCombination((`Add, acc, x))},
E.A.unsafe_get(components, 0), E.A.unsafe_get(components, 0),
); );
Ok(`Normalize(pointwiseSum)) Ok(`Normalize(pointwiseSum)) |> E.R.bind(_, toLeaf(evaluationParams));
|> E.R.bind(_, toLeaf(evaluationParams))
}; };
}; };

View File

@ -20,6 +20,7 @@ module ExpressionTree = {
| `SymbolicDist(SymbolicTypes.symbolicDist) | `SymbolicDist(SymbolicTypes.symbolicDist)
| `RenderedDist(DistTypes.shape) | `RenderedDist(DistTypes.shape)
| `Symbol(string) | `Symbol(string)
| `Hash(array((string, node)))
| `Function(array(string), node) | `Function(array(string), node)
| `AlgebraicCombination(algebraicOperation, node, node) | `AlgebraicCombination(algebraicOperation, node, node)
| `PointwiseCombination(pointwiseOperation, node, node) | `PointwiseCombination(pointwiseOperation, node, node)