From c1429e09078a8669b34ce55b61f94490d2fc1a29 Mon Sep 17 00:00:00 2001 From: Umur Ozkul Date: Mon, 18 Jul 2022 18:16:49 +0200 Subject: [PATCH] simplified modules --- .../Reducer_Peggy_ToExpression_test.res | 1 - .../Reducer_Type/Reducer_Type_Compile_test.res | 2 +- .../Reducer_Type_TypeChecker_arguments_test.res | 4 ++-- .../Reducer_Type/Reducer_Type_TypeChecker_test.res | 4 ++-- .../Reducer/Reducer_Bindings/Reducer_Bindings.res | 3 +++ .../Reducer/Reducer_Type/Reducer_Type_Compile.res | 12 ++++++++---- .../ReducerInterface_InternalExpressionValue.res | 2 +- 7 files changed, 17 insertions(+), 11 deletions(-) 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 74bf59e0..b8a81f25 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 @@ -3,7 +3,6 @@ module InternalExpressionValue = ReducerInterface_InternalExpressionValue open Jest open Reducer_Peggy_TestHelpers -open Expect describe("Peggy to Expression", () => { describe("literals operators parenthesis", () => { 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 3f97ca3f..4de688d1 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,6 +1,6 @@ module Expression = Reducer_Expression module InternalExpressionValue = ReducerInterface_InternalExpressionValue -module Module = Reducer_Module +module Bindings = Reducer_Bindings module T = Reducer_Type_T module TypeCompile = Reducer_Type_Compile 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 4f490bd5..9c23e38e 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 @@ -2,7 +2,7 @@ module Expression = Reducer_Expression module ExpressionT = Reducer_Expression_T module ErrorValue = Reducer_ErrorValue module InternalExpressionValue = ReducerInterface_InternalExpressionValue -module Module = Reducer_Module +module Bindings = Reducer_Bindings module T = Reducer_Type_T module TypeChecker = Reducer_Type_TypeChecker @@ -16,7 +16,7 @@ let checkArgumentsSourceCode = (aTypeSourceCode: string, sourceCode: string): re let reducerFn = Expression.reduceExpression let rResult = Reducer.parse(sourceCode)->Belt.Result.flatMap(expr => - reducerFn(expr, Module.emptyBindings, InternalExpressionValue.defaultEnvironment) + reducerFn(expr, Bindings.emptyBindings, InternalExpressionValue.defaultEnvironment) ) rResult->Belt.Result.flatMap(result => switch result { 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 5b093060..d845d550 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 @@ -2,7 +2,7 @@ module Expression = Reducer_Expression module ExpressionT = Reducer_Expression_T module ErrorValue = Reducer_ErrorValue module InternalExpressionValue = ReducerInterface_InternalExpressionValue -module Module = Reducer_Module +module Bindings = Reducer_Bindings module T = Reducer_Type_T module TypeChecker = Reducer_Type_TypeChecker @@ -19,7 +19,7 @@ let isTypeOfSourceCode = (aTypeSourceCode: string, sourceCode: string): result< let reducerFn = Expression.reduceExpression let rResult = Reducer.parse(sourceCode)->Belt.Result.flatMap(expr => - reducerFn(expr, Module.emptyBindings, InternalExpressionValue.defaultEnvironment) + reducerFn(expr, Bindings.emptyBindings, InternalExpressionValue.defaultEnvironment) ) rResult->Belt.Result.flatMap(result => TypeChecker.isTypeOf(aTypeSourceCode, result, reducerFn)) } diff --git a/packages/squiggle-lang/src/rescript/Reducer/Reducer_Bindings/Reducer_Bindings.res b/packages/squiggle-lang/src/rescript/Reducer/Reducer_Bindings/Reducer_Bindings.res index f02cd54f..28175d7a 100644 --- a/packages/squiggle-lang/src/rescript/Reducer/Reducer_Bindings/Reducer_Bindings.res +++ b/packages/squiggle-lang/src/rescript/Reducer/Reducer_Bindings/Reducer_Bindings.res @@ -1,3 +1,6 @@ +// Only Bindings as the global module is supported +// Other module operations such as import export will be prepreocessed jobs + module ExpressionT = Reducer_Expression_T module InternalExpressionValue = ReducerInterface_InternalExpressionValue open Reducer_ErrorValue 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 c7a776b7..2119ee62 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,7 +1,7 @@ module ErrorValue = Reducer_ErrorValue module ExpressionT = Reducer_Expression_T module InternalExpressionValue = ReducerInterface_InternalExpressionValue -module Module = Reducer_Module +module Bindings = Reducer_Bindings module T = Reducer_Type_T let ievFromTypeExpression = ( @@ -11,11 +11,15 @@ let ievFromTypeExpression = ( let sIndex = "compiled" let sourceCode = `type ${sIndex}=${typeExpressionSourceCode}` Reducer_Expression.parse(sourceCode)->Belt.Result.flatMap(expr => { - let rContext = reducerFn(expr, Module.emptyBindings, InternalExpressionValue.defaultEnvironment) + let rContext = reducerFn( + expr, + Bindings.emptyBindings, + InternalExpressionValue.defaultEnvironment, + ) Belt.Result.map(rContext, context => switch context { - | IEvModule(nameSpace) => - switch Module.getType(nameSpace, sIndex) { + | IEvBindings(nameSpace) => + switch Bindings.getType(nameSpace, sIndex) { | Some(value) => value | None => raise(Reducer_Exception.ImpossibleException("Reducer_Type_Compile-none")) } diff --git a/packages/squiggle-lang/src/rescript/ReducerInterface/ReducerInterface_InternalExpressionValue.res b/packages/squiggle-lang/src/rescript/ReducerInterface/ReducerInterface_InternalExpressionValue.res index 06ab2376..4523b02a 100644 --- a/packages/squiggle-lang/src/rescript/ReducerInterface/ReducerInterface_InternalExpressionValue.res +++ b/packages/squiggle-lang/src/rescript/ReducerInterface/ReducerInterface_InternalExpressionValue.res @@ -84,7 +84,7 @@ let toStringWithType = aValue => | IEvDeclaration(_) => `Declaration::${toString(aValue)}` | IEvDistribution(_) => `Distribution::${toString(aValue)}` | IEvLambda(_) => `Lambda::${toString(aValue)}` - | IEvBindings(_) => `Module::${toString(aValue)}` + | IEvBindings(_) => `Bindings::${toString(aValue)}` | IEvNumber(_) => `Number::${toString(aValue)}` | IEvRecord(_) => `Record::${toString(aValue)}` | IEvString(_) => `String::${toString(aValue)}`