kill mj acronym

This commit is contained in:
Umur Ozkul 2022-03-30 10:22:51 +02:00
parent a9df64230e
commit 9a6522ff29
2 changed files with 11 additions and 11 deletions

View File

@ -47,7 +47,7 @@ let parse = (expr: string): result<node, errorValue> =>
| Js.Exn.Error(obj) => REJs(Js.Exn.message(obj), Js.Exn.name(obj))->Error
}
type mjNode =
type mathJsNode =
| MjAccessorNode(accessorNode)
| MjArrayNode(arrayNode)
| MjConstantNode(constantNode)
@ -72,7 +72,7 @@ let castNodeType = (node: node) =>
| _ => RETodo(`Argg, unhandled MathJsNode: ${node["type"]}`)->Error
}
let rec show = (mjNode: mjNode): string => {
let rec show = (mathJsNode: mathJsNode): string => {
let showValue = (a: 'a): string =>
if Js.typeof(a) == "string" {
`'${Js.String.make(a)}'`
@ -103,7 +103,7 @@ let rec show = (mjNode: mjNode): string => {
->Belt.Array.map(each => showResult(each->castNodeType))
->Js.String.concatMany("")
switch mjNode {
switch mathJsNode {
| MjAccessorNode(aNode) => `${aNode["object"]->showMathJsNode}[${aNode["index"]->showIndexNode}]`
| MjArrayNode(aNode) => `[${aNode["items"]->showNodeArray}]`
| MjConstantNode(cNode) => cNode["value"]->showValue
@ -115,9 +115,9 @@ let rec show = (mjNode: mjNode): string => {
| MjSymbolNode(sNode) => sNode["name"]
}
}
and showResult = (rmjnode: result<mjNode, errorValue>): string =>
switch rmjnode {
and showResult = (rMathJsNode: result<mathJsNode, errorValue>): string =>
switch rMathJsNode {
| Error(e) => showError(e)
| Ok(mjNode) => show(mjNode)
| Ok(mathJsNode) => show(mathJsNode)
}
and showMathJsNode = node => node->castNodeType->showResult

View File

@ -9,8 +9,8 @@ type expression = ExtressionT.expression
type expressionValue = ExpressionValue.expressionValue
type errorValue = ErrorValue.errorValue
let rec fromNode = (mjnode: Parse.node): result<expression, errorValue> =>
Parse.castNodeType(mjnode)->Result.flatMap(typedMjNode => {
let rec fromNode = (mathJsNode: Parse.node): result<expression, errorValue> =>
Parse.castNodeType(mathJsNode)->Result.flatMap(typedMathJsNode => {
let fromNodeList = (nodeList: list<Parse.node>): result<list<expression>, 'e> =>
Belt.List.reduceReverse(nodeList, Ok(list{}), (racc, currNode) =>
racc->Result.flatMap(acc =>
@ -52,9 +52,9 @@ let rec fromNode = (mjnode: Parse.node): result<expression, errorValue> =>
let rpropertyCodeList = Belt.List.reduceReverse(
iNode["dimensions"]->Belt.List.fromArray,
Ok(list{}),
(racc, currentPropertyMjNode) =>
(racc, currentPropertyMathJsNode) =>
racc->Result.flatMap(acc =>
fromNode(currentPropertyMjNode)->Result.map(propertyCode => list{propertyCode, ...acc})
fromNode(currentPropertyMathJsNode)->Result.map(propertyCode => list{propertyCode, ...acc})
),
)
rpropertyCodeList->Result.map(propertyCodeList => ExtressionT.EList(propertyCodeList))
@ -70,7 +70,7 @@ let rec fromNode = (mjnode: Parse.node): result<expression, errorValue> =>
})
}
switch typedMjNode {
switch typedMathJsNode {
| MjArrayNode(aNode) =>
aNode["items"]->Belt.List.fromArray->fromNodeList->Result.map(list => ExtressionT.EList(list))
| MjConstantNode(cNode) =>