From 92483e66e0623fb75309f361147c0ec262e63e13 Mon Sep 17 00:00:00 2001 From: Vyacheslav Matyukhin Date: Tue, 20 Sep 2022 02:19:55 +0400 Subject: [PATCH] yarn format --- .../Reducer_Peggy_ToExpression_void_test.res | 7 +- .../__tests__/Reducer/Reducer_TestHelpers.res | 5 +- .../ReducerInterface_ExpressionValue_test.res | 8 +- .../ReducerProject_tutorial_1_test.res | 12 +- ...cerProject_tutorial_2_multisource_test.res | 18 +-- ...educerProject_tutorial_3_includes_test.res | 6 +- ...leLibrary_FunctionRegistryLibrary_test.res | 5 +- .../src/rescript/FR/FR_Builtin.res | 106 ++++-------------- .../squiggle-lang/src/rescript/FR/FR_Dict.res | 5 +- .../src/rescript/FR/FR_GenericDist.res | 18 +-- .../squiggle-lang/src/rescript/FR/FR_List.res | 7 +- .../squiggle-lang/src/rescript/FR/FR_Math.res | 51 ++------- .../src/rescript/FR/FR_Sampleset.res | 4 +- .../ForTS_SquiggleValue.res | 3 +- .../ForTS_SquiggleValue_Array.res | 6 +- .../ForTS_SquiggleValue_Declaration.res | 3 +- .../ForTS_SquiggleValue_Distribution.res | 3 +- .../ForTS_SquiggleValue_Lambda.res | 3 +- .../ForTS_SquiggleValue_Type.res | 3 +- .../FunctionRegistry_Core.res | 7 +- .../FunctionRegistry_Helpers.res | 52 ++++----- .../src/rescript/Reducer/Reducer_Context.res | 3 +- .../Reducer_Expression/Reducer_Expression.res | 4 +- .../rescript/Reducer/Reducer_Namespace.res | 4 +- .../Reducer_Type/Reducer_Type_Contracts.res | 11 +- .../SquiggleLibrary_StdLib.res | 13 +-- 26 files changed, 104 insertions(+), 263 deletions(-) diff --git a/packages/squiggle-lang/__tests__/Reducer/Reducer_Peggy/Reducer_Peggy_ToExpression_void_test.res b/packages/squiggle-lang/__tests__/Reducer/Reducer_Peggy/Reducer_Peggy_ToExpression_void_test.res index 451656cb..465789da 100644 --- a/packages/squiggle-lang/__tests__/Reducer/Reducer_Peggy/Reducer_Peggy_ToExpression_void_test.res +++ b/packages/squiggle-lang/__tests__/Reducer/Reducer_Peggy/Reducer_Peggy_ToExpression_void_test.res @@ -10,12 +10,7 @@ describe("Peggy void", () => { // ~v="@{fn: lambda(_=>internal code)}", (), ) - testToExpression( - "fn()=1; fn()", - "fn = {|_| {1}}; (fn)(())", - ~v="1", - (), - ) + testToExpression("fn()=1; fn()", "fn = {|_| {1}}; (fn)(())", ~v="1", ()) testToExpression( "fn(a)=(); call fn(1)", "fn = {|a| {()}}; _ = {(fn)(1)}", diff --git a/packages/squiggle-lang/__tests__/Reducer/Reducer_TestHelpers.res b/packages/squiggle-lang/__tests__/Reducer/Reducer_TestHelpers.res index 5d335556..43de902e 100644 --- a/packages/squiggle-lang/__tests__/Reducer/Reducer_TestHelpers.res +++ b/packages/squiggle-lang/__tests__/Reducer/Reducer_TestHelpers.res @@ -17,10 +17,7 @@ let expectParseToBe = (code: string, answer: string) => Expression.BackCompatible.parse(code)->ExpressionT.toStringResult->expect->toBe(answer) let expectEvalToBe = (code: string, answer: string) => - Expression.BackCompatible.evaluateString(code) - ->Reducer_Value.toStringResult - ->expect - ->toBe(answer) + Expression.BackCompatible.evaluateString(code)->Reducer_Value.toStringResult->expect->toBe(answer) let expectEvalError = (code: string) => Expression.BackCompatible.evaluateString(code) diff --git a/packages/squiggle-lang/__tests__/ReducerInterface/ReducerInterface_ExpressionValue_test.res b/packages/squiggle-lang/__tests__/ReducerInterface/ReducerInterface_ExpressionValue_test.res index 31054a67..9b1558c1 100644 --- a/packages/squiggle-lang/__tests__/ReducerInterface/ReducerInterface_ExpressionValue_test.res +++ b/packages/squiggle-lang/__tests__/ReducerInterface/ReducerInterface_ExpressionValue_test.res @@ -2,13 +2,13 @@ open Jest open Expect describe("ExpressionValue", () => { - test("argsToString", () => expect( - [IEvNumber(1.), IEvString("a")]->Reducer_Value.argsToString)->toBe("1,'a'") + test("argsToString", () => + expect([IEvNumber(1.), IEvString("a")]->Reducer_Value.argsToString)->toBe("1,'a'") ) test("toStringFunctionCall", () => - expect( - ("fn", [IEvNumber(1.), IEvString("a")])->Reducer_Value.toStringFunctionCall)->toBe("fn(1,'a')" + expect(("fn", [IEvNumber(1.), IEvString("a")])->Reducer_Value.toStringFunctionCall)->toBe( + "fn(1,'a')", ) ) }) diff --git a/packages/squiggle-lang/__tests__/ReducerProject/ReducerProject_tutorial_1_test.res b/packages/squiggle-lang/__tests__/ReducerProject/ReducerProject_tutorial_1_test.res index fec3ee66..21907acc 100644 --- a/packages/squiggle-lang/__tests__/ReducerProject/ReducerProject_tutorial_1_test.res +++ b/packages/squiggle-lang/__tests__/ReducerProject/ReducerProject_tutorial_1_test.res @@ -48,10 +48,8 @@ Case "Running a single source". let bindings = project->Project.getBindings("main") /* Let's display the result and bindings */ - ( - result->Reducer_Value.toStringResult, - bindings->Reducer_Value.toStringRecord, - )->expect == ("Ok(3)", "{}") + (result->Reducer_Value.toStringResult, bindings->Reducer_Value.toStringRecord)->expect == + ("Ok(3)", "{}") /* You've got 3 with empty bindings. */ }) @@ -86,10 +84,8 @@ Case "Running a single source". /* If you are running single source without includes and you don't need a custom environment, you can use the shortcut. */ /* Examples above was to prepare you for the multi source tutorial. */ let (result, bindings) = Project.evaluate("1+2") - ( - result->Reducer_Value.toStringResult, - bindings->Reducer_Value.toStringRecord, - )->expect == ("Ok(3)", "{}") + (result->Reducer_Value.toStringResult, bindings->Reducer_Value.toStringRecord)->expect == + ("Ok(3)", "{}") }) }) }) diff --git a/packages/squiggle-lang/__tests__/ReducerProject/ReducerProject_tutorial_2_multisource_test.res b/packages/squiggle-lang/__tests__/ReducerProject/ReducerProject_tutorial_2_multisource_test.res index b2c3738a..a31b9811 100644 --- a/packages/squiggle-lang/__tests__/ReducerProject/ReducerProject_tutorial_2_multisource_test.res +++ b/packages/squiggle-lang/__tests__/ReducerProject/ReducerProject_tutorial_2_multisource_test.res @@ -30,10 +30,8 @@ describe("ReducerProject Tutorial", () => { let result3 = project->Project.getResult("source3") let bindings3 = project->Project.getBindings("source3") - ( - result3->Reducer_Value.toStringResult, - bindings3->Reducer_Value.toStringRecord, - )->expect == ("Ok(())", "{z: 3}") + (result3->Reducer_Value.toStringResult, bindings3->Reducer_Value.toStringRecord)->expect == + ("Ok(())", "{z: 3}") }) test("Depending", () => { @@ -56,10 +54,8 @@ describe("ReducerProject Tutorial", () => { let result3 = project->Project.getResult("source3") let bindings3 = project->Project.getBindings("source3") - ( - result3->Reducer_Value.toStringResult, - bindings3->Reducer_Value.toStringRecord, - )->expect == ("Ok(())", "{z: 3}") + (result3->Reducer_Value.toStringResult, bindings3->Reducer_Value.toStringRecord)->expect == + ("Ok(())", "{z: 3}") }) test("Intro to including", () => { @@ -91,10 +87,8 @@ describe("ReducerProject Tutorial", () => { let result3 = project->Project.getResult("source3") let bindings3 = project->Project.getBindings("source3") - ( - result3->Reducer_Value.toStringResult, - bindings3->Reducer_Value.toStringRecord, - )->expect == ("Ok(())", "{z: 3}") + (result3->Reducer_Value.toStringResult, bindings3->Reducer_Value.toStringRecord)->expect == + ("Ok(())", "{z: 3}") /* Doing it like this is too verbose for a storybook But I hope you have seen the relation of setContinues and parseIncludes */ diff --git a/packages/squiggle-lang/__tests__/ReducerProject/ReducerProject_tutorial_3_includes_test.res b/packages/squiggle-lang/__tests__/ReducerProject/ReducerProject_tutorial_3_includes_test.res index e5af0e3f..2c63dfff 100644 --- a/packages/squiggle-lang/__tests__/ReducerProject/ReducerProject_tutorial_3_includes_test.res +++ b/packages/squiggle-lang/__tests__/ReducerProject/ReducerProject_tutorial_3_includes_test.res @@ -144,10 +144,8 @@ Here we will finally proceed to a real life scenario. */ let bindings = project->Project.getBindings("main") /* And see the result and bindings.. */ test("recursive includes", () => { - ( - result->Reducer_Value.toStringResult, - bindings->Reducer_Value.toStringRecord, - )->expect == ("Ok(6)", "{a: 6,b: 2}") + (result->Reducer_Value.toStringResult, bindings->Reducer_Value.toStringRecord)->expect == + ("Ok(6)", "{a: 6,b: 2}") /* Everything as expected */ }) }) diff --git a/packages/squiggle-lang/__tests__/SquiggleLibrary/SquiggleLibrary_FunctionRegistryLibrary_test.res b/packages/squiggle-lang/__tests__/SquiggleLibrary/SquiggleLibrary_FunctionRegistryLibrary_test.res index da4788e5..34a09172 100644 --- a/packages/squiggle-lang/__tests__/SquiggleLibrary/SquiggleLibrary_FunctionRegistryLibrary_test.res +++ b/packages/squiggle-lang/__tests__/SquiggleLibrary/SquiggleLibrary_FunctionRegistryLibrary_test.res @@ -3,10 +3,7 @@ open Expect open Reducer_TestHelpers let expectEvalToBeOk = (code: string) => - Reducer_Expression.BackCompatible.evaluateString(code) - ->E.R.isOk - ->expect - ->toBe(true) + Reducer_Expression.BackCompatible.evaluateString(code)->E.R.isOk->expect->toBe(true) let registry = FunctionRegistry_Library.registry let examples = E.A.to_list(FunctionRegistry_Core.Registry.allExamples(registry)) diff --git a/packages/squiggle-lang/src/rescript/FR/FR_Builtin.res b/packages/squiggle-lang/src/rescript/FR/FR_Builtin.res index e0bc776a..aee18e8b 100644 --- a/packages/squiggle-lang/src/rescript/FR/FR_Builtin.res +++ b/packages/squiggle-lang/src/rescript/FR/FR_Builtin.res @@ -26,93 +26,31 @@ let makeFn = ( ) => makeFnMany(name, [{inputs: inputs, fn: fn}]) let library = [ - Make.ff2f( - ~name="add", // infix + (see Reducer/Reducer_Peggy/helpers.ts) - ~fn=(x, y) => x +. y, - () - ), - Make.ff2f( - ~name="subtract", // infix - - ~fn=(x, y) => x -. y, - () - ), - Make.ff2f( - ~name="multiply", // infix * - ~fn=(x, y) => x *. y, - () - ), - Make.ff2f( - ~name="divide", // infix / - ~fn=(x, y) => x /. y, - () - ), - Make.ff2f( - ~name="pow", // infix ^ - ~fn=(x, y) => Js.Math.pow_float(~base=x, ~exp=y), - () - ), - Make.ff2b( - ~name="equal", // infix == on numbers - ~fn=(x, y) => x == y, - () - ), - Make.bb2b( - ~name="equal", // infix == on booleans - ~fn=(x, y) => x == y, - () - ), - Make.ff2b( - ~name="unequal", // infix != on numbers - ~fn=(x, y) => x != y, - () - ), - Make.ff2b( - ~name="unequal", // infix != on booleans - ~fn=(x, y) => x != y, - () - ), - Make.ff2b( - ~name="smaller", // infix < - ~fn=(x, y) => x < y, - () - ), - Make.ff2b( - ~name="smallerEq", // infix <= - ~fn=(x, y) => x <= y, - () - ), - Make.ff2b( - ~name="larger", // infix > - ~fn=(x, y) => x > y, - () - ), - Make.ff2b( - ~name="largerEq", // infix >= - ~fn=(x, y) => x >= y, - () - ), - Make.bb2b( - ~name="or", // infix || - ~fn=(x, y) => x || y, - () - ), - Make.bb2b( - ~name="and", // infix && - ~fn=(x, y) => x && y, - () - ), - Make.f2f( - ~name="unaryMinus", // unary prefix - - ~fn=x => -.x, - () - ), - makeFn("not", [FRTypeNumber], inputs => { // unary prefix ! + Make.ff2f(~name="add", ~fn=(x, y) => x +. y, ()), // infix + (see Reducer/Reducer_Peggy/helpers.ts) + Make.ff2f(~name="subtract", ~fn=(x, y) => x -. y, ()), // infix - + Make.ff2f(~name="multiply", ~fn=(x, y) => x *. y, ()), // infix * + Make.ff2f(~name="divide", ~fn=(x, y) => x /. y, ()), // infix / + Make.ff2f(~name="pow", ~fn=(x, y) => Js.Math.pow_float(~base=x, ~exp=y), ()), // infix ^ + Make.ff2b(~name="equal", ~fn=(x, y) => x == y, ()), // infix == on numbers + Make.bb2b(~name="equal", ~fn=(x, y) => x == y, ()), // infix == on booleans + Make.ff2b(~name="unequal", ~fn=(x, y) => x != y, ()), // infix != on numbers + Make.ff2b(~name="unequal", ~fn=(x, y) => x != y, ()), // infix != on booleans + Make.ff2b(~name="smaller", ~fn=(x, y) => x < y, ()), // infix < + Make.ff2b(~name="smallerEq", ~fn=(x, y) => x <= y, ()), // infix <= + Make.ff2b(~name="larger", ~fn=(x, y) => x > y, ()), // infix > + Make.ff2b(~name="largerEq", ~fn=(x, y) => x >= y, ()), // infix >= + Make.bb2b(~name="or", ~fn=(x, y) => x || y, ()), // infix || + Make.bb2b(~name="and", ~fn=(x, y) => x && y, ()), // infix && + Make.f2f(~name="unaryMinus", ~fn=x => -.x, ()), // unary prefix - + makeFn("not", [FRTypeNumber], inputs => { + // unary prefix ! switch inputs { | [IEvNumber(x)] => IEvBool(x != 0.)->Ok | _ => Error(impossibleError) } }), - makeFn("not", [FRTypeBool], inputs => { // unary prefix ! + makeFn("not", [FRTypeBool], inputs => { + // unary prefix ! switch inputs { | [IEvBool(x)] => IEvBool(!x)->Ok | _ => Error(impossibleError) @@ -157,9 +95,7 @@ let library = [ }), makeFn("javascriptraise", [FRTypeAny], inputs => { switch inputs { - | [msg] => { - Js.Exn.raiseError(msg->Reducer_Value.toString) - } + | [msg] => Js.Exn.raiseError(msg->Reducer_Value.toString) | _ => Error(impossibleError) } }), diff --git a/packages/squiggle-lang/src/rescript/FR/FR_Dict.res b/packages/squiggle-lang/src/rescript/FR/FR_Dict.res index c8a82b9c..2f36871c 100644 --- a/packages/squiggle-lang/src/rescript/FR/FR_Dict.res +++ b/packages/squiggle-lang/src/rescript/FR/FR_Dict.res @@ -17,10 +17,7 @@ module Internals = { ->E.A2.fmap(((key, value)) => Wrappers.evArray([IEvString(key), value])) ->Wrappers.evArray - let fromList = (items: array): result< - Reducer_T.value, - errorValue, - > => + let fromList = (items: array): result => items ->E.A2.fmap(item => { switch (item: Reducer_T.value) { diff --git a/packages/squiggle-lang/src/rescript/FR/FR_GenericDist.res b/packages/squiggle-lang/src/rescript/FR/FR_GenericDist.res index 93f720b4..443e101b 100644 --- a/packages/squiggle-lang/src/rescript/FR/FR_GenericDist.res +++ b/packages/squiggle-lang/src/rescript/FR/FR_GenericDist.res @@ -74,15 +74,10 @@ module Old = { | _ => Error("Not a number") } - let parseNumberArray = (ags: array): Belt.Result.t< - array, - string, - > => E.A.fmap(parseNumber, ags) |> E.A.R.firstErrorOrOpen + let parseNumberArray = (ags: array): Belt.Result.t, string> => + E.A.fmap(parseNumber, ags) |> E.A.R.firstErrorOrOpen - let parseDist = (args: Reducer_T.value): Belt.Result.t< - DistributionTypes.genericDist, - string, - > => + let parseDist = (args: Reducer_T.value): Belt.Result.t => switch args { | IEvDistribution(x) => Ok(x) | IEvNumber(x) => Ok(GenericDist.fromFloat(x)) @@ -173,10 +168,9 @@ module Old = { } } - let dispatchToGenericOutput = ( - call: Reducer_Value.functionCall, - env: GenericDist.env, - ): option => { + let dispatchToGenericOutput = (call: Reducer_Value.functionCall, env: GenericDist.env): option< + DistributionOperation.outputType, + > => { let (fnName, args) = call switch (fnName, args) { | ("triangular" as fnName, [IEvNumber(f1), IEvNumber(f2), IEvNumber(f3)]) => diff --git a/packages/squiggle-lang/src/rescript/FR/FR_List.res b/packages/squiggle-lang/src/rescript/FR/FR_List.res index 9bc68847..081d453a 100644 --- a/packages/squiggle-lang/src/rescript/FR/FR_List.res +++ b/packages/squiggle-lang/src/rescript/FR/FR_List.res @@ -5,10 +5,9 @@ let nameSpace = "List" let requiresNamespace = true module Internals = { - let makeFromNumber = ( - n: float, - value: Reducer_T.value, - ): Reducer_T.value => IEvArray(Belt.Array.make(E.Float.toInt(n), value)) + let makeFromNumber = (n: float, value: Reducer_T.value): Reducer_T.value => IEvArray( + Belt.Array.make(E.Float.toInt(n), value), + ) let upTo = (low: float, high: float): Reducer_T.value => IEvArray( E.A.Floats.range(low, high, (high -. low +. 1.0)->E.Float.toInt)->E.A2.fmap(Wrappers.evNumber), diff --git a/packages/squiggle-lang/src/rescript/FR/FR_Math.res b/packages/squiggle-lang/src/rescript/FR/FR_Math.res index 98ed37b2..5d98485b 100644 --- a/packages/squiggle-lang/src/rescript/FR/FR_Math.res +++ b/packages/squiggle-lang/src/rescript/FR/FR_Math.res @@ -9,50 +9,13 @@ let library = [ ~name="sqrt", ~nameSpace="Math", ~requiresNamespace=true, - ~fn=(x) => Js.Math.pow_float(~base=x, ~exp=0.5), - (), - ), - - Make.f2f( - ~name="sin", - ~nameSpace="Math", - ~requiresNamespace=true, - ~fn=Js.Math.sin, - (), - ), - Make.f2f( - ~name="cos", - ~nameSpace="Math", - ~requiresNamespace=true, - ~fn=Js.Math.cos, - (), - ), - Make.f2f( - ~name="tan", - ~nameSpace="Math", - ~requiresNamespace=true, - ~fn=Js.Math.tan, - (), - ), - Make.f2f( - ~name="asin", - ~nameSpace="Math", - ~requiresNamespace=true, - ~fn=Js.Math.asin, - (), - ), - Make.f2f( - ~name="acos", - ~nameSpace="Math", - ~requiresNamespace=true, - ~fn=Js.Math.acos, - (), - ), - Make.f2f( - ~name="atan", - ~nameSpace="Math", - ~requiresNamespace=true, - ~fn=Js.Math.atan, + ~fn=x => Js.Math.pow_float(~base=x, ~exp=0.5), (), ), + Make.f2f(~name="sin", ~nameSpace="Math", ~requiresNamespace=true, ~fn=Js.Math.sin, ()), + Make.f2f(~name="cos", ~nameSpace="Math", ~requiresNamespace=true, ~fn=Js.Math.cos, ()), + Make.f2f(~name="tan", ~nameSpace="Math", ~requiresNamespace=true, ~fn=Js.Math.tan, ()), + Make.f2f(~name="asin", ~nameSpace="Math", ~requiresNamespace=true, ~fn=Js.Math.asin, ()), + Make.f2f(~name="acos", ~nameSpace="Math", ~requiresNamespace=true, ~fn=Js.Math.acos, ()), + Make.f2f(~name="atan", ~nameSpace="Math", ~requiresNamespace=true, ~fn=Js.Math.atan, ()), ] diff --git a/packages/squiggle-lang/src/rescript/FR/FR_Sampleset.res b/packages/squiggle-lang/src/rescript/FR/FR_Sampleset.res index 228e8805..49f069ef 100644 --- a/packages/squiggle-lang/src/rescript/FR/FR_Sampleset.res +++ b/packages/squiggle-lang/src/rescript/FR/FR_Sampleset.res @@ -48,9 +48,7 @@ module Internal = { SampleSetDist.map3(~fn, ~t1, ~t2, ~t3)->toType } - let parseSampleSetArray = (arr: array): option< - array, - > => { + let parseSampleSetArray = (arr: array): option> => { let parseSampleSet = (value: Reducer_T.value): option => switch value { | IEvDistribution(SampleSet(dist)) => Some(dist) diff --git a/packages/squiggle-lang/src/rescript/ForTS/ForTS_SquiggleValue/ForTS_SquiggleValue.res b/packages/squiggle-lang/src/rescript/ForTS/ForTS_SquiggleValue/ForTS_SquiggleValue.res index 0b6b9d93..4fac710f 100644 --- a/packages/squiggle-lang/src/rescript/ForTS/ForTS_SquiggleValue/ForTS_SquiggleValue.res +++ b/packages/squiggle-lang/src/rescript/ForTS/ForTS_SquiggleValue/ForTS_SquiggleValue.res @@ -73,8 +73,7 @@ let getTag = (variant: squiggleValue): squiggleValueTag => } @genType -let toString = (variant: squiggleValue) => - Reducer_Value.toString(variant) +let toString = (variant: squiggleValue) => Reducer_Value.toString(variant) // This is a useful method for unit tests. // Convert the result along with the error message to a string. diff --git a/packages/squiggle-lang/src/rescript/ForTS/ForTS_SquiggleValue/ForTS_SquiggleValue_Array.res b/packages/squiggle-lang/src/rescript/ForTS/ForTS_SquiggleValue/ForTS_SquiggleValue_Array.res index 823fde5c..51854580 100644 --- a/packages/squiggle-lang/src/rescript/ForTS/ForTS_SquiggleValue/ForTS_SquiggleValue_Array.res +++ b/packages/squiggle-lang/src/rescript/ForTS/ForTS_SquiggleValue/ForTS_SquiggleValue_Array.res @@ -2,9 +2,7 @@ type squiggleValue = ForTS_SquiggleValue.squiggleValue @genType type squiggleValue_Array = ForTS_SquiggleValue.squiggleValue_Array //re-export recursive type @genType -let getValues = (v: squiggleValue_Array): array => - Reducer_Value.arrayToValueArray(v) +let getValues = (v: squiggleValue_Array): array => Reducer_Value.arrayToValueArray(v) @genType -let toString = (v: squiggleValue_Array): string => - Reducer_Value.toStringArray(v) +let toString = (v: squiggleValue_Array): string => Reducer_Value.toStringArray(v) diff --git a/packages/squiggle-lang/src/rescript/ForTS/ForTS_SquiggleValue/ForTS_SquiggleValue_Declaration.res b/packages/squiggle-lang/src/rescript/ForTS/ForTS_SquiggleValue/ForTS_SquiggleValue_Declaration.res index 5c8eae49..996668de 100644 --- a/packages/squiggle-lang/src/rescript/ForTS/ForTS_SquiggleValue/ForTS_SquiggleValue_Declaration.res +++ b/packages/squiggle-lang/src/rescript/ForTS/ForTS_SquiggleValue/ForTS_SquiggleValue_Declaration.res @@ -1,5 +1,4 @@ @genType type squiggleValue_Declaration = Reducer_T.lambdaDeclaration //re-export @genType -let toString = (v: squiggleValue_Declaration): string => - Reducer_Value.toStringDeclaration(v) +let toString = (v: squiggleValue_Declaration): string => Reducer_Value.toStringDeclaration(v) diff --git a/packages/squiggle-lang/src/rescript/ForTS/ForTS_SquiggleValue/ForTS_SquiggleValue_Distribution.res b/packages/squiggle-lang/src/rescript/ForTS/ForTS_SquiggleValue/ForTS_SquiggleValue_Distribution.res index b1d6b440..ff3e45d8 100644 --- a/packages/squiggle-lang/src/rescript/ForTS/ForTS_SquiggleValue/ForTS_SquiggleValue_Distribution.res +++ b/packages/squiggle-lang/src/rescript/ForTS/ForTS_SquiggleValue/ForTS_SquiggleValue_Distribution.res @@ -1,5 +1,4 @@ @genType type squiggleValue_Distribution = ForTS_Distribution.distribution @genType -let toString = (v: squiggleValue_Distribution): string => - Reducer_Value.toStringDistribution(v) +let toString = (v: squiggleValue_Distribution): string => Reducer_Value.toStringDistribution(v) diff --git a/packages/squiggle-lang/src/rescript/ForTS/ForTS_SquiggleValue/ForTS_SquiggleValue_Lambda.res b/packages/squiggle-lang/src/rescript/ForTS/ForTS_SquiggleValue/ForTS_SquiggleValue_Lambda.res index f6ec66d3..a9793e87 100644 --- a/packages/squiggle-lang/src/rescript/ForTS/ForTS_SquiggleValue/ForTS_SquiggleValue_Lambda.res +++ b/packages/squiggle-lang/src/rescript/ForTS/ForTS_SquiggleValue/ForTS_SquiggleValue_Lambda.res @@ -1,8 +1,7 @@ @genType type squiggleValue_Lambda = Reducer_T.lambdaValue //re-export @genType -let toString = (v: squiggleValue_Lambda): string => - Reducer_Value.toStringFunction(v) +let toString = (v: squiggleValue_Lambda): string => Reducer_Value.toStringFunction(v) @genType let parameters = (v: squiggleValue_Lambda): array => { diff --git a/packages/squiggle-lang/src/rescript/ForTS/ForTS_SquiggleValue/ForTS_SquiggleValue_Type.res b/packages/squiggle-lang/src/rescript/ForTS/ForTS_SquiggleValue/ForTS_SquiggleValue_Type.res index 0c002040..14845512 100644 --- a/packages/squiggle-lang/src/rescript/ForTS/ForTS_SquiggleValue/ForTS_SquiggleValue_Type.res +++ b/packages/squiggle-lang/src/rescript/ForTS/ForTS_SquiggleValue/ForTS_SquiggleValue_Type.res @@ -6,5 +6,4 @@ let getKeyValuePairs = (value: squiggleValue_Type): array<(string, squiggleValue Reducer_Value.recordToKeyValuePairs(value) @genType -let toString = (value: squiggleValue_Type): string => - Reducer_Value.toStringType(value) +let toString = (value: squiggleValue_Type): string => Reducer_Value.toStringType(value) diff --git a/packages/squiggle-lang/src/rescript/FunctionRegistry/FunctionRegistry_Core.res b/packages/squiggle-lang/src/rescript/FunctionRegistry/FunctionRegistry_Core.res index 901915e3..4ae50fa3 100644 --- a/packages/squiggle-lang/src/rescript/FunctionRegistry/FunctionRegistry_Core.res +++ b/packages/squiggle-lang/src/rescript/FunctionRegistry/FunctionRegistry_Core.res @@ -179,10 +179,9 @@ module FRType = { | FRValueAny(f) => matchReverse(f) } - let matchWithExpressionValueArray = ( - inputs: array, - args: array, - ): option> => { + let matchWithExpressionValueArray = (inputs: array, args: array): option< + array, + > => { let isSameLength = E.A.length(inputs) == E.A.length(args) if !isSameLength { None diff --git a/packages/squiggle-lang/src/rescript/FunctionRegistry/FunctionRegistry_Helpers.res b/packages/squiggle-lang/src/rescript/FunctionRegistry/FunctionRegistry_Helpers.res index 82c99d6c..1b94c6bf 100644 --- a/packages/squiggle-lang/src/rescript/FunctionRegistry/FunctionRegistry_Helpers.res +++ b/packages/squiggle-lang/src/rescript/FunctionRegistry/FunctionRegistry_Helpers.res @@ -278,10 +278,10 @@ module Make = { Q: What about polymorphic functions with multiple definitions? Why ~fn is not an array? A: We often define the same function in multiple `FR_*` files, so that doesn't work well anyway. In 90%+ cases there's a single definition. And having to write `name` twice is annoying. - */ + */ let f2f = ( ~name: string, - ~fn: (float) => float, + ~fn: float => float, ~nameSpace="", ~requiresNamespace=false, ~examples=?, @@ -290,22 +290,22 @@ module Make = { Function.make( ~name, ~nameSpace, - ~requiresNamespace=requiresNamespace, + ~requiresNamespace, ~examples=examples->E.O.default([], _), ~output=EvtNumber, ~definitions=[ FnDefinition.make( ~name, ~inputs=[FRTypeNumber], - ~run=((inputs, _, _, _) => + ~run=(inputs, _, _, _) => switch inputs { | [IEvNumber(x)] => fn(x)->IEvNumber->Ok | _ => Error(impossibleError) - }), - () - ) + }, + (), + ), ], - () + (), ) } @@ -320,22 +320,22 @@ module Make = { Function.make( ~name, ~nameSpace, - ~requiresNamespace=requiresNamespace, + ~requiresNamespace, ~examples=examples->E.O.default([], _), ~output=EvtNumber, ~definitions=[ FnDefinition.make( ~name, ~inputs=[FRTypeNumber, FRTypeNumber], - ~run=((inputs, _, _, _) => + ~run=(inputs, _, _, _) => switch inputs { | [IEvNumber(x), IEvNumber(y)] => fn(x, y)->IEvNumber->Ok | _ => Error(impossibleError) - }), - () - ) + }, + (), + ), ], - () + (), ) } @@ -350,22 +350,22 @@ module Make = { Function.make( ~name, ~nameSpace, - ~requiresNamespace=requiresNamespace, + ~requiresNamespace, ~examples=examples->E.O.default([], _), ~output=EvtBool, ~definitions=[ FnDefinition.make( ~name, ~inputs=[FRTypeNumber, FRTypeNumber], - ~run=((inputs, _, _, _) => + ~run=(inputs, _, _, _) => switch inputs { | [IEvNumber(x), IEvNumber(y)] => fn(x, y)->IEvBool->Ok | _ => Error(impossibleError) - }), - () - ) + }, + (), + ), ], - () + (), ) } @@ -380,22 +380,22 @@ module Make = { Function.make( ~name, ~nameSpace, - ~requiresNamespace=requiresNamespace, + ~requiresNamespace, ~examples=examples->E.O.default([], _), ~output=EvtBool, ~definitions=[ FnDefinition.make( ~name, ~inputs=[FRTypeBool, FRTypeBool], - ~run=((inputs, _, _, _) => + ~run=(inputs, _, _, _) => switch inputs { | [IEvBool(x), IEvBool(y)] => fn(x, y)->IEvBool->Ok | _ => Error(impossibleError) - }), - () - ) + }, + (), + ), ], - () + (), ) } } diff --git a/packages/squiggle-lang/src/rescript/Reducer/Reducer_Context.res b/packages/squiggle-lang/src/rescript/Reducer/Reducer_Context.res index ff835e96..c45994bb 100644 --- a/packages/squiggle-lang/src/rescript/Reducer/Reducer_Context.res +++ b/packages/squiggle-lang/src/rescript/Reducer/Reducer_Context.res @@ -9,5 +9,4 @@ let createContext = (stdLib: Reducer_Namespace.t, environment: Reducer_T.environ } } -let createDefaultContext = (): t => - createContext(SquiggleLibrary_StdLib.stdLib, defaultEnvironment) +let createDefaultContext = (): t => createContext(SquiggleLibrary_StdLib.stdLib, defaultEnvironment) diff --git a/packages/squiggle-lang/src/rescript/Reducer/Reducer_Expression/Reducer_Expression.res b/packages/squiggle-lang/src/rescript/Reducer/Reducer_Expression/Reducer_Expression.res index e608036a..c28e121e 100644 --- a/packages/squiggle-lang/src/rescript/Reducer/Reducer_Expression/Reducer_Expression.res +++ b/packages/squiggle-lang/src/rescript/Reducer/Reducer_Expression/Reducer_Expression.res @@ -103,9 +103,7 @@ let rec evaluate: T.reducerFn = (expression, context): (T.value, T.context) => { context, ) | _ => - RENotAFunction(lambda->Reducer_Value.toString) - ->Reducer_ErrorValue.ErrorException - ->raise + RENotAFunction(lambda->Reducer_Value.toString)->Reducer_ErrorValue.ErrorException->raise } } } diff --git a/packages/squiggle-lang/src/rescript/Reducer/Reducer_Namespace.res b/packages/squiggle-lang/src/rescript/Reducer/Reducer_Namespace.res index 14afae95..e2757f60 100644 --- a/packages/squiggle-lang/src/rescript/Reducer/Reducer_Namespace.res +++ b/packages/squiggle-lang/src/rescript/Reducer/Reducer_Namespace.res @@ -24,9 +24,7 @@ let mergeMany = (namespaces: array): t => let toString = (namespace: t) => namespace ->Belt.Map.String.toArray - ->Belt.Array.map(((eachKey, eachValue)) => - `${eachKey}: ${eachValue->Reducer_Value.toString}` - ) + ->Belt.Array.map(((eachKey, eachValue)) => `${eachKey}: ${eachValue->Reducer_Value.toString}`) ->Js.Array2.toString let fromArray = (a): t => Belt.Map.String.fromArray(a) diff --git a/packages/squiggle-lang/src/rescript/Reducer/Reducer_Type/Reducer_Type_Contracts.res b/packages/squiggle-lang/src/rescript/Reducer/Reducer_Type/Reducer_Type_Contracts.res index 8433ef22..59230a9e 100644 --- a/packages/squiggle-lang/src/rescript/Reducer/Reducer_Type/Reducer_Type_Contracts.res +++ b/packages/squiggle-lang/src/rescript/Reducer/Reducer_Type/Reducer_Type_Contracts.res @@ -16,10 +16,7 @@ let isMax = (modifierArg: Reducer_Value.t, aValue: Reducer_Value.t): bool => { } } -let isMemberOf = ( - modifierArg: Reducer_Value.t, - aValue: Reducer_Value.t, -): bool => { +let isMemberOf = (modifierArg: Reducer_Value.t, aValue: Reducer_Value.t): bool => { let pair = (modifierArg, aValue) switch pair { | (ievA, IEvArray(b)) => Js.Array2.includes(b, ievA) @@ -27,11 +24,7 @@ let isMemberOf = ( } } -let checkModifier = ( - key: string, - modifierArg: Reducer_Value.t, - aValue: Reducer_Value.t, -): bool => +let checkModifier = (key: string, modifierArg: Reducer_Value.t, aValue: Reducer_Value.t): bool => switch key { | "min" => isMin(modifierArg, aValue) | "max" => isMax(modifierArg, aValue) diff --git a/packages/squiggle-lang/src/rescript/SquiggleLibrary/SquiggleLibrary_StdLib.res b/packages/squiggle-lang/src/rescript/SquiggleLibrary/SquiggleLibrary_StdLib.res index 454983f7..3be93851 100644 --- a/packages/squiggle-lang/src/rescript/SquiggleLibrary/SquiggleLibrary_StdLib.res +++ b/packages/squiggle-lang/src/rescript/SquiggleLibrary/SquiggleLibrary_StdLib.res @@ -13,16 +13,13 @@ let stdLib: Reducer_T.namespace = { Reducer_Expression_Lambda.makeFFILambda((inputs, _, _) => { switch inputs { | [IEvArray(aValueArray), IEvNumber(fIndex)] => { - let index = Belt.Int.fromFloat(fIndex) // TODO - fail on non-integer indices? + let index = Belt.Int.fromFloat(fIndex) // TODO - fail on non-integer indices? - switch Belt.Array.get(aValueArray, index) { - | Some(value) => value - | None => - REArrayIndexNotFound("Array index not found", index) - ->ErrorException - ->raise + switch Belt.Array.get(aValueArray, index) { + | Some(value) => value + | None => REArrayIndexNotFound("Array index not found", index)->ErrorException->raise + } } - } | [IEvRecord(dict), IEvString(sIndex)] => switch Belt.Map.String.get(dict, sIndex) { | Some(value) => value