From b24cfbc3284076de697c3c608d4cdff787525a3e Mon Sep 17 00:00:00 2001 From: Vyacheslav Matyukhin Date: Mon, 19 Sep 2022 23:10:09 +0400 Subject: [PATCH] cleanups; ReducerInterface is no more --- .../__tests__/Reducer/Reducer_Helpers.res | 9 --- .../Reducer_Peggy_TestHelpers.res | 4 +- ...cer_Peggy_ToExpression_outerBlock_test.res | 3 - .../Reducer_Peggy_ToExpression_test.res | 5 +- .../__tests__/Reducer/Reducer_TestHelpers.res | 6 +- .../Reducer_Type_Compile_test.res | 3 +- ...educer_Type_TypeChecker_arguments_test.res | 2 - .../Reducer_Type_TypeChecker_test.res | 1 - .../Reducer_Type_switch_replacement_test.res | 12 ++-- .../ReducerInterface_ExpressionValue_test.res | 9 ++- .../ReducerProject_includes_test.res | 2 - .../ReducerProject/ReducerProject_test.res | 5 +- .../ReducerProject_tutorial_1_test.res | 17 +++--- ...cerProject_tutorial_2_multisource_test.res | 13 ++--- ...educerProject_tutorial_3_includes_test.res | 5 +- ...oject_tutorial_4_injecting_user_values.res | 4 +- ...erProject_tutorial_5_calling_functions.res | 3 +- ...leLibrary_FunctionRegistryLibrary_test.res | 3 +- .../src/rescript/FR/FR_Builtin.res | 10 ++-- .../squiggle-lang/src/rescript/FR/FR_Date.res | 2 +- .../squiggle-lang/src/rescript/FR/FR_Dict.res | 16 ++--- .../squiggle-lang/src/rescript/FR/FR_Dist.res | 2 +- .../squiggle-lang/src/rescript/FR/FR_Fn.res | 2 +- .../src/rescript/FR/FR_GenericDist.res | 18 +++--- .../squiggle-lang/src/rescript/FR/FR_List.res | 16 ++--- .../src/rescript/FR/FR_Pointset.res | 8 +-- .../src/rescript/FR/FR_Sampleset.res | 24 ++++---- .../ForTS_Distribution/ForTS_Distribution.res | 2 +- .../ForTS_SquiggleValue.res | 4 +- .../ForTS_SquiggleValue_Array.res | 4 +- .../ForTS_SquiggleValue_Declaration.res | 2 +- .../ForTS_SquiggleValue_Distribution.res | 2 +- .../ForTS_SquiggleValue_Lambda.res | 2 +- .../ForTS_SquiggleValue_Record.res | 4 +- .../ForTS_SquiggleValue_Type.res | 4 +- .../FunctionRegistry_Core.res | 23 ++++---- .../src/rescript/Reducer/Reducer_Bindings.res | 1 - .../src/rescript/Reducer/Reducer_Context.res | 7 +-- .../Reducer_Dispatch_ChainPiece.res | 2 +- .../Reducer_Dispatch/Reducer_Dispatch_T.res | 5 +- .../Reducer_Expression/Reducer_Expression.res | 2 +- .../Reducer_Expression_Lambda.res | 4 +- .../Reducer_Expression_T.res | 4 +- .../Reducer/Reducer_Js/Reducer_Js.res | 1 - .../Reducer/Reducer_Js/Reducer_Js_Gate.res | 17 ------ .../rescript/Reducer/Reducer_Namespace.res | 2 +- .../Reducer_Type/Reducer_Type_Compile.res | 5 +- .../Reducer_Type/Reducer_Type_Contracts.res | 17 +++--- .../Reducer/Reducer_Type/Reducer_Type_T.res | 31 +++++----- .../Reducer_Type/Reducer_Type_TypeChecker.res | 25 ++++---- .../Reducer_Value.res} | 4 -- .../ReducerInterface/ReducerInterface.res | 2 - .../ReducerProject/ReducerProject.res | 9 ++- .../ReducerProject_ProjectAccessors_T.res | 31 ---------- .../SquiggleLibrary_StdLib.res} | 2 +- .../src/rescript/TypescriptInterface.res | 58 ------------------- 56 files changed, 160 insertions(+), 320 deletions(-) delete mode 100644 packages/squiggle-lang/__tests__/Reducer/Reducer_Helpers.res delete mode 100644 packages/squiggle-lang/src/rescript/Reducer/Reducer_Js/Reducer_Js.res delete mode 100644 packages/squiggle-lang/src/rescript/Reducer/Reducer_Js/Reducer_Js_Gate.res rename packages/squiggle-lang/src/rescript/{ReducerInterface/ReducerInterface_InternalExpressionValue.res => Reducer/Reducer_Value.res} (98%) delete mode 100644 packages/squiggle-lang/src/rescript/ReducerInterface/ReducerInterface.res delete mode 100644 packages/squiggle-lang/src/rescript/ReducerProject/ReducerProject_ProjectAccessors_T.res rename packages/squiggle-lang/src/rescript/{ReducerInterface/ReducerInterface_StdLib.res => SquiggleLibrary/SquiggleLibrary_StdLib.res} (97%) delete mode 100644 packages/squiggle-lang/src/rescript/TypescriptInterface.res diff --git a/packages/squiggle-lang/__tests__/Reducer/Reducer_Helpers.res b/packages/squiggle-lang/__tests__/Reducer/Reducer_Helpers.res deleted file mode 100644 index 4bbeff17..00000000 --- a/packages/squiggle-lang/__tests__/Reducer/Reducer_Helpers.res +++ /dev/null @@ -1,9 +0,0 @@ -// Reducer_Helpers -module ErrorValue = Reducer_ErrorValue -module InternalExpressionValue = ReducerInterface.InternalExpressionValue - -let removeDefaultsInternal = (iev: InternalExpressionValue.t) => { - iev // TODO - cleanup, noop -} - -let rRemoveDefaultsInternal = r => Belt.Result.map(r, removeDefaultsInternal) diff --git a/packages/squiggle-lang/__tests__/Reducer/Reducer_Peggy/Reducer_Peggy_TestHelpers.res b/packages/squiggle-lang/__tests__/Reducer/Reducer_Peggy/Reducer_Peggy_TestHelpers.res index 303f66ee..0dadae86 100644 --- a/packages/squiggle-lang/__tests__/Reducer/Reducer_Peggy/Reducer_Peggy_TestHelpers.res +++ b/packages/squiggle-lang/__tests__/Reducer/Reducer_Peggy/Reducer_Peggy_TestHelpers.res @@ -1,6 +1,5 @@ module Expression = Reducer_Expression module ExpressionT = Reducer_Expression_T -module ExpressionValue = ReducerInterface.InternalExpressionValue module Parse = Reducer_Peggy_Parse module Result = Belt.Result module ToExpression = Reducer_Peggy_ToExpression @@ -24,8 +23,7 @@ let expectToExpressionToBe = (expr, answer, ~v="_", ()) => { let a2 = rExpr ->Result.flatMap(expr => Expression.BackCompatible.evaluate(expr)) - ->Reducer_Helpers.rRemoveDefaultsInternal - ->ExpressionValue.toStringResultOkless + ->Reducer_Value.toStringResultOkless (a1, a2)->expect->toEqual((answer, v)) } } diff --git a/packages/squiggle-lang/__tests__/Reducer/Reducer_Peggy/Reducer_Peggy_ToExpression_outerBlock_test.res b/packages/squiggle-lang/__tests__/Reducer/Reducer_Peggy/Reducer_Peggy_ToExpression_outerBlock_test.res index 03ef24c8..80f93fdc 100644 --- a/packages/squiggle-lang/__tests__/Reducer/Reducer_Peggy/Reducer_Peggy_ToExpression_outerBlock_test.res +++ b/packages/squiggle-lang/__tests__/Reducer/Reducer_Peggy/Reducer_Peggy_ToExpression_outerBlock_test.res @@ -1,6 +1,3 @@ -module Bindings = Reducer_Bindings -module InternalExpressionValue = ReducerInterface_InternalExpressionValue - open Jest open Reducer_Peggy_TestHelpers diff --git a/packages/squiggle-lang/__tests__/Reducer/Reducer_Peggy/Reducer_Peggy_ToExpression_test.res b/packages/squiggle-lang/__tests__/Reducer/Reducer_Peggy/Reducer_Peggy_ToExpression_test.res index 3016e3c2..cab84681 100644 --- a/packages/squiggle-lang/__tests__/Reducer/Reducer_Peggy/Reducer_Peggy_ToExpression_test.res +++ b/packages/squiggle-lang/__tests__/Reducer/Reducer_Peggy/Reducer_Peggy_ToExpression_test.res @@ -1,5 +1,4 @@ module Bindings = Reducer_Bindings -module InternalExpressionValue = ReducerInterface_InternalExpressionValue open Jest open Reducer_Peggy_TestHelpers @@ -144,9 +143,9 @@ describe("Peggy to Expression", () => { describe("module", () => { // testToExpression("Math.pi", "{:Math.pi}", ~v="3.141592653589793", ()) // Only.test("stdlibrary", () => { - // ReducerInterface_StdLib.internalStdLib + // SquiggleLibrary_StdLib.stdLib // ->IEvBindings - // ->InternalExpressionValue.toString + // ->Reducer_Value.toString // ->expect // ->toBe("") // }) diff --git a/packages/squiggle-lang/__tests__/Reducer/Reducer_TestHelpers.res b/packages/squiggle-lang/__tests__/Reducer/Reducer_TestHelpers.res index e9057671..5d335556 100644 --- a/packages/squiggle-lang/__tests__/Reducer/Reducer_TestHelpers.res +++ b/packages/squiggle-lang/__tests__/Reducer/Reducer_TestHelpers.res @@ -1,7 +1,6 @@ module ErrorValue = Reducer_ErrorValue module Expression = Reducer_Expression module ExpressionT = Reducer_Expression_T -module InternalExpressionValue = ReducerInterface.InternalExpressionValue open Jest open Expect @@ -19,14 +18,13 @@ let expectParseToBe = (code: string, answer: string) => let expectEvalToBe = (code: string, answer: string) => Expression.BackCompatible.evaluateString(code) - ->Reducer_Helpers.rRemoveDefaultsInternal - ->InternalExpressionValue.toStringResult + ->Reducer_Value.toStringResult ->expect ->toBe(answer) let expectEvalError = (code: string) => Expression.BackCompatible.evaluateString(code) - ->InternalExpressionValue.toStringResult + ->Reducer_Value.toStringResult ->expect ->toMatch("Error\(") diff --git a/packages/squiggle-lang/__tests__/Reducer/Reducer_Type/Reducer_Type_Compile_test.res b/packages/squiggle-lang/__tests__/Reducer/Reducer_Type/Reducer_Type_Compile_test.res index 8abf5f7a..4c0812fd 100644 --- a/packages/squiggle-lang/__tests__/Reducer/Reducer_Type/Reducer_Type_Compile_test.res +++ b/packages/squiggle-lang/__tests__/Reducer/Reducer_Type/Reducer_Type_Compile_test.res @@ -1,5 +1,4 @@ // module Expression = Reducer_Expression -// module InternalExpressionValue = ReducerInterface_InternalExpressionValue // module Bindings = Reducer_Bindings // module T = Reducer_Type_T // module TypeCompile = Reducer_Type_Compile @@ -10,7 +9,7 @@ // let myIevEval = (aTypeSourceCode: string) => // TypeCompile.ievFromTypeExpression(aTypeSourceCode, Expression.reduceExpressionInProject) // let myIevEvalToString = (aTypeSourceCode: string) => -// myIevEval(aTypeSourceCode)->InternalExpressionValue.toStringResult +// myIevEval(aTypeSourceCode)->Reducer_Value.toStringResult // let myIevExpectEqual = (aTypeSourceCode, answer) => // expect(myIevEvalToString(aTypeSourceCode))->toEqual(answer) diff --git a/packages/squiggle-lang/__tests__/Reducer/Reducer_Type/Reducer_Type_TypeChecker_arguments_test.res b/packages/squiggle-lang/__tests__/Reducer/Reducer_Type/Reducer_Type_TypeChecker_arguments_test.res index 64f2554a..723ff00b 100644 --- a/packages/squiggle-lang/__tests__/Reducer/Reducer_Type/Reducer_Type_TypeChecker_arguments_test.res +++ b/packages/squiggle-lang/__tests__/Reducer/Reducer_Type/Reducer_Type_TypeChecker_arguments_test.res @@ -1,8 +1,6 @@ // module Bindings = Reducer_Bindings // module ErrorValue = Reducer_ErrorValue // module Expression = Reducer_Expression -// module ExpressionT = Reducer_Expression_T -// module InternalExpressionValue = ReducerInterface_InternalExpressionValue // module ProjectAccessorsT = ReducerProject_ProjectAccessors_T // module T = Reducer_Type_T // module TypeChecker = Reducer_Type_TypeChecker diff --git a/packages/squiggle-lang/__tests__/Reducer/Reducer_Type/Reducer_Type_TypeChecker_test.res b/packages/squiggle-lang/__tests__/Reducer/Reducer_Type/Reducer_Type_TypeChecker_test.res index c4272880..5f59c60a 100644 --- a/packages/squiggle-lang/__tests__/Reducer/Reducer_Type/Reducer_Type_TypeChecker_test.res +++ b/packages/squiggle-lang/__tests__/Reducer/Reducer_Type/Reducer_Type_TypeChecker_test.res @@ -1,7 +1,6 @@ // module Expression = Reducer_Expression // module ExpressionT = Reducer_Expression_T // module ErrorValue = Reducer_ErrorValue -// module InternalExpressionValue = ReducerInterface_InternalExpressionValue // module Bindings = Reducer_Bindings // module T = Reducer_Type_T // module TypeChecker = Reducer_Type_TypeChecker diff --git a/packages/squiggle-lang/__tests__/Reducer/Reducer_Type/Reducer_Type_switch_replacement_test.res b/packages/squiggle-lang/__tests__/Reducer/Reducer_Type/Reducer_Type_switch_replacement_test.res index 88f3d9a6..fcba831d 100644 --- a/packages/squiggle-lang/__tests__/Reducer/Reducer_Type/Reducer_Type_switch_replacement_test.res +++ b/packages/squiggle-lang/__tests__/Reducer/Reducer_Type/Reducer_Type_switch_replacement_test.res @@ -8,15 +8,13 @@ // module TypeChecker = Reducer_Type_TypeChecker // module TypeCompile = Reducer_Type_Compile -// open ReducerInterface_InternalExpressionValue - // type errorValue = Reducer_ErrorValue.errorValue // // Let's build a function to replace switch statements // // In dispatchChainPiece, we execute an return the result of execution if there is a type match. // // Otherwise we return None so that the call chain can continue. // // So we want to build a function like -// // dispatchChainPiece = (call: functionCall, accessors): option> +// // dispatchChainPiece = (call: functionCall, accessors): option> // // Use accessors.environment to get the environment finally. // // Now lets make the dispatchChainPiece itself. @@ -28,9 +26,9 @@ // module Implementation = { // let stringConcat = (a: string, b: string): string => Js.String2.concat(a, b) // let arrayConcat = ( -// a: Js.Array2.t, -// b: Js.Array2.t, -// ): Js.Array2.t => Js.Array2.concat(a, b) +// a: Js.Array2.t, +// b: Js.Array2.t, +// ): Js.Array2.t => Js.Array2.concat(a, b) // let plot = _r => "yey, plotted" // } @@ -104,7 +102,7 @@ // accessors: ProjectAccessorsT.t, // reducer: Reducer_T.reducerFn, // chain, -// ): result => { +// ): result => { // let dispatchChainPiece = makeMyDispatchChainPiece(reducer) // dispatchChainPiece(call, accessors)->E.O2.defaultFn(() => chain(call, accessors, reducer)) // } diff --git a/packages/squiggle-lang/__tests__/ReducerInterface/ReducerInterface_ExpressionValue_test.res b/packages/squiggle-lang/__tests__/ReducerInterface/ReducerInterface_ExpressionValue_test.res index 71fd9f61..31054a67 100644 --- a/packages/squiggle-lang/__tests__/ReducerInterface/ReducerInterface_ExpressionValue_test.res +++ b/packages/squiggle-lang/__tests__/ReducerInterface/ReducerInterface_ExpressionValue_test.res @@ -1,11 +1,14 @@ -open ReducerInterface.InternalExpressionValue open Jest open Expect describe("ExpressionValue", () => { - test("argsToString", () => expect([IEvNumber(1.), IEvString("a")]->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")])->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_includes_test.res b/packages/squiggle-lang/__tests__/ReducerProject/ReducerProject_includes_test.res index 3d1fcddc..07660044 100644 --- a/packages/squiggle-lang/__tests__/ReducerProject/ReducerProject_includes_test.res +++ b/packages/squiggle-lang/__tests__/ReducerProject/ReducerProject_includes_test.res @@ -1,7 +1,5 @@ @@warning("-44") -module InternalExpressionValue = ReducerInterface_InternalExpressionValue module Project = ForTS_ReducerProject -module Bindings = Reducer_Bindings open Jest open Expect diff --git a/packages/squiggle-lang/__tests__/ReducerProject/ReducerProject_test.res b/packages/squiggle-lang/__tests__/ReducerProject/ReducerProject_test.res index d85d636c..aee917a3 100644 --- a/packages/squiggle-lang/__tests__/ReducerProject/ReducerProject_test.res +++ b/packages/squiggle-lang/__tests__/ReducerProject/ReducerProject_test.res @@ -1,5 +1,4 @@ @@warning("-44") -module InternalExpressionValue = ReducerInterface_InternalExpressionValue module Project = ForTS_ReducerProject module Bindings = Reducer_Bindings @@ -9,12 +8,12 @@ open Expect.Operators let runFetchResult = (project, sourceId) => { Project.run(project, sourceId) - Project.getResult(project, sourceId)->InternalExpressionValue.toStringResult + Project.getResult(project, sourceId)->Reducer_Value.toStringResult } let runFetchFlatBindings = (project, sourceId) => { Project.run(project, sourceId) - Project.getBindings(project, sourceId)->InternalExpressionValue.toStringRecord + Project.getBindings(project, sourceId)->Reducer_Value.toStringRecord } test("test result true", () => { 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 13cab7aa..fec3ee66 100644 --- a/packages/squiggle-lang/__tests__/ReducerProject/ReducerProject_tutorial_1_test.res +++ b/packages/squiggle-lang/__tests__/ReducerProject/ReducerProject_tutorial_1_test.res @@ -1,5 +1,4 @@ @@warning("-44") -module InternalExpressionValue = ReducerInterface_InternalExpressionValue module Project = ForTS_ReducerProject module Bindings = Reducer_Bindings @@ -50,8 +49,8 @@ Case "Running a single source". /* Let's display the result and bindings */ ( - result->InternalExpressionValue.toStringResult, - bindings->InternalExpressionValue.toStringRecord, + result->Reducer_Value.toStringResult, + bindings->Reducer_Value.toStringRecord, )->expect == ("Ok(3)", "{}") /* You've got 3 with empty bindings. */ }) @@ -64,8 +63,8 @@ Case "Running a single source". let bindings = project->Project.getBindings("main") /* Now you have external bindings and external result. */ ( - result->InternalExpressionValue.toStringResult, - bindings->Reducer_T.IEvRecord->InternalExpressionValue.toString, + result->Reducer_Value.toStringResult, + bindings->Reducer_T.IEvRecord->Reducer_Value.toString, )->expect == ("Ok(3)", "{}") }) @@ -74,13 +73,13 @@ Case "Running a single source". let project = Project.createProject() /* Optional. Set your custom environment anytime before running */ - project->Project.setEnvironment(InternalExpressionValue.defaultEnvironment) + project->Project.setEnvironment(Reducer_Context.defaultEnvironment) project->Project.setSource("main", "1 + 2") project->Project.runAll let result = project->Project.getResult("main") let _bindings = project->Project.getBindings("main") - result->InternalExpressionValue.toStringResult->expect == "Ok(3)" + result->Reducer_Value.toStringResult->expect == "Ok(3)" }) test("shortcut", () => { @@ -88,8 +87,8 @@ Case "Running a single source". /* Examples above was to prepare you for the multi source tutorial. */ let (result, bindings) = Project.evaluate("1+2") ( - result->InternalExpressionValue.toStringResult, - bindings->InternalExpressionValue.toStringRecord, + 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 d50ec544..b2c3738a 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 @@ -1,5 +1,4 @@ @@warning("-44") -module InternalExpressionValue = ReducerInterface_InternalExpressionValue module Project = ForTS_ReducerProject module Bindings = Reducer_Bindings @@ -32,8 +31,8 @@ describe("ReducerProject Tutorial", () => { let bindings3 = project->Project.getBindings("source3") ( - result3->InternalExpressionValue.toStringResult, - bindings3->InternalExpressionValue.toStringRecord, + result3->Reducer_Value.toStringResult, + bindings3->Reducer_Value.toStringRecord, )->expect == ("Ok(())", "{z: 3}") }) @@ -58,8 +57,8 @@ describe("ReducerProject Tutorial", () => { let bindings3 = project->Project.getBindings("source3") ( - result3->InternalExpressionValue.toStringResult, - bindings3->InternalExpressionValue.toStringRecord, + result3->Reducer_Value.toStringResult, + bindings3->Reducer_Value.toStringRecord, )->expect == ("Ok(())", "{z: 3}") }) @@ -93,8 +92,8 @@ describe("ReducerProject Tutorial", () => { let bindings3 = project->Project.getBindings("source3") ( - result3->InternalExpressionValue.toStringResult, - bindings3->InternalExpressionValue.toStringRecord, + result3->Reducer_Value.toStringResult, + bindings3->Reducer_Value.toStringRecord, )->expect == ("Ok(())", "{z: 3}") /* Doing it like this is too verbose for a storybook 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 8e584576..e5af0e3f 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 @@ -1,5 +1,4 @@ @@warning("-44") -module InternalExpressionValue = ReducerInterface_InternalExpressionValue module Project = ForTS_ReducerProject module Bindings = Reducer_Bindings @@ -146,8 +145,8 @@ Here we will finally proceed to a real life scenario. */ /* And see the result and bindings.. */ test("recursive includes", () => { ( - result->InternalExpressionValue.toStringResult, - bindings->InternalExpressionValue.toStringRecord, + 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__/ReducerProject/ReducerProject_tutorial_4_injecting_user_values.res b/packages/squiggle-lang/__tests__/ReducerProject/ReducerProject_tutorial_4_injecting_user_values.res index 38d655c1..507e12cc 100644 --- a/packages/squiggle-lang/__tests__/ReducerProject/ReducerProject_tutorial_4_injecting_user_values.res +++ b/packages/squiggle-lang/__tests__/ReducerProject/ReducerProject_tutorial_4_injecting_user_values.res @@ -1,7 +1,5 @@ @@warning("-44") -module InternalExpressionValue = ReducerInterface_InternalExpressionValue module Project = ForTS_ReducerProject -module Bindings = Reducer_Bindings open Jest open Expect @@ -30,7 +28,7 @@ describe("ReducerProject Tutorial", () => { /* We can now run the project */ Project.runAll(project) let result = Project.getResult(project, "main") - result->InternalExpressionValue.toStringResult->expect == "Ok(6)" + result->Reducer_Value.toStringResult->expect == "Ok(6)" }) }) diff --git a/packages/squiggle-lang/__tests__/ReducerProject/ReducerProject_tutorial_5_calling_functions.res b/packages/squiggle-lang/__tests__/ReducerProject/ReducerProject_tutorial_5_calling_functions.res index 7e2471b5..35643c77 100644 --- a/packages/squiggle-lang/__tests__/ReducerProject/ReducerProject_tutorial_5_calling_functions.res +++ b/packages/squiggle-lang/__tests__/ReducerProject/ReducerProject_tutorial_5_calling_functions.res @@ -1,5 +1,4 @@ @@warning("-44") -module InternalExpressionValue = ReducerInterface_InternalExpressionValue module Project = ForTS_ReducerProject module Bindings = Reducer_Bindings @@ -32,7 +31,7 @@ describe("ReducerProject Tutorial", () => { test("userResults", () => { let userResultsAsString = Belt.Array.map(userResults, aResult => - aResult->InternalExpressionValue.toStringResult + aResult->Reducer_Value.toStringResult ) userResultsAsString->expect == ["Ok(2)", "Ok(4)", "Ok(6)", "Ok(8)", "Ok(10)"] }) diff --git a/packages/squiggle-lang/__tests__/SquiggleLibrary/SquiggleLibrary_FunctionRegistryLibrary_test.res b/packages/squiggle-lang/__tests__/SquiggleLibrary/SquiggleLibrary_FunctionRegistryLibrary_test.res index 95fdbdf6..da4788e5 100644 --- a/packages/squiggle-lang/__tests__/SquiggleLibrary/SquiggleLibrary_FunctionRegistryLibrary_test.res +++ b/packages/squiggle-lang/__tests__/SquiggleLibrary/SquiggleLibrary_FunctionRegistryLibrary_test.res @@ -4,7 +4,6 @@ open Reducer_TestHelpers let expectEvalToBeOk = (code: string) => Reducer_Expression.BackCompatible.evaluateString(code) - ->Reducer_Helpers.rRemoveDefaultsInternal ->E.R.isOk ->expect ->toBe(true) @@ -102,7 +101,7 @@ describe("FunctionRegistry Library", () => { let responseType = example ->Reducer_Expression.BackCompatible.evaluateString - ->E.R2.fmap(ReducerInterface_InternalExpressionValue.valueToValueType) + ->E.R2.fmap(Reducer_Value.valueToValueType) let expectedOutputType = fn.output |> E.O.toExn("") expect(responseType)->toEqual(Ok(expectedOutputType)) }, diff --git a/packages/squiggle-lang/src/rescript/FR/FR_Builtin.res b/packages/squiggle-lang/src/rescript/FR/FR_Builtin.res index e346075d..e0bc776a 100644 --- a/packages/squiggle-lang/src/rescript/FR/FR_Builtin.res +++ b/packages/squiggle-lang/src/rescript/FR/FR_Builtin.res @@ -5,7 +5,7 @@ let nameSpace = "" // no namespaced versions type simpleDefinition = { inputs: array, - fn: array => result, + fn: array => result, } let makeFnMany = (name: string, definitions: array) => @@ -22,7 +22,7 @@ let makeFnMany = (name: string, definitions: array) => let makeFn = ( name: string, inputs: array, - fn: array => result, + fn: array => result, ) => makeFnMany(name, [{inputs: inputs, fn: fn}]) let library = [ @@ -140,7 +140,7 @@ let library = [ makeFn("inspect", [FRTypeAny], inputs => { switch inputs { | [value] => { - Js.log(value->ReducerInterface_InternalExpressionValue.toString) + Js.log(value->Reducer_Value.toString) value->Ok } | _ => Error(impossibleError) @@ -149,7 +149,7 @@ let library = [ makeFn("inspect", [FRTypeAny, FRTypeString], inputs => { switch inputs { | [value, IEvString(label)] => { - Js.log(`${label}: ${value->ReducerInterface_InternalExpressionValue.toString}`) + Js.log(`${label}: ${value->Reducer_Value.toString}`) value->Ok } | _ => Error(impossibleError) @@ -158,7 +158,7 @@ let library = [ makeFn("javascriptraise", [FRTypeAny], inputs => { switch inputs { | [msg] => { - Js.Exn.raiseError(msg->ReducerInterface_InternalExpressionValue.toString) + Js.Exn.raiseError(msg->Reducer_Value.toString) } | _ => Error(impossibleError) } diff --git a/packages/squiggle-lang/src/rescript/FR/FR_Date.res b/packages/squiggle-lang/src/rescript/FR/FR_Date.res index 96f94b9d..bf7e2120 100644 --- a/packages/squiggle-lang/src/rescript/FR/FR_Date.res +++ b/packages/squiggle-lang/src/rescript/FR/FR_Date.res @@ -4,7 +4,7 @@ open FunctionRegistry_Helpers let makeFn = ( name: string, inputs: array, - fn: array => result, + fn: array => result, ) => Function.make( ~name, diff --git a/packages/squiggle-lang/src/rescript/FR/FR_Dict.res b/packages/squiggle-lang/src/rescript/FR/FR_Dict.res index 310d295d..c8a82b9c 100644 --- a/packages/squiggle-lang/src/rescript/FR/FR_Dict.res +++ b/packages/squiggle-lang/src/rescript/FR/FR_Dict.res @@ -6,24 +6,24 @@ let nameSpace = "Dict" module Internals = { type t = Reducer_T.map - let keys = (a: t): internalExpressionValue => IEvArray( + let keys = (a: t): Reducer_T.value => IEvArray( Belt.Map.String.keysToArray(a)->E.A2.fmap(Wrappers.evString), ) - let values = (a: t): internalExpressionValue => IEvArray(Belt.Map.String.valuesToArray(a)) + let values = (a: t): Reducer_T.value => IEvArray(Belt.Map.String.valuesToArray(a)) - let toList = (a: t): internalExpressionValue => + let toList = (a: t): Reducer_T.value => Belt.Map.String.toArray(a) ->E.A2.fmap(((key, value)) => Wrappers.evArray([IEvString(key), value])) ->Wrappers.evArray - let fromList = (items: array): result< - internalExpressionValue, + let fromList = (items: array): result< + Reducer_T.value, errorValue, > => items ->E.A2.fmap(item => { - switch (item: internalExpressionValue) { + switch (item: Reducer_T.value) { | IEvArray([IEvString(string), value]) => (string, value)->Ok | _ => Error(impossibleError) } @@ -32,12 +32,12 @@ module Internals = { ->E.R2.fmap(Belt.Map.String.fromArray) ->E.R2.fmap(Wrappers.evRecord) - let merge = (a: t, b: t): internalExpressionValue => IEvRecord( + let merge = (a: t, b: t): Reducer_T.value => IEvRecord( Belt.Map.String.merge(a, b, (_, _, c) => c), ) //Belt.Map.String has a function for mergeMany, but I couldn't understand how to use it yet. - let mergeMany = (a: array): internalExpressionValue => { + let mergeMany = (a: array): Reducer_T.value => { let mergedValues = a->E.A2.fmap(Belt.Map.String.toArray)->Belt.Array.concatMany->Belt.Map.String.fromArray IEvRecord(mergedValues) diff --git a/packages/squiggle-lang/src/rescript/FR/FR_Dist.res b/packages/squiggle-lang/src/rescript/FR/FR_Dist.res index 8482f3f8..1ee92c87 100644 --- a/packages/squiggle-lang/src/rescript/FR/FR_Dist.res +++ b/packages/squiggle-lang/src/rescript/FR/FR_Dist.res @@ -4,7 +4,7 @@ let twoArgs = E.Tuple2.toFnCall module DistributionCreation = { let nameSpace = "Dist" - let output = ReducerInterface_InternalExpressionValue.EvtDistribution + let output = Reducer_Value.EvtDistribution let requiresNamespace = false let fnMake = (~name, ~examples, ~definitions) => { diff --git a/packages/squiggle-lang/src/rescript/FR/FR_Fn.res b/packages/squiggle-lang/src/rescript/FR/FR_Fn.res index 44d8882b..86db7edc 100644 --- a/packages/squiggle-lang/src/rescript/FR/FR_Fn.res +++ b/packages/squiggle-lang/src/rescript/FR/FR_Fn.res @@ -7,7 +7,7 @@ module Declaration = { ("inputs", FRTypeArray(FRTypeRecord([("min", FRTypeNumber), ("max", FRTypeNumber)]))), ]) - let fromExpressionValue = (e: frValue): result => { + let fromExpressionValue = (e: frValue): result => { switch FunctionRegistry_Helpers.Prepare.ToValueArray.Record.twoArgs([e]) { | Ok([FRValueLambda(lambda), FRValueArray(inputs)]) => { open FunctionRegistry_Helpers.Prepare diff --git a/packages/squiggle-lang/src/rescript/FR/FR_GenericDist.res b/packages/squiggle-lang/src/rescript/FR/FR_GenericDist.res index dc449ee4..93f720b4 100644 --- a/packages/squiggle-lang/src/rescript/FR/FR_GenericDist.res +++ b/packages/squiggle-lang/src/rescript/FR/FR_GenericDist.res @@ -18,7 +18,7 @@ module Old = { | _ => #Multiply } - let catchAndConvertTwoArgsToDists = (args: array): option<( + let catchAndConvertTwoArgsToDists = (args: array): option<( DistributionTypes.genericDist, DistributionTypes.genericDist, )> => @@ -68,18 +68,18 @@ module Old = { )->DistributionOperation.run(~env) } - let parseNumber = (args: internalExpressionValue): Belt.Result.t => + let parseNumber = (args: Reducer_T.value): Belt.Result.t => switch args { | IEvNumber(x) => Ok(x) | _ => Error("Not a number") } - let parseNumberArray = (ags: array): Belt.Result.t< + let parseNumberArray = (ags: array): Belt.Result.t< array, string, > => E.A.fmap(parseNumber, ags) |> E.A.R.firstErrorOrOpen - let parseDist = (args: internalExpressionValue): Belt.Result.t< + let parseDist = (args: Reducer_T.value): Belt.Result.t< DistributionTypes.genericDist, string, > => @@ -89,7 +89,7 @@ module Old = { | _ => Error("Not a distribution") } - let parseDistributionArray = (ags: array): Belt.Result.t< + let parseDistributionArray = (ags: array): Belt.Result.t< array, string, > => E.A.fmap(parseDist, ags) |> E.A.R.firstErrorOrOpen @@ -115,7 +115,7 @@ module Old = { } let mixture = ( - args: array, + args: array, ~env: GenericDist.env, ): DistributionOperation.outputType => { let error = (err: string): DistributionOperation.outputType => @@ -174,7 +174,7 @@ module Old = { } let dispatchToGenericOutput = ( - call: ReducerInterface_InternalExpressionValue.functionCall, + call: Reducer_Value.functionCall, env: GenericDist.env, ): option => { let (fnName, args) = call @@ -301,7 +301,7 @@ module Old = { } let genericOutputToReducerValue = (o: DistributionOperation.outputType): result< - internalExpressionValue, + Reducer_T.value, Reducer_ErrorValue.errorValue, > => switch o { @@ -313,7 +313,7 @@ module Old = { | GenDistError(err) => Error(REDistributionError(err)) } - let dispatch = (call: ReducerInterface_InternalExpressionValue.functionCall, environment) => + let dispatch = (call: Reducer_Value.functionCall, environment) => switch dispatchToGenericOutput(call, environment) { | Some(o) => genericOutputToReducerValue(o) | None => diff --git a/packages/squiggle-lang/src/rescript/FR/FR_List.res b/packages/squiggle-lang/src/rescript/FR/FR_List.res index eb6a653a..9bc68847 100644 --- a/packages/squiggle-lang/src/rescript/FR/FR_List.res +++ b/packages/squiggle-lang/src/rescript/FR/FR_List.res @@ -7,29 +7,29 @@ let requiresNamespace = true module Internals = { let makeFromNumber = ( n: float, - value: internalExpressionValue, - ): internalExpressionValue => IEvArray(Belt.Array.make(E.Float.toInt(n), value)) + value: Reducer_T.value, + ): Reducer_T.value => IEvArray(Belt.Array.make(E.Float.toInt(n), value)) - let upTo = (low: float, high: float): internalExpressionValue => IEvArray( + 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), ) - let first = (v: array): result => + let first = (v: array): result => v->E.A.first |> E.O.toResult("No first element") - let last = (v: array): result => + let last = (v: array): result => v->E.A.last |> E.O.toResult("No last element") - let reverse = (array: array): internalExpressionValue => IEvArray( + let reverse = (array: array): Reducer_T.value => IEvArray( Belt.Array.reverse(array), ) let map = ( - array: array, + array: array, eLambdaValue, env: Reducer_T.environment, reducer: Reducer_T.reducerFn, - ): internalExpressionValue => { + ): Reducer_T.value => { Belt.Array.map(array, elem => Reducer_Expression_Lambda.doLambdaCall(eLambdaValue, [elem], env, reducer) )->Wrappers.evArray diff --git a/packages/squiggle-lang/src/rescript/FR/FR_Pointset.res b/packages/squiggle-lang/src/rescript/FR/FR_Pointset.res index 61d03c9d..54b8706d 100644 --- a/packages/squiggle-lang/src/rescript/FR/FR_Pointset.res +++ b/packages/squiggle-lang/src/rescript/FR/FR_Pointset.res @@ -48,7 +48,7 @@ let library = [ ~nameSpace, ~requiresNamespace=true, ~examples=[`PointSet.fromDist(normal(5,2))`], - ~output=ReducerInterface_InternalExpressionValue.EvtDistribution, + ~output=Reducer_Value.EvtDistribution, ~definitions=[ FnDefinition.make( ~name="fromDist", @@ -77,7 +77,7 @@ let library = [ ~nameSpace, ~requiresNamespace=true, ~examples=[`PointSet.mapY(mx(normal(5,2)), {|x| x + 1})`], - ~output=ReducerInterface_InternalExpressionValue.EvtDistribution, + ~output=Reducer_Value.EvtDistribution, ~definitions=[ FnDefinition.make( ~name="mapY", @@ -105,7 +105,7 @@ let library = [ {x: 3, y: 0.2} ])`, ], - ~output=ReducerInterface_InternalExpressionValue.EvtDistribution, + ~output=Reducer_Value.EvtDistribution, ~definitions=[ FnDefinition.make( ~name="makeContinuous", @@ -129,7 +129,7 @@ let library = [ {x: 3, y: 0.2} ])`, ], - ~output=ReducerInterface_InternalExpressionValue.EvtDistribution, + ~output=Reducer_Value.EvtDistribution, ~definitions=[ FnDefinition.make( ~name="makeDiscrete", diff --git a/packages/squiggle-lang/src/rescript/FR/FR_Sampleset.res b/packages/squiggle-lang/src/rescript/FR/FR_Sampleset.res index 4c04489b..228e8805 100644 --- a/packages/squiggle-lang/src/rescript/FR/FR_Sampleset.res +++ b/packages/squiggle-lang/src/rescript/FR/FR_Sampleset.res @@ -48,10 +48,10 @@ module Internal = { SampleSetDist.map3(~fn, ~t1, ~t2, ~t3)->toType } - let parseSampleSetArray = (arr: array): option< + let parseSampleSetArray = (arr: array): option< array, > => { - let parseSampleSet = (value: internalExpressionValue): option => + let parseSampleSet = (value: Reducer_T.value): option => switch value { | IEvDistribution(SampleSet(dist)) => Some(dist) | _ => None @@ -60,7 +60,7 @@ module Internal = { } let mapN = ( - aValueArray: array, + aValueArray: array, aLambdaValue, environment: Reducer_T.environment, reducer, @@ -86,7 +86,7 @@ let libaryBase = [ ~nameSpace, ~requiresNamespace=true, ~examples=[`SampleSet.fromDist(normal(5,2))`], - ~output=ReducerInterface_InternalExpressionValue.EvtDistribution, + ~output=Reducer_Value.EvtDistribution, ~definitions=[ FnDefinition.make( ~name="fromDist", @@ -110,7 +110,7 @@ let libaryBase = [ ~nameSpace, ~requiresNamespace=true, ~examples=[`SampleSet.fromList([3,5,2,3,5,2,3,5,2,3,3,5,3,2,3,1,1,3])`], - ~output=ReducerInterface_InternalExpressionValue.EvtDistribution, + ~output=Reducer_Value.EvtDistribution, ~definitions=[ FnDefinition.make( ~name="fromList", @@ -135,7 +135,7 @@ let libaryBase = [ ~nameSpace, ~requiresNamespace=true, ~examples=[`SampleSet.toList(SampleSet.fromDist(normal(5,2)))`], - ~output=ReducerInterface_InternalExpressionValue.EvtArray, + ~output=Reducer_Value.EvtArray, ~definitions=[ FnDefinition.make( ~name="toList", @@ -156,7 +156,7 @@ let libaryBase = [ ~nameSpace, ~requiresNamespace=true, ~examples=[`SampleSet.fromFn({|| sample(normal(5,2))})`], - ~output=ReducerInterface_InternalExpressionValue.EvtDistribution, + ~output=Reducer_Value.EvtDistribution, ~definitions=[ FnDefinition.make( ~name="fromFn", @@ -180,7 +180,7 @@ let libaryBase = [ ~nameSpace, ~requiresNamespace, ~examples=[`SampleSet.map(SampleSet.fromDist(normal(5,2)), {|x| x + 1})`], - ~output=ReducerInterface_InternalExpressionValue.EvtDistribution, + ~output=Reducer_Value.EvtDistribution, ~definitions=[ FnDefinition.make( ~name="map", @@ -203,7 +203,7 @@ let libaryBase = [ ~examples=[ `SampleSet.map2(SampleSet.fromDist(normal(5,2)), SampleSet.fromDist(normal(5,2)), {|x, y| x + y})`, ], - ~output=ReducerInterface_InternalExpressionValue.EvtDistribution, + ~output=Reducer_Value.EvtDistribution, ~definitions=[ FnDefinition.make( ~name="map2", @@ -231,7 +231,7 @@ let libaryBase = [ ~examples=[ `SampleSet.map3(SampleSet.fromDist(normal(5,2)), SampleSet.fromDist(normal(5,2)), SampleSet.fromDist(normal(5,2)), {|x, y, z| max([x,y,z])})`, ], - ~output=ReducerInterface_InternalExpressionValue.EvtDistribution, + ~output=Reducer_Value.EvtDistribution, ~definitions=[ FnDefinition.make( ~name="map3", @@ -259,7 +259,7 @@ let libaryBase = [ ~examples=[ `SampleSet.mapN([SampleSet.fromDist(normal(5,2)), SampleSet.fromDist(normal(5,2)), SampleSet.fromDist(normal(5,2))], {|x| max(x)})`, ], - ~output=ReducerInterface_InternalExpressionValue.EvtDistribution, + ~output=Reducer_Value.EvtDistribution, ~definitions=[ FnDefinition.make( ~name="mapN", @@ -306,7 +306,7 @@ module Comparison = { `SampleSet.${name}(SampleSet.fromDist(normal(5,2)), 3.0)`, `SampleSet.${name}(4.0, SampleSet.fromDist(normal(6,2)))`, ], - ~output=ReducerInterface_InternalExpressionValue.EvtDistribution, + ~output=Reducer_Value.EvtDistribution, ~definitions=[ template(name, [FRTypeDist, FRTypeDist], inputs => { switch inputs { diff --git a/packages/squiggle-lang/src/rescript/ForTS/ForTS_Distribution/ForTS_Distribution.res b/packages/squiggle-lang/src/rescript/ForTS/ForTS_Distribution/ForTS_Distribution.res index 80824ba9..6701b580 100644 --- a/packages/squiggle-lang/src/rescript/ForTS/ForTS_Distribution/ForTS_Distribution.res +++ b/packages/squiggle-lang/src/rescript/ForTS/ForTS_Distribution/ForTS_Distribution.res @@ -8,7 +8,7 @@ type environment = ForTS_Distribution_Environment.environment //use @genType -let defaultEnvironment: environment = DistributionOperation.defaultEnv +let defaultEnvironment: environment = Reducer_Context.defaultEnvironment @module("./ForTS_Distribution_tag") @scope("distributionTag") external dtPointSet_: string = "PointSet" 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 07dccc50..0b6b9d93 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 @@ -74,13 +74,13 @@ let getTag = (variant: squiggleValue): squiggleValueTag => @genType let toString = (variant: squiggleValue) => - ReducerInterface_InternalExpressionValue.toString(variant) + Reducer_Value.toString(variant) // This is a useful method for unit tests. // Convert the result along with the error message to a string. @genType let toStringResult = (variantResult: result) => - ReducerInterface_InternalExpressionValue.toStringResult(variantResult) + Reducer_Value.toStringResult(variantResult) @genType let getArray = (variant: squiggleValue): option => 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 cfe128e7..823fde5c 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 @@ -3,8 +3,8 @@ type squiggleValue = ForTS_SquiggleValue.squiggleValue @genType let getValues = (v: squiggleValue_Array): array => - ReducerInterface_InternalExpressionValue.arrayToValueArray(v) + Reducer_Value.arrayToValueArray(v) @genType let toString = (v: squiggleValue_Array): string => - ReducerInterface_InternalExpressionValue.toStringArray(v) + 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 d7da5e1e..5c8eae49 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 @@ -2,4 +2,4 @@ @genType let toString = (v: squiggleValue_Declaration): string => - ReducerInterface_InternalExpressionValue.toStringDeclaration(v) + 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 c346701c..b1d6b440 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 @@ -2,4 +2,4 @@ @genType let toString = (v: squiggleValue_Distribution): string => - ReducerInterface_InternalExpressionValue.toStringDistribution(v) + 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 ef4c460f..f6ec66d3 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 @@ -2,7 +2,7 @@ @genType let toString = (v: squiggleValue_Lambda): string => - ReducerInterface_InternalExpressionValue.toStringFunction(v) + Reducer_Value.toStringFunction(v) @genType let parameters = (v: squiggleValue_Lambda): array => { diff --git a/packages/squiggle-lang/src/rescript/ForTS/ForTS_SquiggleValue/ForTS_SquiggleValue_Record.res b/packages/squiggle-lang/src/rescript/ForTS/ForTS_SquiggleValue/ForTS_SquiggleValue_Record.res index e145eefc..2f0d034a 100644 --- a/packages/squiggle-lang/src/rescript/ForTS/ForTS_SquiggleValue/ForTS_SquiggleValue_Record.res +++ b/packages/squiggle-lang/src/rescript/ForTS/ForTS_SquiggleValue/ForTS_SquiggleValue_Record.res @@ -3,10 +3,10 @@ type squiggleValue = ForTS_SquiggleValue.squiggleValue //use @genType let getKeyValuePairs = (value: squiggleValue_Record): array<(string, squiggleValue)> => - ReducerInterface_InternalExpressionValue.recordToKeyValuePairs(value) + Reducer_Value.recordToKeyValuePairs(value) @genType -let toString = (v: squiggleValue_Record) => ReducerInterface_InternalExpressionValue.toStringMap(v) +let toString = (v: squiggleValue_Record) => Reducer_Value.toStringMap(v) @genType let toSquiggleValue = (v: squiggleValue_Record): squiggleValue => IEvRecord(v) 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 1399dcf4..0c002040 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 @@ -3,8 +3,8 @@ type squiggleValue = ForTS_SquiggleValue.squiggleValue //use @genType let getKeyValuePairs = (value: squiggleValue_Type): array<(string, squiggleValue)> => - ReducerInterface_InternalExpressionValue.recordToKeyValuePairs(value) + Reducer_Value.recordToKeyValuePairs(value) @genType let toString = (value: squiggleValue_Type): string => - ReducerInterface_InternalExpressionValue.toStringType(value) + 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 a5685f2e..901915e3 100644 --- a/packages/squiggle-lang/src/rescript/FunctionRegistry/FunctionRegistry_Core.res +++ b/packages/squiggle-lang/src/rescript/FunctionRegistry/FunctionRegistry_Core.res @@ -1,5 +1,4 @@ -type internalExpressionValue = Reducer_T.value -type internalExpressionValueType = ReducerInterface_InternalExpressionValue.internalExpressionValueType +type internalExpressionValueType = Reducer_Value.internalExpressionValueType type errorValue = Reducer_ErrorValue.errorValue /* @@ -51,11 +50,11 @@ type fnDefinition = { name: string, inputs: array, run: ( - array, + array, array, Reducer_T.environment, Reducer_T.reducerFn, - ) => result, + ) => result, } type function = { @@ -92,7 +91,7 @@ module FRType = { | FRTypeAny => `any` } - let rec toFrValue = (r: internalExpressionValue): option => + let rec toFrValue = (r: Reducer_T.value): option => // not all value variants are supported, but it's not important (we'll probably deprecate frValues soon anyway) switch r { | IEvNumber(f) => Some(FRValueNumber(f)) @@ -109,7 +108,7 @@ module FRType = { | _ => None } - let rec matchWithExpressionValue = (t: t, r: internalExpressionValue): option => + let rec matchWithExpressionValue = (t: t, r: Reducer_T.value): option => switch (t, r) { | (FRTypeAny, f) => toFrValue(f) | (FRTypeString, IEvString(f)) => Some(FRValueString(f)) @@ -149,7 +148,7 @@ module FRType = { | _ => None } - let rec matchReverse = (e: frValue): internalExpressionValue => + let rec matchReverse = (e: frValue): Reducer_T.value => switch e { | FRValueNumber(f) => IEvNumber(f) | FRValueBool(f) => IEvBool(f) @@ -182,7 +181,7 @@ module FRType = { let matchWithExpressionValueArray = ( inputs: array, - args: array, + args: array, ): option> => { let isSameLength = E.A.length(inputs) == E.A.length(args) if !isSameLength { @@ -203,7 +202,7 @@ module FnDefinition = { t.name ++ `(${inputs})` } - let isMatch = (t: t, args: array) => { + let isMatch = (t: t, args: array) => { let argValues = FRType.matchWithExpressionValueArray(t.inputs, args) switch argValues { | Some(_) => true @@ -213,7 +212,7 @@ module FnDefinition = { let run = ( t: t, - args: array, + args: array, env: Reducer_T.environment, reducer: Reducer_T.reducerFn, ) => { @@ -317,10 +316,10 @@ module Registry = { let call = ( registry, fnName: string, - args: array, + args: array, env: Reducer_T.environment, reducer: Reducer_T.reducerFn, - ): result => { + ): result => { switch Belt.Map.String.get(registry.fnNameDict, fnName) { | Some(definitions) => { let showNameMatchDefinitions = () => { diff --git a/packages/squiggle-lang/src/rescript/Reducer/Reducer_Bindings.res b/packages/squiggle-lang/src/rescript/Reducer/Reducer_Bindings.res index 4ca31638..8311792b 100644 --- a/packages/squiggle-lang/src/rescript/Reducer/Reducer_Bindings.res +++ b/packages/squiggle-lang/src/rescript/Reducer/Reducer_Bindings.res @@ -5,7 +5,6 @@ */ type t = Reducer_T.bindings -type internalExpressionValue = Reducer_T.value let rec get = ({namespace, parent}: t, id: string) => { switch namespace->Reducer_Namespace.get(id) { diff --git a/packages/squiggle-lang/src/rescript/Reducer/Reducer_Context.res b/packages/squiggle-lang/src/rescript/Reducer/Reducer_Context.res index f9b8a2c8..ff835e96 100644 --- a/packages/squiggle-lang/src/rescript/Reducer/Reducer_Context.res +++ b/packages/squiggle-lang/src/rescript/Reducer/Reducer_Context.res @@ -1,5 +1,7 @@ type t = Reducer_T.context +let defaultEnvironment: Reducer_T.environment = DistributionOperation.defaultEnv + let createContext = (stdLib: Reducer_Namespace.t, environment: Reducer_T.environment): t => { { bindings: stdLib->Reducer_Bindings.fromNamespace->Reducer_Bindings.extend, @@ -8,7 +10,4 @@ let createContext = (stdLib: Reducer_Namespace.t, environment: Reducer_T.environ } let createDefaultContext = (): t => - createContext( - ReducerInterface_StdLib.internalStdLib, - ReducerInterface_InternalExpressionValue.defaultEnvironment, - ) + createContext(SquiggleLibrary_StdLib.stdLib, defaultEnvironment) diff --git a/packages/squiggle-lang/src/rescript/Reducer/Reducer_Dispatch/Reducer_Dispatch_ChainPiece.res b/packages/squiggle-lang/src/rescript/Reducer/Reducer_Dispatch/Reducer_Dispatch_ChainPiece.res index ebeb7f43..f0506f8a 100644 --- a/packages/squiggle-lang/src/rescript/Reducer/Reducer_Dispatch/Reducer_Dispatch_ChainPiece.res +++ b/packages/squiggle-lang/src/rescript/Reducer/Reducer_Dispatch/Reducer_Dispatch_ChainPiece.res @@ -1,7 +1,7 @@ // module ProjectAccessorsT = ReducerProject_ProjectAccessors_T // module T = Reducer_Dispatch_T // module TypeChecker = Reducer_Type_TypeChecker -// open ReducerInterface_InternalExpressionValue +// open Reducer_Value // type errorValue = Reducer_ErrorValue.errorValue diff --git a/packages/squiggle-lang/src/rescript/Reducer/Reducer_Dispatch/Reducer_Dispatch_T.res b/packages/squiggle-lang/src/rescript/Reducer/Reducer_Dispatch/Reducer_Dispatch_T.res index a60a92b5..0d852783 100644 --- a/packages/squiggle-lang/src/rescript/Reducer/Reducer_Dispatch/Reducer_Dispatch_T.res +++ b/packages/squiggle-lang/src/rescript/Reducer/Reducer_Dispatch/Reducer_Dispatch_T.res @@ -1,15 +1,14 @@ -// module InternalExpressionValue = ReducerInterface_InternalExpressionValue // module ExpressionT = Reducer_Expression_T // module ProjectAccessorsT = ReducerProject_ProjectAccessors_T // // Each piece of the dispatch chain computes the result or returns None so that the chain can continue // type dispatchChainPiece = ( -// InternalExpressionValue.functionCall, +// Reducer_Value.functionCall, // ProjectAccessorsT.t, // ) => option> // type dispatchChainPieceWithReducer = ( -// InternalExpressionValue.functionCall, +// Reducer_Value.functionCall, // ProjectAccessorsT.t, // Reducer_T.reducerFn, // ) => option> 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 1bcdc030..e608036a 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,7 +103,7 @@ let rec evaluate: T.reducerFn = (expression, context): (T.value, T.context) => { context, ) | _ => - RENotAFunction(lambda->ReducerInterface_InternalExpressionValue.toString) + RENotAFunction(lambda->Reducer_Value.toString) ->Reducer_ErrorValue.ErrorException ->raise } diff --git a/packages/squiggle-lang/src/rescript/Reducer/Reducer_Expression/Reducer_Expression_Lambda.res b/packages/squiggle-lang/src/rescript/Reducer/Reducer_Expression/Reducer_Expression_Lambda.res index bb4e80c5..e9a85a1a 100644 --- a/packages/squiggle-lang/src/rescript/Reducer/Reducer_Expression/Reducer_Expression_Lambda.res +++ b/packages/squiggle-lang/src/rescript/Reducer/Reducer_Expression/Reducer_Expression_Lambda.res @@ -1,8 +1,5 @@ -module Bindings = Reducer_Bindings module ErrorValue = Reducer_ErrorValue -type internalExpressionValue = ReducerInterface_InternalExpressionValue.t - let doLambdaCall = ( lambdaValue: Reducer_T.lambdaValue, args, @@ -21,6 +18,7 @@ let makeLambda = ( // Note: with this implementation, FFI lambdas (created by other methods than calling `makeLambda`) are allowed to violate the rules, pollute the bindings, etc. // Not sure yet if that's a bug or a feature. + // FunctionRegistry functions are unaffected by this, their API is too limited. let lambda = ( arguments: array, diff --git a/packages/squiggle-lang/src/rescript/Reducer/Reducer_Expression/Reducer_Expression_T.res b/packages/squiggle-lang/src/rescript/Reducer/Reducer_Expression/Reducer_Expression_T.res index 365d0836..71995c0a 100644 --- a/packages/squiggle-lang/src/rescript/Reducer/Reducer_Expression/Reducer_Expression_T.res +++ b/packages/squiggle-lang/src/rescript/Reducer/Reducer_Expression/Reducer_Expression_T.res @@ -2,8 +2,6 @@ An expression is an intermediate representation of a Squiggle code. Expressions are evaluated by `Reducer_Expression.evaluate` function. */ -module InternalExpressionValue = ReducerInterface_InternalExpressionValue - type t = Reducer_T.expression let commaJoin = values => values->Reducer_Extra_Array.intersperse(", ")->Js.String.concatMany("") @@ -27,7 +25,7 @@ let rec toString = (expression: t) => | EAssign(name, value) => `${name} = ${value->toString}` | ECall(fn, args) => `(${fn->toString})(${args->Js.Array2.map(toString)->commaJoin})` | ELambda(parameters, body) => `{|${parameters->commaJoin}| ${body->toString}}` - | EValue(aValue) => InternalExpressionValue.toString(aValue) + | EValue(aValue) => Reducer_Value.toString(aValue) } let toStringResult = codeResult => diff --git a/packages/squiggle-lang/src/rescript/Reducer/Reducer_Js/Reducer_Js.res b/packages/squiggle-lang/src/rescript/Reducer/Reducer_Js/Reducer_Js.res deleted file mode 100644 index 8e7bd1f2..00000000 --- a/packages/squiggle-lang/src/rescript/Reducer/Reducer_Js/Reducer_Js.res +++ /dev/null @@ -1 +0,0 @@ -module Gate = Reducer_Js_Gate diff --git a/packages/squiggle-lang/src/rescript/Reducer/Reducer_Js/Reducer_Js_Gate.res b/packages/squiggle-lang/src/rescript/Reducer/Reducer_Js/Reducer_Js_Gate.res deleted file mode 100644 index d7a267e2..00000000 --- a/packages/squiggle-lang/src/rescript/Reducer/Reducer_Js/Reducer_Js_Gate.res +++ /dev/null @@ -1,17 +0,0 @@ -open ReducerInterface_InternalExpressionValue -open Reducer_ErrorValue - -external castBool: unit => bool = "%identity" -external castNumber: unit => float = "%identity" -external castString: unit => string = "%identity" - -/* - As JavaScript returns us any type, we need to type check and cast type propertype before using it -*/ -let jsToIEv = (jsValue): result => - switch Js.typeof(jsValue) { - | "boolean" => jsValue->castBool->IEvBool->Ok - | "number" => jsValue->castNumber->IEvNumber->Ok - | "string" => jsValue->castString->IEvString->Ok - | other => RETodo(`Unhandled MathJs literal type: ${Js.String.make(other)}`)->Error - } diff --git a/packages/squiggle-lang/src/rescript/Reducer/Reducer_Namespace.res b/packages/squiggle-lang/src/rescript/Reducer/Reducer_Namespace.res index 5793fe07..14afae95 100644 --- a/packages/squiggle-lang/src/rescript/Reducer/Reducer_Namespace.res +++ b/packages/squiggle-lang/src/rescript/Reducer/Reducer_Namespace.res @@ -25,7 +25,7 @@ let toString = (namespace: t) => namespace ->Belt.Map.String.toArray ->Belt.Array.map(((eachKey, eachValue)) => - `${eachKey}: ${eachValue->ReducerInterface_InternalExpressionValue.toString}` + `${eachKey}: ${eachValue->Reducer_Value.toString}` ) ->Js.Array2.toString diff --git a/packages/squiggle-lang/src/rescript/Reducer/Reducer_Type/Reducer_Type_Compile.res b/packages/squiggle-lang/src/rescript/Reducer/Reducer_Type/Reducer_Type_Compile.res index 5335ece7..2d636d2b 100644 --- a/packages/squiggle-lang/src/rescript/Reducer/Reducer_Type/Reducer_Type_Compile.res +++ b/packages/squiggle-lang/src/rescript/Reducer/Reducer_Type/Reducer_Type_Compile.res @@ -1,15 +1,12 @@ // module Bindings = Reducer_Bindings // module ErrorValue = Reducer_ErrorValue -// module Expression = Reducer_Expression -// module ExpressionT = Reducer_Expression_T -// module InternalExpressionValue = ReducerInterface_InternalExpressionValue // module ProjectAccessorsT = ReducerProject_ProjectAccessors_T // module T = Reducer_Type_T // let ievFromTypeExpression = ( // typeExpressionSourceCode: string, // reducerFn: ProjectReducerFnT.t, -// ): result => { +// ): result => { // let sIndex = "compiled" // let sourceCode = `type ${sIndex}=${typeExpressionSourceCode}` // Reducer_Expression.BackCompatible.parse(sourceCode)->Belt.Result.flatMap(expr => { 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 7b68f178..8433ef22 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 @@ -1,7 +1,6 @@ -module InternalExpressionValue = ReducerInterface_InternalExpressionValue module T = Reducer_Type_T -let isMin = (modifierArg: InternalExpressionValue.t, aValue: InternalExpressionValue.t): bool => { +let isMin = (modifierArg: Reducer_Value.t, aValue: Reducer_Value.t): bool => { let pair = (modifierArg, aValue) switch pair { | (IEvNumber(a), IEvNumber(b)) => a <= b @@ -9,7 +8,7 @@ let isMin = (modifierArg: InternalExpressionValue.t, aValue: InternalExpressionV } } -let isMax = (modifierArg: InternalExpressionValue.t, aValue: InternalExpressionValue.t): bool => { +let isMax = (modifierArg: Reducer_Value.t, aValue: Reducer_Value.t): bool => { let pair = (modifierArg, aValue) switch pair { | (IEvNumber(a), IEvNumber(b)) => a >= b @@ -18,8 +17,8 @@ let isMax = (modifierArg: InternalExpressionValue.t, aValue: InternalExpressionV } let isMemberOf = ( - modifierArg: InternalExpressionValue.t, - aValue: InternalExpressionValue.t, + modifierArg: Reducer_Value.t, + aValue: Reducer_Value.t, ): bool => { let pair = (modifierArg, aValue) switch pair { @@ -30,8 +29,8 @@ let isMemberOf = ( let checkModifier = ( key: string, - modifierArg: InternalExpressionValue.t, - aValue: InternalExpressionValue.t, + modifierArg: Reducer_Value.t, + aValue: Reducer_Value.t, ): bool => switch key { | "min" => isMin(modifierArg, aValue) @@ -41,8 +40,8 @@ let checkModifier = ( } let checkModifiers = ( - contracts: Belt.Map.String.t, - aValue: InternalExpressionValue.t, + contracts: Belt.Map.String.t, + aValue: Reducer_Value.t, ): bool => { contracts->Belt.Map.String.reduce(true, (acc, key, modifierArg) => switch acc { diff --git a/packages/squiggle-lang/src/rescript/Reducer/Reducer_Type/Reducer_Type_T.res b/packages/squiggle-lang/src/rescript/Reducer/Reducer_Type/Reducer_Type_T.res index e7bab837..8f293d53 100644 --- a/packages/squiggle-lang/src/rescript/Reducer/Reducer_Type/Reducer_Type_T.res +++ b/packages/squiggle-lang/src/rescript/Reducer/Reducer_Type/Reducer_Type_T.res @@ -1,9 +1,6 @@ -// module InternalExpressionValue = ReducerInterface_InternalExpressionValue -// open InternalExpressionValue - // type rec iType = // | ItTypeIdentifier(string) -// | ItModifiedType({modifiedType: iType, contracts: Belt.Map.String.t}) +// | ItModifiedType({modifiedType: iType, contracts: Belt.Map.String.t}) // | ItTypeOr({typeOr: array}) // | ItTypeFunction({inputs: array, output: iType}) // | ItTypeArray({element: iType}) @@ -11,14 +8,14 @@ // | ItTypeRecord({properties: Belt.Map.String.t}) // type t = iType -// type typeErrorValue = TypeMismatch(t, InternalExpressionValue.t) +// type typeErrorValue = TypeMismatch(t, Reducer_Value.t) // let rec toString = (t: t): string => { // switch t { // | ItTypeIdentifier(s) => s // | ItModifiedType({modifiedType, contracts}) => // `${toString(modifiedType)}${contracts->Belt.Map.String.reduce("", (acc, k, v) => -// Js.String2.concatMany(acc, ["<-", k, "(", InternalExpressionValue.toString(v), ")"]) +// Js.String2.concatMany(acc, ["<-", k, "(", Reducer_Value.toString(v), ")"]) // )}` // | ItTypeOr({typeOr}) => `(${Js.Array2.map(typeOr, toString)->Js.Array2.joinWith(" | ")})` // | ItTypeFunction({inputs, output}) => @@ -41,42 +38,42 @@ // let rec fromTypeMap = typeMap => { // let default = IEvString("") -// let evTypeTag: InternalExpressionValue.t = Belt.Map.String.getWithDefault( +// let evTypeTag: Reducer_Value.t = Belt.Map.String.getWithDefault( // typeMap, // "typeTag", // default, // ) -// let evTypeIdentifier: InternalExpressionValue.t = Belt.Map.String.getWithDefault( +// let evTypeIdentifier: Reducer_Value.t = Belt.Map.String.getWithDefault( // typeMap, // "typeIdentifier", // default, // ) -// let evTypeOr: InternalExpressionValue.t = Belt.Map.String.getWithDefault( +// let evTypeOr: Reducer_Value.t = Belt.Map.String.getWithDefault( // typeMap, // "typeOr", // default, // ) -// let evInputs: InternalExpressionValue.t = Belt.Map.String.getWithDefault( +// let evInputs: Reducer_Value.t = Belt.Map.String.getWithDefault( // typeMap, // "inputs", // default, // ) -// let evOutput: InternalExpressionValue.t = Belt.Map.String.getWithDefault( +// let evOutput: Reducer_Value.t = Belt.Map.String.getWithDefault( // typeMap, // "output", // default, // ) -// let evElement: InternalExpressionValue.t = Belt.Map.String.getWithDefault( +// let evElement: Reducer_Value.t = Belt.Map.String.getWithDefault( // typeMap, // "element", // default, // ) -// let evElements: InternalExpressionValue.t = Belt.Map.String.getWithDefault( +// let evElements: Reducer_Value.t = Belt.Map.String.getWithDefault( // typeMap, // "elements", // default, // ) -// let evProperties: InternalExpressionValue.t = Belt.Map.String.getWithDefault( +// let evProperties: Reducer_Value.t = Belt.Map.String.getWithDefault( // typeMap, // "properties", // default, @@ -101,18 +98,18 @@ // : ItModifiedType({modifiedType: makeIt, contracts: contracts}) // } -// and fromIEvValue = (ievValue: InternalExpressionValue.t): iType => +// and fromIEvValue = (ievValue: Reducer_Value.t): iType => // switch ievValue { // | IEvTypeIdentifier(typeIdentifier) => ItTypeIdentifier({typeIdentifier}) // | IEvType(typeMap) => fromTypeMap(typeMap) // | _ => raise(Reducer_Exception.ImpossibleException("Reducer_Type_T-ievValue")) // } -// and fromIEvArray = (ievArray: InternalExpressionValue.t) => +// and fromIEvArray = (ievArray: Reducer_Value.t) => // switch ievArray { // | IEvArray(array) => array->Belt.Array.map(fromIEvValue) // | _ => raise(Reducer_Exception.ImpossibleException("Reducer_Type_T-ievArray")) // } -// and fromIEvRecord = (ievRecord: InternalExpressionValue.t) => +// and fromIEvRecord = (ievRecord: Reducer_Value.t) => // switch ievRecord { // | IEvRecord(record) => record->Belt.Map.String.map(fromIEvValue) // | _ => raise(Reducer_Exception.ImpossibleException("Reducer_Type_T-ievRecord")) diff --git a/packages/squiggle-lang/src/rescript/Reducer/Reducer_Type/Reducer_Type_TypeChecker.res b/packages/squiggle-lang/src/rescript/Reducer/Reducer_Type/Reducer_Type_TypeChecker.res index af712587..5d2be602 100644 --- a/packages/squiggle-lang/src/rescript/Reducer/Reducer_Type/Reducer_Type_TypeChecker.res +++ b/packages/squiggle-lang/src/rescript/Reducer/Reducer_Type/Reducer_Type_TypeChecker.res @@ -1,9 +1,8 @@ // module ExpressionT = Reducer_Expression_T -// module InternalExpressionValue = ReducerInterface_InternalExpressionValue // module ProjectAccessorsT = ReducerProject_ProjectAccessors_T // module T = Reducer_Type_T // module TypeContracts = Reducer_Type_Contracts -// open InternalExpressionValue +// open Reducer_Value // let rec isITypeOf = (anIType: T.iType, aValue): result => { // let caseTypeIdentifier = (anUpperTypeName, aValue) => { @@ -98,8 +97,8 @@ // let caseModifiedType = ( // anIType: T.iType, // modifiedType: T.iType, -// contracts: Belt.Map.String.t, -// aValue: InternalExpressionValue.t, +// contracts: Belt.Map.String.t, +// aValue: Reducer_Value.t, // ) => { // isITypeOf(modifiedType, aValue)->Belt.Result.flatMap(_result => { // if TypeContracts.checkModifiers(contracts, aValue) { @@ -113,7 +112,7 @@ // switch anIType { // | ItTypeIdentifier(name) => caseTypeIdentifier(name, aValue) // | ItModifiedType({modifiedType, contracts}) => -// caseModifiedType(anIType, modifiedType, contracts, aValue) //{modifiedType: iType, contracts: Belt.Map.String.t} +// caseModifiedType(anIType, modifiedType, contracts, aValue) //{modifiedType: iType, contracts: Belt.Map.String.t} // | ItTypeOr({typeOr}) => caseOr(anIType, typeOr, aValue) // | ItTypeFunction(_) => // raise( @@ -129,23 +128,23 @@ // let isTypeOf = ( // typeExpressionSourceCode: string, -// aValue: InternalExpressionValue.t, +// aValue: Reducer_Value.t, // reducerFn: Reducer_T.reducerFn, -// ): result => { +// ): result => { // switch typeExpressionSourceCode->Reducer_Type_Compile.fromTypeExpression(reducerFn) { // | Ok(anIType) => // switch isITypeOf(anIType, aValue) { // | Ok(_) => Ok(aValue) // | Error(T.TypeMismatch(anIType, evValue)) => // Error( -// ErrorValue.REExpectedType(anIType->T.toString, evValue->InternalExpressionValue.toString), +// ErrorValue.REExpectedType(anIType->T.toString, evValue->Reducer_Value.toString), // ) // } // | Error(error) => Error(error) // Directly propagating - err => err - causes type mismatch // } // } -// let checkITypeArguments = (anIType: T.iType, args: array): result< +// let checkITypeArguments = (anIType: T.iType, args: array): result< // bool, // T.typeErrorValue, // > => { @@ -155,7 +154,7 @@ // } // } -// let checkITypeArgumentsBool = (anIType: T.iType, args: array): bool => { +// let checkITypeArgumentsBool = (anIType: T.iType, args: array): bool => { // switch checkITypeArguments(anIType, args) { // | Ok(_) => true // | _ => false @@ -164,16 +163,16 @@ // let checkArguments = ( // typeExpressionSourceCode: string, -// args: array, +// args: array, // reducerFn: ReducerT.reducerFn, -// ): result => { +// ): result => { // switch typeExpressionSourceCode->Reducer_Type_Compile.fromTypeExpression(reducerFn) { // | Ok(anIType) => // switch checkITypeArguments(anIType, args) { // | Ok(_) => Ok(args->IEvArray) // | Error(T.TypeMismatch(anIType, evValue)) => // Error( -// ErrorValue.REExpectedType(anIType->T.toString, evValue->InternalExpressionValue.toString), +// ErrorValue.REExpectedType(anIType->T.toString, evValue->Reducer_Value.toString), // ) // } // | Error(error) => Error(error) // Directly propagating - err => err - causes type mismatch diff --git a/packages/squiggle-lang/src/rescript/ReducerInterface/ReducerInterface_InternalExpressionValue.res b/packages/squiggle-lang/src/rescript/Reducer/Reducer_Value.res similarity index 98% rename from packages/squiggle-lang/src/rescript/ReducerInterface/ReducerInterface_InternalExpressionValue.res rename to packages/squiggle-lang/src/rescript/Reducer/Reducer_Value.res index dd0d6e51..093dc196 100644 --- a/packages/squiggle-lang/src/rescript/ReducerInterface/ReducerInterface_InternalExpressionValue.res +++ b/packages/squiggle-lang/src/rescript/Reducer/Reducer_Value.res @@ -5,12 +5,8 @@ module ErrorValue = Reducer_ErrorValue type environment = GenericDist.env module T = Reducer_T -let defaultEnvironment: environment = DistributionOperation.defaultEnv - type t = Reducer_T.value -type internalExpressionValue = t - type functionCall = (string, array) let rec toString = (aValue: T.value) => diff --git a/packages/squiggle-lang/src/rescript/ReducerInterface/ReducerInterface.res b/packages/squiggle-lang/src/rescript/ReducerInterface/ReducerInterface.res deleted file mode 100644 index 5153e413..00000000 --- a/packages/squiggle-lang/src/rescript/ReducerInterface/ReducerInterface.res +++ /dev/null @@ -1,2 +0,0 @@ -module InternalExpressionValue = ReducerInterface_InternalExpressionValue -module StdLib = ReducerInterface_StdLib diff --git a/packages/squiggle-lang/src/rescript/ReducerProject/ReducerProject.res b/packages/squiggle-lang/src/rescript/ReducerProject/ReducerProject.res index 01996b32..1942a136 100644 --- a/packages/squiggle-lang/src/rescript/ReducerProject/ReducerProject.res +++ b/packages/squiggle-lang/src/rescript/ReducerProject/ReducerProject.res @@ -2,7 +2,6 @@ module Bindings = Reducer_Bindings module ErrorValue = Reducer_ErrorValue -module InternalExpressionValue = ReducerInterface_InternalExpressionValue module ProjectItem = ReducerProject_ProjectItem module T = ReducerProject_T module Topology = ReducerProject_Topology @@ -19,8 +18,8 @@ let getRunOrderFor = Topology.getRunOrderFor let createProject = () => { let project: t = { items: Belt.MutableMap.String.make(), - stdLib: ReducerInterface_StdLib.internalStdLib, - environment: InternalExpressionValue.defaultEnvironment, + stdLib: SquiggleLibrary_StdLib.stdLib, + environment: Reducer_Context.defaultEnvironment, previousRunOrder: [], } project @@ -143,8 +142,8 @@ let setStdLib = (project: t, value: Reducer_T.namespace): unit => { project.stdLib = value } -let getEnvironment = (project: t): InternalExpressionValue.environment => project.environment -let setEnvironment = (project: t, value: InternalExpressionValue.environment): unit => { +let getEnvironment = (project: t): Reducer_T.environment => project.environment +let setEnvironment = (project: t, value: Reducer_T.environment): unit => { project.environment = value } diff --git a/packages/squiggle-lang/src/rescript/ReducerProject/ReducerProject_ProjectAccessors_T.res b/packages/squiggle-lang/src/rescript/ReducerProject/ReducerProject_ProjectAccessors_T.res deleted file mode 100644 index 51fd41e3..00000000 --- a/packages/squiggle-lang/src/rescript/ReducerProject/ReducerProject_ProjectAccessors_T.res +++ /dev/null @@ -1,31 +0,0 @@ -// module ProjectItemT = ReducerProject_ProjectItem_T -// module InternalExpressionValue = ReducerInterface_InternalExpressionValue - -// type states = {mutable continuation: ProjectItemT.continuationArgumentType} - -// type projectAccessors = { -// stdLib: Reducer_Bindings.t, -// environment: Reducer_T.environment, -// states: states, -// } - -// type t = projectAccessors - -// let identityAccessors: t = { -// // We need the states at the end of the runtime. -// // Accessors can be modified but states will stay as the same pointer -// states: { -// continuation: Reducer_Bindings.emptyBindings, -// }, -// stdLib: ReducerInterface_StdLib.internalStdLib, -// environment: InternalExpressionValue.defaultEnvironment, -// } - -// // to support change of environment in runtime -// let setEnvironment = (this: t, environment: Reducer_T.environment): t => { -// { -// ...this, -// environment: environment, -// } -// } - diff --git a/packages/squiggle-lang/src/rescript/ReducerInterface/ReducerInterface_StdLib.res b/packages/squiggle-lang/src/rescript/SquiggleLibrary/SquiggleLibrary_StdLib.res similarity index 97% rename from packages/squiggle-lang/src/rescript/ReducerInterface/ReducerInterface_StdLib.res rename to packages/squiggle-lang/src/rescript/SquiggleLibrary/SquiggleLibrary_StdLib.res index f619d488..454983f7 100644 --- a/packages/squiggle-lang/src/rescript/ReducerInterface/ReducerInterface_StdLib.res +++ b/packages/squiggle-lang/src/rescript/SquiggleLibrary/SquiggleLibrary_StdLib.res @@ -1,6 +1,6 @@ exception ErrorException = Reducer_ErrorValue.ErrorException -let internalStdLib: Reducer_T.namespace = { +let stdLib: Reducer_T.namespace = { // constants let res = Reducer_Namespace.make() diff --git a/packages/squiggle-lang/src/rescript/TypescriptInterface.res b/packages/squiggle-lang/src/rescript/TypescriptInterface.res deleted file mode 100644 index fa537347..00000000 --- a/packages/squiggle-lang/src/rescript/TypescriptInterface.res +++ /dev/null @@ -1,58 +0,0 @@ -open ForTS__Types -/* -This is meant as a file to contain @genType declarations as needed for Typescript. -I would ultimately want to have all @genType declarations here, vs. other files, but -@genType doesn't play as nicely with renaming Modules and functions as -would be preferable. - -The below few seem to work fine. In the future there's definitely more work to do here. -*/ - -// For backwards compatibility: -//Alternatives if one wants to keep the old habits -@genType type samplingParams = environment -@genType type squiggleValue_Dist = squiggleValue_Distribution //alternative -@genType type genericDist = squiggleValue_Distribution //alternative -@genType type sampleSetDist = sampleSetDistribution //alternative -@genType type symbolicDist = symbolicDistribution //alternative -@genType type resultDist = result //alternative -@genType type resultFloat = result //alternative -@genType type resultString = result //alternative - -@genType -let makeSampleSetDist: array => result< - sampleSetDist, - SampleSetDist.sampleSetError, -> = SampleSetDist.make - -//TODO: ForTS Interface module candid -@genType -let toPointSet: ( - squiggleValue_Distribution, - ~xyPointLength: int, - ~sampleCount: int, - ~xSelection: DistributionTypes.DistributionOperation.pointsetXSelection=?, - unit, -) => result = GenericDist.toPointSet - -@genType -type mixedShape = PointSetTypes.mixedShape - -@genType -type discreteShape = PointSetTypes.discreteShape - -@genType -type continuousShape = PointSetTypes.continuousShape - -@genType -let distributionErrorToString = ForTS_Distribution_Error.toString - -@genType -let defaultSamplingEnv = ForTS_Distribution.defaultEnvironment - -// Umur: opaque types -// @genType -// type declarationArg = Declaration.arg - -// @genType -// type declaration<'a> = Declaration.declaration<'a>