From d7ed87556651b54a7db94396d916131171c05252 Mon Sep 17 00:00:00 2001 From: Umur Ozkul Date: Fri, 19 Aug 2022 21:12:04 +0200 Subject: [PATCH] demolish external value --- .../__tests__/Reducer/Reducer_Helpers.res | 1 - .../Reducer_MathJsEval_test.res | 2 +- .../ReducerInterface_ExpressionValue_test.res | 6 +- .../src/rescript/Reducer/Reducer.res | 17 --- .../src/rescript/Reducer/Reducer.resi | 45 ------- .../Reducer_Expression/Reducer_Expression.res | 2 - .../Reducer_Expression_BindingsReplacer.res | 1 - .../ReducerInterface/ReducerInterface.res | 1 - ...ducerInterface_ExternalExpressionValue.res | 111 ------------------ .../ReducerInterface_GenericDistribution.resi | 2 +- ...ducerInterface_InternalExpressionValue.res | 21 ---- .../ReducerProject_ProjectItem_T.res | 1 - 12 files changed, 5 insertions(+), 205 deletions(-) delete mode 100644 packages/squiggle-lang/src/rescript/Reducer/Reducer.res delete mode 100644 packages/squiggle-lang/src/rescript/Reducer/Reducer.resi delete mode 100644 packages/squiggle-lang/src/rescript/ReducerInterface/ReducerInterface_ExternalExpressionValue.res diff --git a/packages/squiggle-lang/__tests__/Reducer/Reducer_Helpers.res b/packages/squiggle-lang/__tests__/Reducer/Reducer_Helpers.res index 91bd5866..e915bfc1 100644 --- a/packages/squiggle-lang/__tests__/Reducer/Reducer_Helpers.res +++ b/packages/squiggle-lang/__tests__/Reducer/Reducer_Helpers.res @@ -1,6 +1,5 @@ // Reducer_Helpers module ErrorValue = Reducer_ErrorValue -module ExternalExpressionValue = ReducerInterface.ExternalExpressionValue module InternalExpressionValue = ReducerInterface.InternalExpressionValue module Bindings = Reducer_Bindings diff --git a/packages/squiggle-lang/__tests__/Reducer/Reducer_MathJs/Reducer_MathJsEval_test.res b/packages/squiggle-lang/__tests__/Reducer/Reducer_MathJs/Reducer_MathJsEval_test.res index ed00e957..e56c04d7 100644 --- a/packages/squiggle-lang/__tests__/Reducer/Reducer_MathJs/Reducer_MathJsEval_test.res +++ b/packages/squiggle-lang/__tests__/Reducer/Reducer_MathJs/Reducer_MathJsEval_test.res @@ -1,5 +1,5 @@ module MathJs = Reducer_MathJs -module ErrorValue = Reducer.ErrorValue +module ErrorValue = Reducer_ErrorValue open Jest open ExpectJs diff --git a/packages/squiggle-lang/__tests__/ReducerInterface/ReducerInterface_ExpressionValue_test.res b/packages/squiggle-lang/__tests__/ReducerInterface/ReducerInterface_ExpressionValue_test.res index b09e20ae..71fd9f61 100644 --- a/packages/squiggle-lang/__tests__/ReducerInterface/ReducerInterface_ExpressionValue_test.res +++ b/packages/squiggle-lang/__tests__/ReducerInterface/ReducerInterface_ExpressionValue_test.res @@ -1,11 +1,11 @@ -open ReducerInterface.ExternalExpressionValue +open ReducerInterface.InternalExpressionValue open Jest open Expect describe("ExpressionValue", () => { - test("argsToString", () => expect([EvNumber(1.), EvString("a")]->argsToString)->toBe("1,'a'")) + test("argsToString", () => expect([IEvNumber(1.), IEvString("a")]->argsToString)->toBe("1,'a'")) test("toStringFunctionCall", () => - expect(("fn", [EvNumber(1.), EvString("a")])->toStringFunctionCall)->toBe("fn(1,'a')") + expect(("fn", [IEvNumber(1.), IEvString("a")])->toStringFunctionCall)->toBe("fn(1,'a')") ) }) diff --git a/packages/squiggle-lang/src/rescript/Reducer/Reducer.res b/packages/squiggle-lang/src/rescript/Reducer/Reducer.res deleted file mode 100644 index ca0f63f3..00000000 --- a/packages/squiggle-lang/src/rescript/Reducer/Reducer.res +++ /dev/null @@ -1,17 +0,0 @@ -module ErrorValue = Reducer_ErrorValue -module Expression = Reducer_Expression -module ExternalExpressionValue = ReducerInterface_ExternalExpressionValue - -type environment = ReducerInterface_InternalExpressionValue.environment -type errorValue = Reducer_ErrorValue.errorValue -type expressionValue = ExternalExpressionValue.t -type externalBindings = ReducerInterface_ExternalExpressionValue.externalBindings -type lambdaValue = ExternalExpressionValue.lambdaValue - -/* - Use Reducer_Project instead -*/ - -let defaultEnvironment = ExternalExpressionValue.defaultEnvironment - -// let defaultExternalBindings = ReducerInterface_StdLib.externalStdLib diff --git a/packages/squiggle-lang/src/rescript/Reducer/Reducer.resi b/packages/squiggle-lang/src/rescript/Reducer/Reducer.resi deleted file mode 100644 index 8ac63abf..00000000 --- a/packages/squiggle-lang/src/rescript/Reducer/Reducer.resi +++ /dev/null @@ -1,45 +0,0 @@ -module ErrorValue = Reducer_ErrorValue -module Expression = Reducer_Expression - -@genType0 -type environment = ReducerInterface_ExternalExpressionValue.environment -@genType -type errorValue = Reducer_ErrorValue.errorValue -@genType -type expressionValue = ReducerInterface_ExternalExpressionValue.t -@genType -type externalBindings = ReducerInterface_ExternalExpressionValue.externalBindings -@genType -type lambdaValue = ReducerInterface_ExternalExpressionValue.lambdaValue - -// @genType -// let evaluateUsingOptions: ( -// ~environment: option, -// ~externalBindings: option< -// QuriSquiggleLang.ReducerInterface_ExternalExpressionValue.externalBindings, -// >, -// string, -// ) => result -// @genType -// let evaluatePartialUsingExternalBindings: ( -// string, -// QuriSquiggleLang.ReducerInterface_ExternalExpressionValue.externalBindings, -// QuriSquiggleLang.ReducerInterface_ExternalExpressionValue.environment, -// ) => result -// @genType -// let evaluate: string => result - -// let parse: string => result - -// @genType -// let foreignFunctionInterface: ( -// QuriSquiggleLang.ReducerInterface_ExternalExpressionValue.lambdaValue, -// array, -// QuriSquiggleLang.ReducerInterface_ExternalExpressionValue.environment, -// ) => result - -@genType -let defaultEnvironment: environment - -// @genType -// let defaultExternalBindings: externalBindings 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 d350ad74..f2b05036 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 @@ -2,7 +2,6 @@ module Bindings = Reducer_Bindings module BindingsReplacer = Reducer_Expression_BindingsReplacer module BuiltIn = Reducer_Dispatch_BuiltIn module ExpressionBuilder = Reducer_Expression_ExpressionBuilder -module ExternalExpressionValue = ReducerInterface_ExternalExpressionValue module Extra = Reducer_Extra module InternalExpressionValue = ReducerInterface_InternalExpressionValue module Lambda = Reducer_Expression_Lambda @@ -13,7 +12,6 @@ module Result = Belt.Result module T = Reducer_Expression_T type errorValue = Reducer_ErrorValue.errorValue -type externalExpressionValue = ReducerInterface_ExternalExpressionValue.t type t = T.t /* diff --git a/packages/squiggle-lang/src/rescript/Reducer/Reducer_Expression/Reducer_Expression_BindingsReplacer.res b/packages/squiggle-lang/src/rescript/Reducer/Reducer_Expression/Reducer_Expression_BindingsReplacer.res index 15ecfe58..6e38f833 100644 --- a/packages/squiggle-lang/src/rescript/Reducer/Reducer_Expression/Reducer_Expression_BindingsReplacer.res +++ b/packages/squiggle-lang/src/rescript/Reducer/Reducer_Expression/Reducer_Expression_BindingsReplacer.res @@ -7,7 +7,6 @@ module Bindings = Reducer_Bindings type errorValue = Reducer_ErrorValue.errorValue type expression = ExpressionT.expression type internalExpressionValue = InternalExpressionValue.t -type externalBindings = ReducerInterface_ExternalExpressionValue.externalBindings let isMacroName = (fName: string): bool => fName->Js.String2.startsWith("$$") diff --git a/packages/squiggle-lang/src/rescript/ReducerInterface/ReducerInterface.res b/packages/squiggle-lang/src/rescript/ReducerInterface/ReducerInterface.res index ef27130b..d19b93b3 100644 --- a/packages/squiggle-lang/src/rescript/ReducerInterface/ReducerInterface.res +++ b/packages/squiggle-lang/src/rescript/ReducerInterface/ReducerInterface.res @@ -1,4 +1,3 @@ -module ExternalExpressionValue = ReducerInterface_ExternalExpressionValue module ExternalLibrary = ReducerInterface_ExternalLibrary module InternalExpressionValue = ReducerInterface_InternalExpressionValue module StdLib = ReducerInterface_StdLib diff --git a/packages/squiggle-lang/src/rescript/ReducerInterface/ReducerInterface_ExternalExpressionValue.res b/packages/squiggle-lang/src/rescript/ReducerInterface/ReducerInterface_ExternalExpressionValue.res deleted file mode 100644 index f3ecb0f4..00000000 --- a/packages/squiggle-lang/src/rescript/ReducerInterface/ReducerInterface_ExternalExpressionValue.res +++ /dev/null @@ -1,111 +0,0 @@ -/* - Irreducible values. Reducer does not know about those. Only used for external calls - This is a configuration to to make external calls of those types -*/ -module Extra_Array = Reducer_Extra_Array -module ErrorValue = Reducer_ErrorValue -@genType.opaque -type internalCode = Object - -@genType.opaque -type hiddenNameSpace = Object - -@genType -type rec externalExpressionValue = - | EvArray(array) - | EvArrayString(array) - | EvBool(bool) - | EvCall(string) // External function call - | EvDate(Js.Date.t) - | EvDeclaration(lambdaDeclaration) - | EvDistribution(DistributionTypes.genericDist) - | EvLambda(lambdaValue) - | EvModule(record) - | EvNumber(float) - | EvRecord(record) - | EvString(string) - | EvSymbol(string) - | EvTimeDuration(float) - | EvType(record) - | EvTypeIdentifier(string) - | EvVoid -and record = Js.Dict.t -and lambdaValue = { - parameters: array, - context: hiddenNameSpace, - body: internalCode, -} -and lambdaDeclaration = Declaration.declaration - -@genType -type externalBindings = record - -@genType -type t = externalExpressionValue - -type functionCall = (string, array) - -let rec toString = aValue => - switch aValue { - | EvArray(anArray) => { - let args = anArray->Js.Array2.map(each => toString(each))->Js.Array2.toString - `[${args}]` - } - | EvArrayString(anArray) => { - let args = anArray->Js.Array2.toString - `[${args}]` - } - | EvBool(aBool) => Js.String.make(aBool) - | EvCall(fName) => `:${fName}` - | EvDate(date) => DateTime.Date.toString(date) - | EvDeclaration(d) => Declaration.toString(d, r => toString(EvLambda(r))) - | EvDistribution(dist) => GenericDist.toString(dist) - | EvLambda(lambdaValue) => `lambda(${Js.Array2.toString(lambdaValue.parameters)}=>internal code)` - | EvModule(m) => `@${m->toStringRecord}` - | EvNumber(aNumber) => Js.String.make(aNumber) - | EvRecord(aRecord) => aRecord->toStringRecord - | EvString(aString) => `'${aString}'` - | EvSymbol(aString) => `:${aString}` - | EvTimeDuration(t) => DateTime.Duration.toString(t) - | EvType(t) => `type${t->toStringRecord}` - | EvTypeIdentifier(id) => `#${id}` - | EvVoid => `()` - } -and toStringRecord = aRecord => { - let pairs = - aRecord - ->Js.Dict.entries - ->Js.Array2.map(((eachKey, eachValue)) => `${eachKey}: ${toString(eachValue)}`) - ->Js.Array2.toString - `{${pairs}}` -} - -let argsToString = (args: array): string => { - args->Js.Array2.map(arg => arg->toString)->Js.Array2.toString -} - -let toStringFunctionCall = ((fn, args)): string => `${fn}(${argsToString(args)})` - -let toStringResult = x => - switch x { - | Ok(a) => `Ok(${toString(a)})` - | Error(m) => `Error(${ErrorValue.errorToString(m)})` - } - -let toStringOptionResult = x => - switch x { - | Some(a) => toStringResult(a) - | None => `None` - } - -let toStringOption = x => - switch x { - | Some(a) => toString(a) - | None => `None` - } - -@genType -type environment = GenericDist.env - -@genType -let defaultEnvironment: environment = DistributionOperation.defaultEnv diff --git a/packages/squiggle-lang/src/rescript/ReducerInterface/ReducerInterface_GenericDistribution.resi b/packages/squiggle-lang/src/rescript/ReducerInterface/ReducerInterface_GenericDistribution.resi index 6cccdf17..4cf8a17d 100644 --- a/packages/squiggle-lang/src/rescript/ReducerInterface/ReducerInterface_GenericDistribution.resi +++ b/packages/squiggle-lang/src/rescript/ReducerInterface/ReducerInterface_GenericDistribution.resi @@ -1,4 +1,4 @@ let dispatch: ( ReducerInterface_InternalExpressionValue.functionCall, - ReducerInterface_ExternalExpressionValue.environment, + ReducerInterface_InternalExpressionValue.environment, ) => option> diff --git a/packages/squiggle-lang/src/rescript/ReducerInterface/ReducerInterface_InternalExpressionValue.res b/packages/squiggle-lang/src/rescript/ReducerInterface/ReducerInterface_InternalExpressionValue.res index 2f0dd7df..9d47c741 100644 --- a/packages/squiggle-lang/src/rescript/ReducerInterface/ReducerInterface_InternalExpressionValue.res +++ b/packages/squiggle-lang/src/rescript/ReducerInterface/ReducerInterface_InternalExpressionValue.res @@ -172,27 +172,6 @@ let valueToValueType = value => | IEvVoid => EvtVoid } -let externalValueToValueType = (value: ReducerInterface_ExternalExpressionValue.t) => - switch value { - | EvArray(_) => EvtArray - | EvArrayString(_) => EvtArrayString - | EvBool(_) => EvtBool - | EvCall(_) => EvtCall - | EvDate(_) => EvtDate - | EvDeclaration(_) => EvtDeclaration - | EvDistribution(_) => EvtDistribution - | EvLambda(_) => EvtLambda - | EvModule(_) => EvtModule - | EvNumber(_) => EvtNumber - | EvRecord(_) => EvtRecord - | EvString(_) => EvtString - | EvSymbol(_) => EvtSymbol - | EvTimeDuration(_) => EvtTimeDuration - | EvType(_) => EvtType - | EvTypeIdentifier(_) => EvtTypeIdentifier - | EvVoid => EvtVoid - } - let functionCallToCallSignature = (functionCall: functionCall): functionCallSignature => { let (fn, args) = functionCall CallSignature(fn, args->Js.Array2.map(valueToValueType)) diff --git a/packages/squiggle-lang/src/rescript/ReducerProject/ReducerProject_ProjectItem_T.res b/packages/squiggle-lang/src/rescript/ReducerProject/ReducerProject_ProjectItem_T.res index 13505fea..6fe251d2 100644 --- a/packages/squiggle-lang/src/rescript/ReducerProject/ReducerProject_ProjectItem_T.res +++ b/packages/squiggle-lang/src/rescript/ReducerProject/ReducerProject_ProjectItem_T.res @@ -1,7 +1,6 @@ module Parse = Reducer_Peggy_Parse module ExpressionT = Reducer_Expression_T module InternalExpressionValue = ReducerInterface_InternalExpressionValue -module ExternalExpressionValue = ReducerInterface_ExternalExpressionValue open Reducer_ErrorValue type sourceArgumentType = string