From fdc7f06f082f3bc2685f53fbc5e5164a0e04bb9a Mon Sep 17 00:00:00 2001 From: Umur Ozkul Date: Thu, 18 Aug 2022 15:32:26 +0200 Subject: [PATCH] result --- .../ForTS_InternalValue.res | 2 +- .../ForTS_InternalValue_RecordLike.res | 2 +- .../ForTS_InternalValue_Void.res | 2 +- .../ForTS/ForTS_MyProject.res | 2 +- .../ForTS/ForTS_Result_.res | 18 ++++++++ .../{ForTS_Types.res => ForTS_Types_.res} | 2 +- .../ForTS/ForTS_Reducer_ErrorValue.res | 0 .../ForTS/ForTS_Result.res | 2 +- .../rescript/ForTS/ForTS_SquiggleProject.res | 1 + .../rescript/ForTS/ForTS_SquiggleValue.res | 1 + .../ForTS_SquiggleValue_Array.res | 1 + .../ForTS_SquiggleValue_ArrayString.res | 1 + .../ForTS_SquiggleValue_Date.res | 1 + .../ForTS_SquiggleValue_Declaration.res | 1 + .../ForTS_SquiggleValue_Distribution.res | 1 + .../ForTS_SquiggleValue_Lambda.res | 1 + .../ForTS_SquiggleValue_Record.res | 1 + .../ForTS_SquiggleValue_TimeDuration.res | 1 + .../ForTS_SquiggleValue_Type.res | 1 + .../ForTS_SquiggleValue_Void.res | 1 + .../rescript/ForTS/ForTS_SquiggleValue_tag.ts | 19 +++++++++ .../src/rescript/ForTS/ForTS__Functions.res | 0 .../src/rescript/ForTS/ForTS__Types.res | 20 +++++++++ .../rescript/Reducer/Reducer_ErrorValue.res | 3 +- .../Reducer_Peggy/Reducer_Peggy_Parse.res | 1 - .../ReducerProject/ReducerProject.res | 26 ------------ .../src/rescript/TypescriptInterface.res | 42 ------------------- 27 files changed, 76 insertions(+), 77 deletions(-) create mode 100644 packages/squiggle-lang/src/rescript/Dummy-TypeScriptingRescript/ForTS/ForTS_Result_.res rename packages/squiggle-lang/src/rescript/Dummy-TypeScriptingRescript/ForTS/{ForTS_Types.res => ForTS_Types_.res} (80%) create mode 100644 packages/squiggle-lang/src/rescript/ForTS/ForTS_Reducer_ErrorValue.res rename packages/squiggle-lang/src/rescript/{Dummy-TypeScriptingRescript => }/ForTS/ForTS_Result.res (95%) create mode 100644 packages/squiggle-lang/src/rescript/ForTS/ForTS_SquiggleProject.res create mode 100644 packages/squiggle-lang/src/rescript/ForTS/ForTS_SquiggleValue.res create mode 100644 packages/squiggle-lang/src/rescript/ForTS/ForTS_SquiggleValue/ForTS_SquiggleValue_Array.res create mode 100644 packages/squiggle-lang/src/rescript/ForTS/ForTS_SquiggleValue/ForTS_SquiggleValue_ArrayString.res create mode 100644 packages/squiggle-lang/src/rescript/ForTS/ForTS_SquiggleValue/ForTS_SquiggleValue_Date.res create mode 100644 packages/squiggle-lang/src/rescript/ForTS/ForTS_SquiggleValue/ForTS_SquiggleValue_Declaration.res create mode 100644 packages/squiggle-lang/src/rescript/ForTS/ForTS_SquiggleValue/ForTS_SquiggleValue_Distribution.res create mode 100644 packages/squiggle-lang/src/rescript/ForTS/ForTS_SquiggleValue/ForTS_SquiggleValue_Lambda.res create mode 100644 packages/squiggle-lang/src/rescript/ForTS/ForTS_SquiggleValue/ForTS_SquiggleValue_Record.res create mode 100644 packages/squiggle-lang/src/rescript/ForTS/ForTS_SquiggleValue/ForTS_SquiggleValue_TimeDuration.res create mode 100644 packages/squiggle-lang/src/rescript/ForTS/ForTS_SquiggleValue/ForTS_SquiggleValue_Type.res create mode 100644 packages/squiggle-lang/src/rescript/ForTS/ForTS_SquiggleValue/ForTS_SquiggleValue_Void.res create mode 100644 packages/squiggle-lang/src/rescript/ForTS/ForTS_SquiggleValue_tag.ts create mode 100644 packages/squiggle-lang/src/rescript/ForTS/ForTS__Functions.res create mode 100644 packages/squiggle-lang/src/rescript/ForTS/ForTS__Types.res diff --git a/packages/squiggle-lang/src/rescript/Dummy-TypeScriptingRescript/ForTS/ForTS_InternalValue/ForTS_InternalValue.res b/packages/squiggle-lang/src/rescript/Dummy-TypeScriptingRescript/ForTS/ForTS_InternalValue/ForTS_InternalValue.res index c85474da..783f97ec 100644 --- a/packages/squiggle-lang/src/rescript/Dummy-TypeScriptingRescript/ForTS/ForTS_InternalValue/ForTS_InternalValue.res +++ b/packages/squiggle-lang/src/rescript/Dummy-TypeScriptingRescript/ForTS/ForTS_InternalValue/ForTS_InternalValue.res @@ -1,4 +1,4 @@ -open ForTS_Types +open ForTS_Types_ @module("ForTS_InternalValue_tag") @scope("InternalValueTag") external ivtVoid_: int = "IvtVoid" diff --git a/packages/squiggle-lang/src/rescript/Dummy-TypeScriptingRescript/ForTS/ForTS_InternalValue/ForTS_InternalValue_RecordLike.res b/packages/squiggle-lang/src/rescript/Dummy-TypeScriptingRescript/ForTS/ForTS_InternalValue/ForTS_InternalValue_RecordLike.res index 630cd72e..7a28ea75 100644 --- a/packages/squiggle-lang/src/rescript/Dummy-TypeScriptingRescript/ForTS/ForTS_InternalValue/ForTS_InternalValue_RecordLike.res +++ b/packages/squiggle-lang/src/rescript/Dummy-TypeScriptingRescript/ForTS/ForTS_InternalValue/ForTS_InternalValue_RecordLike.res @@ -1,4 +1,4 @@ -open ForTS_Types +open ForTS_Types_ @genType let toString = (v: recordLike): string => diff --git a/packages/squiggle-lang/src/rescript/Dummy-TypeScriptingRescript/ForTS/ForTS_InternalValue/ForTS_InternalValue_Void.res b/packages/squiggle-lang/src/rescript/Dummy-TypeScriptingRescript/ForTS/ForTS_InternalValue/ForTS_InternalValue_Void.res index 7b5b85e6..7fae9341 100644 --- a/packages/squiggle-lang/src/rescript/Dummy-TypeScriptingRescript/ForTS/ForTS_InternalValue/ForTS_InternalValue_Void.res +++ b/packages/squiggle-lang/src/rescript/Dummy-TypeScriptingRescript/ForTS/ForTS_InternalValue/ForTS_InternalValue_Void.res @@ -1,3 +1,3 @@ -open ForTS_Types +open ForTS_Types_ @genType let toString = (_value: internalVoid): string => MyInterface_InternalValue_Void.toString diff --git a/packages/squiggle-lang/src/rescript/Dummy-TypeScriptingRescript/ForTS/ForTS_MyProject.res b/packages/squiggle-lang/src/rescript/Dummy-TypeScriptingRescript/ForTS/ForTS_MyProject.res index c275b71a..23550d16 100644 --- a/packages/squiggle-lang/src/rescript/Dummy-TypeScriptingRescript/ForTS/ForTS_MyProject.res +++ b/packages/squiggle-lang/src/rescript/Dummy-TypeScriptingRescript/ForTS/ForTS_MyProject.res @@ -1,4 +1,4 @@ -open ForTS_Types +open ForTS_Types_ @genType let getResult = (_p: myProject): option> => diff --git a/packages/squiggle-lang/src/rescript/Dummy-TypeScriptingRescript/ForTS/ForTS_Result_.res b/packages/squiggle-lang/src/rescript/Dummy-TypeScriptingRescript/ForTS/ForTS_Result_.res new file mode 100644 index 00000000..f29b1657 --- /dev/null +++ b/packages/squiggle-lang/src/rescript/Dummy-TypeScriptingRescript/ForTS/ForTS_Result_.res @@ -0,0 +1,18 @@ +open ForTS_Types_ + +@genType let isError = (r: result_<'a, 'e>): bool => Belt.Result.isError(r) +@genType let isOk = (r: result_<'a, 'e>): bool => Belt.Result.isOk(r) + +@genType +let getError = (r: result_<'a, 'e>): option<'e> => + switch r { + | Ok(_) => None + | Error(e) => Some(e) + } + +@genType +let getValue = (r: result_<'a, 'e>): option<'a> => + switch r { + | Ok(v) => Some(v) + | Error(_) => None + } diff --git a/packages/squiggle-lang/src/rescript/Dummy-TypeScriptingRescript/ForTS/ForTS_Types.res b/packages/squiggle-lang/src/rescript/Dummy-TypeScriptingRescript/ForTS/ForTS_Types_.res similarity index 80% rename from packages/squiggle-lang/src/rescript/Dummy-TypeScriptingRescript/ForTS/ForTS_Types.res rename to packages/squiggle-lang/src/rescript/Dummy-TypeScriptingRescript/ForTS/ForTS_Types_.res index 7efcc47d..980c90bd 100644 --- a/packages/squiggle-lang/src/rescript/Dummy-TypeScriptingRescript/ForTS/ForTS_Types.res +++ b/packages/squiggle-lang/src/rescript/Dummy-TypeScriptingRescript/ForTS/ForTS_Types_.res @@ -6,7 +6,7 @@ @genType.opaque type recordLike = MyInterface_InternalValue_RecordLike.t @genType.opaque type internalVoid = int @genType.opaque type errorValue = My_ErrorValue.t -@genType.opaque type result_<'a, 'e> = result<'a, 'e> // There has to be a type for each result permutation +@genType.opaque type result_<'a, 'e> = result<'a, 'e> @genType.opaque type myProject = {name: string} //There is no need to map option<> as it becomes nullable diff --git a/packages/squiggle-lang/src/rescript/ForTS/ForTS_Reducer_ErrorValue.res b/packages/squiggle-lang/src/rescript/ForTS/ForTS_Reducer_ErrorValue.res new file mode 100644 index 00000000..e69de29b diff --git a/packages/squiggle-lang/src/rescript/Dummy-TypeScriptingRescript/ForTS/ForTS_Result.res b/packages/squiggle-lang/src/rescript/ForTS/ForTS_Result.res similarity index 95% rename from packages/squiggle-lang/src/rescript/Dummy-TypeScriptingRescript/ForTS/ForTS_Result.res rename to packages/squiggle-lang/src/rescript/ForTS/ForTS_Result.res index 407c4a2c..19bf6ee0 100644 --- a/packages/squiggle-lang/src/rescript/Dummy-TypeScriptingRescript/ForTS/ForTS_Result.res +++ b/packages/squiggle-lang/src/rescript/ForTS/ForTS_Result.res @@ -1,4 +1,4 @@ -open ForTS_Types +open ForTS__Types @genType let isError = (r: result_<'a, 'e>): bool => Belt.Result.isError(r) @genType let isOk = (r: result_<'a, 'e>): bool => Belt.Result.isOk(r) diff --git a/packages/squiggle-lang/src/rescript/ForTS/ForTS_SquiggleProject.res b/packages/squiggle-lang/src/rescript/ForTS/ForTS_SquiggleProject.res new file mode 100644 index 00000000..80c79902 --- /dev/null +++ b/packages/squiggle-lang/src/rescript/ForTS/ForTS_SquiggleProject.res @@ -0,0 +1 @@ +open ForTS__Types \ No newline at end of file diff --git a/packages/squiggle-lang/src/rescript/ForTS/ForTS_SquiggleValue.res b/packages/squiggle-lang/src/rescript/ForTS/ForTS_SquiggleValue.res new file mode 100644 index 00000000..80c79902 --- /dev/null +++ b/packages/squiggle-lang/src/rescript/ForTS/ForTS_SquiggleValue.res @@ -0,0 +1 @@ +open ForTS__Types \ No newline at end of file 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 new file mode 100644 index 00000000..80c79902 --- /dev/null +++ b/packages/squiggle-lang/src/rescript/ForTS/ForTS_SquiggleValue/ForTS_SquiggleValue_Array.res @@ -0,0 +1 @@ +open ForTS__Types \ No newline at end of file diff --git a/packages/squiggle-lang/src/rescript/ForTS/ForTS_SquiggleValue/ForTS_SquiggleValue_ArrayString.res b/packages/squiggle-lang/src/rescript/ForTS/ForTS_SquiggleValue/ForTS_SquiggleValue_ArrayString.res new file mode 100644 index 00000000..80c79902 --- /dev/null +++ b/packages/squiggle-lang/src/rescript/ForTS/ForTS_SquiggleValue/ForTS_SquiggleValue_ArrayString.res @@ -0,0 +1 @@ +open ForTS__Types \ No newline at end of file diff --git a/packages/squiggle-lang/src/rescript/ForTS/ForTS_SquiggleValue/ForTS_SquiggleValue_Date.res b/packages/squiggle-lang/src/rescript/ForTS/ForTS_SquiggleValue/ForTS_SquiggleValue_Date.res new file mode 100644 index 00000000..80c79902 --- /dev/null +++ b/packages/squiggle-lang/src/rescript/ForTS/ForTS_SquiggleValue/ForTS_SquiggleValue_Date.res @@ -0,0 +1 @@ +open ForTS__Types \ No newline at end of file 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 new file mode 100644 index 00000000..80c79902 --- /dev/null +++ b/packages/squiggle-lang/src/rescript/ForTS/ForTS_SquiggleValue/ForTS_SquiggleValue_Declaration.res @@ -0,0 +1 @@ +open ForTS__Types \ No newline at end of file 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 new file mode 100644 index 00000000..80c79902 --- /dev/null +++ b/packages/squiggle-lang/src/rescript/ForTS/ForTS_SquiggleValue/ForTS_SquiggleValue_Distribution.res @@ -0,0 +1 @@ +open ForTS__Types \ No newline at end of file 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 new file mode 100644 index 00000000..80c79902 --- /dev/null +++ b/packages/squiggle-lang/src/rescript/ForTS/ForTS_SquiggleValue/ForTS_SquiggleValue_Lambda.res @@ -0,0 +1 @@ +open ForTS__Types \ No newline at end of file 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 new file mode 100644 index 00000000..80c79902 --- /dev/null +++ b/packages/squiggle-lang/src/rescript/ForTS/ForTS_SquiggleValue/ForTS_SquiggleValue_Record.res @@ -0,0 +1 @@ +open ForTS__Types \ No newline at end of file diff --git a/packages/squiggle-lang/src/rescript/ForTS/ForTS_SquiggleValue/ForTS_SquiggleValue_TimeDuration.res b/packages/squiggle-lang/src/rescript/ForTS/ForTS_SquiggleValue/ForTS_SquiggleValue_TimeDuration.res new file mode 100644 index 00000000..80c79902 --- /dev/null +++ b/packages/squiggle-lang/src/rescript/ForTS/ForTS_SquiggleValue/ForTS_SquiggleValue_TimeDuration.res @@ -0,0 +1 @@ +open ForTS__Types \ No newline at end of file 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 new file mode 100644 index 00000000..80c79902 --- /dev/null +++ b/packages/squiggle-lang/src/rescript/ForTS/ForTS_SquiggleValue/ForTS_SquiggleValue_Type.res @@ -0,0 +1 @@ +open ForTS__Types \ No newline at end of file diff --git a/packages/squiggle-lang/src/rescript/ForTS/ForTS_SquiggleValue/ForTS_SquiggleValue_Void.res b/packages/squiggle-lang/src/rescript/ForTS/ForTS_SquiggleValue/ForTS_SquiggleValue_Void.res new file mode 100644 index 00000000..80c79902 --- /dev/null +++ b/packages/squiggle-lang/src/rescript/ForTS/ForTS_SquiggleValue/ForTS_SquiggleValue_Void.res @@ -0,0 +1 @@ +open ForTS__Types \ No newline at end of file diff --git a/packages/squiggle-lang/src/rescript/ForTS/ForTS_SquiggleValue_tag.ts b/packages/squiggle-lang/src/rescript/ForTS/ForTS_SquiggleValue_tag.ts new file mode 100644 index 00000000..afa4a4ba --- /dev/null +++ b/packages/squiggle-lang/src/rescript/ForTS/ForTS_SquiggleValue_tag.ts @@ -0,0 +1,19 @@ +enum SquiggleValueTag { + SvtArray, + SvtArrayString, + SvtBool, + SvtCall, + SvtDate, + SvtDeclaration, + SvtDistribution + SvtLambda, + SvtModule, + SvtNumber, + SvtRecord, + SvtString, + SvtSymbol, + SvtTimeDuration, + SvtType, + SvtTypeIdentifier, + SvtVoid, +} \ No newline at end of file diff --git a/packages/squiggle-lang/src/rescript/ForTS/ForTS__Functions.res b/packages/squiggle-lang/src/rescript/ForTS/ForTS__Functions.res new file mode 100644 index 00000000..e69de29b diff --git a/packages/squiggle-lang/src/rescript/ForTS/ForTS__Types.res b/packages/squiggle-lang/src/rescript/ForTS/ForTS__Types.res new file mode 100644 index 00000000..71bd56c2 --- /dev/null +++ b/packages/squiggle-lang/src/rescript/ForTS/ForTS__Types.res @@ -0,0 +1,20 @@ +/* +The reason this is not ExpressionValue is that ExpressionValue is becoming a parametric type +to allow expressions for different domains. +So we rename it right away not cause a compatibility problem +*/ +@genType.opaque type result_<'a, 'e> = result<'a, 'e> + +@genType.opaque type squiggleValue +@genType.opaque type squiggleValue_Array +@genType.opaque type squiggleValue_ArrayString +@genType.opaque type squiggleValue_Date +@genType.opaque type squiggleValue_Declaration +@genType.opaque type squiggleValue_Distribution +@genType.opaque type squiggleValue_Lambda +@genType.opaque type squiggleValue_Record +@genType.opaque type squiggleValue_TimeDuration +@genType.opaque type squiggleValue_Type +@genType.opaque type squiggleValue_Void +@genType.opaque type reducer_errorValue + diff --git a/packages/squiggle-lang/src/rescript/Reducer/Reducer_ErrorValue.res b/packages/squiggle-lang/src/rescript/Reducer/Reducer_ErrorValue.res index d908bf93..de1dd93f 100644 --- a/packages/squiggle-lang/src/rescript/Reducer/Reducer_ErrorValue.res +++ b/packages/squiggle-lang/src/rescript/Reducer/Reducer_ErrorValue.res @@ -1,7 +1,7 @@ +//FIXME: Move this under ForTS @gentype.import("peggy") @genType.as("LocationRange") type location -@genType type errorValue = | REArityError(option, int, int) | REArrayIndexNotFound(string, int) @@ -23,7 +23,6 @@ type errorValue = type t = errorValue -@genType let errorToString = err => switch err { | REArityError(_oFnName, arity, usedArity) => diff --git a/packages/squiggle-lang/src/rescript/Reducer/Reducer_Peggy/Reducer_Peggy_Parse.res b/packages/squiggle-lang/src/rescript/Reducer/Reducer_Peggy/Reducer_Peggy_Parse.res index 193cb893..59002761 100644 --- a/packages/squiggle-lang/src/rescript/Reducer/Reducer_Peggy/Reducer_Peggy_Parse.res +++ b/packages/squiggle-lang/src/rescript/Reducer/Reducer_Peggy/Reducer_Peggy_Parse.res @@ -11,7 +11,6 @@ external castWithLocation: Js.Exn.t => withLocation = "%identity" let syntaxErrorToLocation = (error: Js.Exn.t): Reducer_ErrorValue.location => castWithLocation(error)["location"] -@genType let parse = (expr: string): result => try { Ok(parse__(expr)) diff --git a/packages/squiggle-lang/src/rescript/ReducerProject/ReducerProject.res b/packages/squiggle-lang/src/rescript/ReducerProject/ReducerProject.res index 5ed0858b..ba6e8bb0 100644 --- a/packages/squiggle-lang/src/rescript/ReducerProject/ReducerProject.res +++ b/packages/squiggle-lang/src/rescript/ReducerProject/ReducerProject.res @@ -10,7 +10,6 @@ module ProjectItem = ReducerProject_ProjectItem module T = ReducerProject_T module Topology = ReducerProject_Topology -@genType.opaque type reducerProject = T.t type t = T.t @@ -232,34 +231,29 @@ To run a group of source codes and get results/bindings, the necessary methods a A project has a public field tag with a constant value "reducerProject" project = {tag: "reducerProject"} */ -@genType let createProject = (): reducerProject => Private.createProject()->T.Private.castFromInternalProject /* Answer all the source ids of all the sources in the project. */ -@genType let getSourceIds = (project: reducerProject): array => project->T.Private.castToInternalProject->Private.getSourceIds /* Sets the source for a given source Id. */ -@genType let setSource = (project: reducerProject, sourceId: string, value: string): unit => project->T.Private.castToInternalProject->Private.setSource(sourceId, value) /* Gets the source for a given source id. */ -@genType let getSource = (project: reducerProject, sourceId: string): option => project->T.Private.castToInternalProject->Private.getSource(sourceId) /* Touches the source for a given source id. This and dependent, sources are set to be re-evaluated. */ -@genType let touchSource = (project: reducerProject, sourceId: string): unit => project->T.Private.castToInternalProject->Private.touchSource(sourceId) @@ -268,14 +262,12 @@ Cleans the compilation artifacts for a given source ID. The results stay untouch Normally, you would never need the compilation artifacts again as the results with the same sources would never change. However, they are needed in case of any debugging reruns */ -@genType let clean = (project: reducerProject, sourceId: string): unit => project->T.Private.castToInternalProject->Private.clean(sourceId) /* Cleans all the compilation artifacts in all of the project */ -@genType let cleanAll = (project: reducerProject): unit => project->T.Private.castToInternalProject->Private.cleanAll @@ -283,21 +275,18 @@ let cleanAll = (project: reducerProject): unit => Cleans results. Compilation stays untouched to be able to re-run the source. You would not do this if you were not trying to debug the source code. */ -@genType let cleanResults = (project: reducerProject, sourceId: string): unit => project->T.Private.castToInternalProject->Private.cleanResults(sourceId) /* Cleans all results. Compilations remains untouched to rerun the source. */ -@genType let cleanAllResults = (project: reducerProject): unit => project->T.Private.castToInternalProject->Private.cleanAllResults /* To set the includes one first has to call "parseIncludes". The parsed includes or the parser error is returned. */ -@genType let getIncludes = (project: reducerProject, sourceId: string): result< array, Reducer_ErrorValue.errorValue, @@ -306,7 +295,6 @@ let getIncludes = (project: reducerProject, sourceId: string): result< /* Answers the source codes after which this source code is continuing */ -@genType let getContinues = (project: reducerProject, sourceId: string): array => project->T.Private.castToInternalProject->Private.getContinues(sourceId) @@ -315,35 +303,30 @@ let getContinues = (project: reducerProject, sourceId: string): array => It is used to define a continuation that is not visible in the source code. You can chain source codes on the web interface for example */ -@genType let setContinues = (project: reducerProject, sourceId: string, continues: array): unit => project->T.Private.castToInternalProject->Private.setContinues(sourceId, continues) /* This source depends on the array of sources returned. */ -@genType let getDependencies = (project: reducerProject, sourceId: string): array => project->T.Private.castToInternalProject->Private.getDependencies(sourceId) /* The sources returned are dependent on this */ -@genType let getDependents = (project: reducerProject, sourceId: string): array => project->T.Private.castToInternalProject->Private.getDependents(sourceId) /* Get the run order for the sources in the project. */ -@genType let getRunOrder = (project: reducerProject): array => project->T.Private.castToInternalProject->Private.getRunOrder /* Get the run order to get the results of this specific source */ -@genType let getRunOrderFor = (project: reducerProject, sourceId: string) => project->T.Private.castToInternalProject->Private.getRunOrderFor(sourceId) @@ -352,7 +335,6 @@ Parse includes so that you can load them before running. Load includes by calling getIncludes which returns the includes that have been parsed. It is your responsibility to load the includes before running. */ -@genType let parseIncludes = (project: reducerProject, sourceId: string): unit => project->T.Private.castToInternalProject->Private.parseIncludes(sourceId) @@ -361,28 +343,24 @@ Parse the source code if it is not done already. Use getRawParse to get the parse tree. You would need this function if you want to see the parse tree without running the source code. */ -@genType let rawParse = (project: reducerProject, sourceId: string): unit => project->T.Private.castToInternalProject->Private.rawParse(sourceId) /* Runs a specific source code if it is not done already. The code is parsed if it is not already done. It runs the dependencies if it is not already done. */ -@genType let run = (project: reducerProject, sourceId: string): unit => project->T.Private.castToInternalProject->Private.run(sourceId) /* Runs all of the sources in a project. Their results and bindings will be available */ -@genType let runAll = (project: reducerProject): unit => project->T.Private.castToInternalProject->Private.runAll /* Get the bindings after running this source file or the project */ -@genType let getExternalBindings = ( project: reducerProject, sourceId: string, @@ -392,7 +370,6 @@ let getExternalBindings = ( /* Get the result after running this source file or the project */ -@genType let getExternalResult = (project: reducerProject, sourceId: string): option< result, > => project->T.Private.castToInternalProject->Private.getExternalResult(sourceId) @@ -402,7 +379,6 @@ This is a convenience function to get the result of a single source without crea However, without a project, you cannot handle include directives. The source has to be include free */ -@genType let evaluate = (sourceCode: string): ('r, 'b) => { let (result, continuation) = Private.evaluate(sourceCode) ( @@ -411,13 +387,11 @@ let evaluate = (sourceCode: string): ('r, 'b) => { ) } -@genType let setEnvironment = ( project: reducerProject, environment: ExternalExpressionValue.environment, ): unit => project->T.Private.castToInternalProject->Private.setEnvironment(environment) -@genType let foreignFunctionInterface = ( lambdaValue: ExternalExpressionValue.lambdaValue, argArray: array, diff --git a/packages/squiggle-lang/src/rescript/TypescriptInterface.res b/packages/squiggle-lang/src/rescript/TypescriptInterface.res index 64629731..b3d2e827 100644 --- a/packages/squiggle-lang/src/rescript/TypescriptInterface.res +++ b/packages/squiggle-lang/src/rescript/TypescriptInterface.res @@ -34,30 +34,6 @@ type resultString = result @genType let makeSampleSetDist = SampleSetDist.make -// @genType -// let evaluate = Reducer.evaluate - -// @genType -// let evaluateUsingOptions = Reducer.evaluateUsingOptions - -@genType -let parse = Reducer_Peggy_Parse.parse - -// @genType -// let evaluatePartialUsingExternalBindings = Reducer.evaluatePartialUsingExternalBindings - -@genType -type externalBindings = Reducer.externalBindings - -@genType -type expressionValue = ReducerInterface_ExternalExpressionValue.t - -@genType -type recordEV = ReducerInterface_ExternalExpressionValue.record - -@genType -type errorValue = Reducer_ErrorValue.errorValue - @genType let toPointSet = GenericDist.toPointSet @@ -70,30 +46,12 @@ type discreteShape = PointSetTypes.discreteShape @genType type continuousShape = PointSetTypes.continuousShape -@genType -let errorValueToString = Reducer_ErrorValue.errorToString - @genType let distributionErrorToString = DistributionTypes.Error.toString -@genType -type lambdaValue = ReducerInterface_ExternalExpressionValue.lambdaValue - -@genType -type lambdaDeclaration = ReducerInterface_ExternalExpressionValue.lambdaDeclaration - @genType let defaultSamplingEnv = DistributionOperation.defaultEnv -@genType -type environment = ReducerInterface_ExternalExpressionValue.environment - -@genType -let defaultEnvironment = ReducerInterface_ExternalExpressionValue.defaultEnvironment - -// @genType -// let foreignFunctionInterface = Reducer.foreignFunctionInterface - @genType type declarationArg = Declaration.arg