From a5bb390370a8e730418c3dbc92c87f27311669e1 Mon Sep 17 00:00:00 2001 From: Umur Ozkul Date: Tue, 5 Apr 2022 20:54:51 +0200 Subject: [PATCH] reformat --- .../__tests__/Reducer/Reducer_test.res | 37 +++++++++---------- .../Reducer_Expression.resi | 20 ++-------- .../Reducer_MathJs_ToExpression.res | 5 ++- .../ReducerInterface_ExpressionValue.res | 5 ++- 4 files changed, 29 insertions(+), 38 deletions(-) diff --git a/packages/squiggle-lang/__tests__/Reducer/Reducer_test.res b/packages/squiggle-lang/__tests__/Reducer/Reducer_test.res index 7f6ae6f1..a7539b7f 100644 --- a/packages/squiggle-lang/__tests__/Reducer/Reducer_test.res +++ b/packages/squiggle-lang/__tests__/Reducer/Reducer_test.res @@ -1,18 +1,13 @@ open Jest open Reducer_TestHelpers +let testParseToBe = (expr, answer) => test(expr, () => expectParseToBe(expr, answer)) -let testParseToBe = (expr, answer) => - test(expr, () => expectParseToBe(expr, answer)) +let testDescParseToBe = (desc, expr, answer) => test(desc, () => expectParseToBe(expr, answer)) -let testDescParseToBe = (desc, expr, answer) => - test(desc, () => expectParseToBe(expr, answer)) +let testEvalToBe = (expr, answer) => test(expr, () => expectEvalToBe(expr, answer)) -let testEvalToBe = (expr, answer) => - test(expr, () => expectEvalToBe(expr, answer)) - -let testDescEvalToBe = (desc, expr, answer) => - test(desc, () => expectEvalToBe(expr, answer)) +let testDescEvalToBe = (desc, expr, answer) => test(desc, () => expectEvalToBe(expr, answer)) describe("reducer using mathjs parse", () => { // Test the MathJs parser compatibility @@ -40,11 +35,12 @@ describe("reducer using mathjs parse", () => { testDescParseToBe("index", "([0,1,2])[1]", "Ok((:$atIndex (0 1 2) (1)))") }) describe("records", () => { - testDescParseToBe("define", - "{a: 1, b: 2}", "Ok((:$constructRecord (('a' 1) ('b' 2))))") - testDescParseToBe("use", - "{a: 1, b: 2}.a", - "Ok((:$atIndex (:$constructRecord (('a' 1) ('b' 2))) ('a')))") + testDescParseToBe("define", "{a: 1, b: 2}", "Ok((:$constructRecord (('a' 1) ('b' 2))))") + testDescParseToBe( + "use", + "{a: 1, b: 2}.a", + "Ok((:$atIndex (:$constructRecord (('a' 1) ('b' 2))) ('a')))", + ) }) }) @@ -68,8 +64,7 @@ describe("eval", () => { testEvalToBe("[1, 2, 3]", "Ok([1, 2, 3])") testEvalToBe("['hello', 'world']", "Ok(['hello', 'world'])") testEvalToBe("([0,1,2])[1]", "Ok(1)") - testDescEvalToBe("index not found", - "([0,1,2])[10]", "Error(Array index not found: 10)") + testDescEvalToBe("index not found", "([0,1,2])[10]", "Error(Array index not found: 10)") }) describe("records", () => { test("define", () => expectEvalToBe("{a: 1, b: 2}", "Ok({a: 1, b: 2})")) @@ -79,8 +74,10 @@ describe("eval", () => { }) describe("test exceptions", () => { - testDescEvalToBe("javascript exception", - "jsraise('div by 0')", "Error(JS Exception: Error: 'div by 0')") - testDescEvalToBe("rescript exception", - "resraise()", "Error(TODO: unhandled rescript exception)") + testDescEvalToBe( + "javascript exception", + "jsraise('div by 0')", + "Error(JS Exception: Error: 'div by 0')", + ) + testDescEvalToBe("rescript exception", "resraise()", "Error(TODO: unhandled rescript exception)") }) diff --git a/packages/squiggle-lang/src/rescript/Reducer/Reducer_Expression/Reducer_Expression.resi b/packages/squiggle-lang/src/rescript/Reducer/Reducer_Expression/Reducer_Expression.resi index 8b09c516..afd0105f 100644 --- a/packages/squiggle-lang/src/rescript/Reducer/Reducer_Expression/Reducer_Expression.resi +++ b/packages/squiggle-lang/src/rescript/Reducer/Reducer_Expression/Reducer_Expression.resi @@ -9,20 +9,8 @@ let parse: string => result module MapString = Belt.Map.String type bindings = MapString.t let defaultBindings: bindings -let reduceValueList: list => result< - expressionValue, - Reducer_ErrorValue.t, -> -let reduceExpression: (expression, 'a) => result< - expressionValue, - Reducer_ErrorValue.t, -> -let evalWBindingsExpression: (expression, 'a) => result< - expressionValue, - Reducer_ErrorValue.t, -> -let evalWBindings: (string, bindings) => Result.t< - expressionValue, - Reducer_ErrorValue.t, -> +let reduceValueList: list => result +let reduceExpression: (expression, 'a) => result +let evalWBindingsExpression: (expression, 'a) => result +let evalWBindings: (string, bindings) => Result.t let eval: string => Result.t diff --git a/packages/squiggle-lang/src/rescript/Reducer/Reducer_MathJs/Reducer_MathJs_ToExpression.res b/packages/squiggle-lang/src/rescript/Reducer/Reducer_MathJs/Reducer_MathJs_ToExpression.res index 5b16fb54..edd0313b 100644 --- a/packages/squiggle-lang/src/rescript/Reducer/Reducer_MathJs/Reducer_MathJs_ToExpression.res +++ b/packages/squiggle-lang/src/rescript/Reducer/Reducer_MathJs/Reducer_MathJs_ToExpression.res @@ -54,7 +54,10 @@ let rec fromNode = (mathJsNode: Parse.node): result => Ok(list{}), (racc, currentPropertyMathJsNode) => racc->Result.flatMap(acc => - fromNode(currentPropertyMathJsNode)->Result.map(propertyCode => list{propertyCode, ...acc}) + fromNode(currentPropertyMathJsNode)->Result.map(propertyCode => list{ + propertyCode, + ...acc, + }) ), ) rpropertyCodeList->Result.map(propertyCodeList => ExtressionT.EList(propertyCodeList)) diff --git a/packages/squiggle-lang/src/rescript/ReducerInterface/ReducerInterface_ExpressionValue.res b/packages/squiggle-lang/src/rescript/ReducerInterface/ReducerInterface_ExpressionValue.res index 8c94d752..1aeca2f1 100644 --- a/packages/squiggle-lang/src/rescript/ReducerInterface/ReducerInterface_ExpressionValue.res +++ b/packages/squiggle-lang/src/rescript/ReducerInterface/ReducerInterface_ExpressionValue.res @@ -23,7 +23,10 @@ let rec toString = aValue => | EvSymbol(aString) => `:${aString}` | EvArray(anArray) => { let args = - anArray->Belt.Array.map(each => toString(each))->Extra_Array.interperse(", ")->Js.String.concatMany("") + anArray + ->Belt.Array.map(each => toString(each)) + ->Extra_Array.interperse(", ") + ->Js.String.concatMany("") `[${args}]` } | EvRecord(aRecord) => {