From af4070a34f332891aadadd520b4ec4f7a93a2675 Mon Sep 17 00:00:00 2001 From: Umur Ozkul Date: Fri, 19 Aug 2022 17:30:29 +0200 Subject: [PATCH] demolish external expression value --- .../ForTS_InternalValue.res | 37 ------------------- .../ForTS_InternalValue_RecordLike.res | 8 ---- .../ForTS_InternalValue_String.res | 1 - .../ForTS_InternalValue_Void.res | 3 -- .../ForTS_InternalValue_tag.tsx | 7 ---- .../ForTS/ForTS_MyProject.res | 5 --- .../ForTS/ForTS_Result_.res | 18 --------- .../ForTS/ForTS_Types_.res | 12 ------ .../My/My_ErrorValue.res | 10 ----- .../MyInterface/MyInterface_InternalValue.res | 9 ----- .../MyInterface_InternalValue_RecordLike.res | 12 ------ .../MyInterface_InternalValue_String.res | 1 - .../MyInterface_InternalValue_Void.res | 1 - .../MyInterface_InternalValue_T.res | 7 ---- .../Dummy-TypeScriptingRescript/README.md | 1 - .../rescript/ForTS/ForTS_ReducerProject.res | 2 +- .../src/rescript/ForTS/ForTS__Functions.res | 7 +++- .../src/rescript/ForTS/ForTS__Types.res | 7 ++-- 18 files changed, 11 insertions(+), 137 deletions(-) delete mode 100644 packages/squiggle-lang/src/rescript/Dummy-TypeScriptingRescript/ForTS/ForTS_InternalValue/ForTS_InternalValue.res delete mode 100644 packages/squiggle-lang/src/rescript/Dummy-TypeScriptingRescript/ForTS/ForTS_InternalValue/ForTS_InternalValue_RecordLike.res delete mode 100644 packages/squiggle-lang/src/rescript/Dummy-TypeScriptingRescript/ForTS/ForTS_InternalValue/ForTS_InternalValue_String.res delete mode 100644 packages/squiggle-lang/src/rescript/Dummy-TypeScriptingRescript/ForTS/ForTS_InternalValue/ForTS_InternalValue_Void.res delete mode 100644 packages/squiggle-lang/src/rescript/Dummy-TypeScriptingRescript/ForTS/ForTS_InternalValue/ForTS_InternalValue_tag.tsx delete mode 100644 packages/squiggle-lang/src/rescript/Dummy-TypeScriptingRescript/ForTS/ForTS_MyProject.res delete mode 100644 packages/squiggle-lang/src/rescript/Dummy-TypeScriptingRescript/ForTS/ForTS_Result_.res delete mode 100644 packages/squiggle-lang/src/rescript/Dummy-TypeScriptingRescript/ForTS/ForTS_Types_.res delete mode 100644 packages/squiggle-lang/src/rescript/Dummy-TypeScriptingRescript/My/My_ErrorValue.res delete mode 100644 packages/squiggle-lang/src/rescript/Dummy-TypeScriptingRescript/MyInterface/MyInterface_InternalValue.res delete mode 100644 packages/squiggle-lang/src/rescript/Dummy-TypeScriptingRescript/MyInterface/MyInterface_InternalValue/MyInterface_InternalValue_RecordLike.res delete mode 100644 packages/squiggle-lang/src/rescript/Dummy-TypeScriptingRescript/MyInterface/MyInterface_InternalValue/MyInterface_InternalValue_String.res delete mode 100644 packages/squiggle-lang/src/rescript/Dummy-TypeScriptingRescript/MyInterface/MyInterface_InternalValue/MyInterface_InternalValue_Void.res delete mode 100644 packages/squiggle-lang/src/rescript/Dummy-TypeScriptingRescript/MyInterface/MyInterface_InternalValue_T.res delete mode 100644 packages/squiggle-lang/src/rescript/Dummy-TypeScriptingRescript/README.md 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 deleted file mode 100644 index 783f97ec..00000000 --- a/packages/squiggle-lang/src/rescript/Dummy-TypeScriptingRescript/ForTS/ForTS_InternalValue/ForTS_InternalValue.res +++ /dev/null @@ -1,37 +0,0 @@ -open ForTS_Types_ - -@module("ForTS_InternalValue_tag") @scope("InternalValueTag") -external ivtVoid_: int = "IvtVoid" -@module("ForTS_InternalValue_tag") @scope("InternalValueTag") -external ivtString_: int = "IvtString" -@module("ForTS_InternalValue_tag") @scope("InternalValueTag") -external ivtRecordLike_: int = "IvtRecordLike" - -@genType -let getTag = (variant: internalValue) => - switch variant { - | IvVoid(_) => ivtVoid_ - | IvString(_) => ivtString_ - | IvRecordLike(_) => ivtRecordLike_ - } - -@genType -let getVoid = (variant: internalValue): option => - switch variant { - | IvVoid(v) => Some(v) - | _ => None - } - -@genType -let getString = (variant: internalValue): option => - switch variant { - | IvString(s) => Some(s) - | _ => None - } - -@genType -let getRecordLike = (variant: internalValue): option => - switch variant { - | IvRecordLike(r) => Some(r) - | _ => None - } 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 deleted file mode 100644 index 7a28ea75..00000000 --- a/packages/squiggle-lang/src/rescript/Dummy-TypeScriptingRescript/ForTS/ForTS_InternalValue/ForTS_InternalValue_RecordLike.res +++ /dev/null @@ -1,8 +0,0 @@ -open ForTS_Types_ - -@genType -let toString = (v: recordLike): string => - MyInterface_InternalValue_RecordLike.toString(v, MyInterface_InternalValue.toString) -@genType -let toArray = (v: recordLike): array<(string, internalValue)> => - MyInterface_InternalValue_RecordLike.toArray(v) diff --git a/packages/squiggle-lang/src/rescript/Dummy-TypeScriptingRescript/ForTS/ForTS_InternalValue/ForTS_InternalValue_String.res b/packages/squiggle-lang/src/rescript/Dummy-TypeScriptingRescript/ForTS/ForTS_InternalValue/ForTS_InternalValue_String.res deleted file mode 100644 index dffb46e1..00000000 --- a/packages/squiggle-lang/src/rescript/Dummy-TypeScriptingRescript/ForTS/ForTS_InternalValue/ForTS_InternalValue_String.res +++ /dev/null @@ -1 +0,0 @@ -@genType let toString = (value: string): string => value 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 deleted file mode 100644 index 7fae9341..00000000 --- a/packages/squiggle-lang/src/rescript/Dummy-TypeScriptingRescript/ForTS/ForTS_InternalValue/ForTS_InternalValue_Void.res +++ /dev/null @@ -1,3 +0,0 @@ -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_InternalValue/ForTS_InternalValue_tag.tsx b/packages/squiggle-lang/src/rescript/Dummy-TypeScriptingRescript/ForTS/ForTS_InternalValue/ForTS_InternalValue_tag.tsx deleted file mode 100644 index a8438d1d..00000000 --- a/packages/squiggle-lang/src/rescript/Dummy-TypeScriptingRescript/ForTS/ForTS_InternalValue/ForTS_InternalValue_tag.tsx +++ /dev/null @@ -1,7 +0,0 @@ -enum InternalValueTag { - IvtVoid, - IvtString, - IvtRecordLike -} - - 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 deleted file mode 100644 index 23550d16..00000000 --- a/packages/squiggle-lang/src/rescript/Dummy-TypeScriptingRescript/ForTS/ForTS_MyProject.res +++ /dev/null @@ -1,5 +0,0 @@ -open ForTS_Types_ - -@genType -let getResult = (_p: myProject): option> => - My_ErrorValue.EError->Error->Some 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 deleted file mode 100644 index f29b1657..00000000 --- a/packages/squiggle-lang/src/rescript/Dummy-TypeScriptingRescript/ForTS/ForTS_Result_.res +++ /dev/null @@ -1,18 +0,0 @@ -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 deleted file mode 100644 index 980c90bd..00000000 --- a/packages/squiggle-lang/src/rescript/Dummy-TypeScriptingRescript/ForTS/ForTS_Types_.res +++ /dev/null @@ -1,12 +0,0 @@ -/* - Group all opaque types together for TS. - All other modules for TS should use this module -*/ -@genType.opaque type internalValue = MyInterface_InternalValue_T.t -@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> -@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/Dummy-TypeScriptingRescript/My/My_ErrorValue.res b/packages/squiggle-lang/src/rescript/Dummy-TypeScriptingRescript/My/My_ErrorValue.res deleted file mode 100644 index a4a2304a..00000000 --- a/packages/squiggle-lang/src/rescript/Dummy-TypeScriptingRescript/My/My_ErrorValue.res +++ /dev/null @@ -1,10 +0,0 @@ -type errorValue = EError | EErrorString(string) | EErrorNumber(float) -type t = errorValue - -let toString = (e: errorValue): string => { - switch e { - | EError => "Error" - | EErrorString(s) => s - | EErrorNumber(f) => Js.Float.toString(f) - } -} diff --git a/packages/squiggle-lang/src/rescript/Dummy-TypeScriptingRescript/MyInterface/MyInterface_InternalValue.res b/packages/squiggle-lang/src/rescript/Dummy-TypeScriptingRescript/MyInterface/MyInterface_InternalValue.res deleted file mode 100644 index b4037564..00000000 --- a/packages/squiggle-lang/src/rescript/Dummy-TypeScriptingRescript/MyInterface/MyInterface_InternalValue.res +++ /dev/null @@ -1,9 +0,0 @@ -open MyInterface_InternalValue_T - -let rec toString = (v: internalValue): string => { - switch v { - | IvString(s) => MyInterface_InternalValue_String.toString(s) - | IvRecordLike(m) => MyInterface_InternalValue_RecordLike.toString(m, toString) - | IvVoid(_v) => MyInterface_InternalValue_Void.toString - } -} diff --git a/packages/squiggle-lang/src/rescript/Dummy-TypeScriptingRescript/MyInterface/MyInterface_InternalValue/MyInterface_InternalValue_RecordLike.res b/packages/squiggle-lang/src/rescript/Dummy-TypeScriptingRescript/MyInterface/MyInterface_InternalValue/MyInterface_InternalValue_RecordLike.res deleted file mode 100644 index ccf7bc45..00000000 --- a/packages/squiggle-lang/src/rescript/Dummy-TypeScriptingRescript/MyInterface/MyInterface_InternalValue/MyInterface_InternalValue_RecordLike.res +++ /dev/null @@ -1,12 +0,0 @@ -type t = MyInterface_InternalValue_T.recordLike -let toString = (value: t, recToString) => { - let contents = - Belt.Map.String.mapWithKey(value, (key, value) => { - `${key}: ${recToString(value)}` - }) - ->Belt.Map.String.toArray - ->Js.Array2.joinWith(", ") - `{${contents}}` -} - -let toArray = (value: t) => Belt.Map.String.toArray(value) diff --git a/packages/squiggle-lang/src/rescript/Dummy-TypeScriptingRescript/MyInterface/MyInterface_InternalValue/MyInterface_InternalValue_String.res b/packages/squiggle-lang/src/rescript/Dummy-TypeScriptingRescript/MyInterface/MyInterface_InternalValue/MyInterface_InternalValue_String.res deleted file mode 100644 index 21c261ef..00000000 --- a/packages/squiggle-lang/src/rescript/Dummy-TypeScriptingRescript/MyInterface/MyInterface_InternalValue/MyInterface_InternalValue_String.res +++ /dev/null @@ -1 +0,0 @@ -let toString = v => v diff --git a/packages/squiggle-lang/src/rescript/Dummy-TypeScriptingRescript/MyInterface/MyInterface_InternalValue/MyInterface_InternalValue_Void.res b/packages/squiggle-lang/src/rescript/Dummy-TypeScriptingRescript/MyInterface/MyInterface_InternalValue/MyInterface_InternalValue_Void.res deleted file mode 100644 index b41f0b82..00000000 --- a/packages/squiggle-lang/src/rescript/Dummy-TypeScriptingRescript/MyInterface/MyInterface_InternalValue/MyInterface_InternalValue_Void.res +++ /dev/null @@ -1 +0,0 @@ -let toString = "Void" diff --git a/packages/squiggle-lang/src/rescript/Dummy-TypeScriptingRescript/MyInterface/MyInterface_InternalValue_T.res b/packages/squiggle-lang/src/rescript/Dummy-TypeScriptingRescript/MyInterface/MyInterface_InternalValue_T.res deleted file mode 100644 index c37ef95a..00000000 --- a/packages/squiggle-lang/src/rescript/Dummy-TypeScriptingRescript/MyInterface/MyInterface_InternalValue_T.res +++ /dev/null @@ -1,7 +0,0 @@ -type rec internalValue = - | IvString(string) - | IvRecordLike(recordLike) - | IvVoid(int) -and recordLike = Belt.Map.String.t - -type t = internalValue diff --git a/packages/squiggle-lang/src/rescript/Dummy-TypeScriptingRescript/README.md b/packages/squiggle-lang/src/rescript/Dummy-TypeScriptingRescript/README.md deleted file mode 100644 index 93dd1be2..00000000 --- a/packages/squiggle-lang/src/rescript/Dummy-TypeScriptingRescript/README.md +++ /dev/null @@ -1 +0,0 @@ -To be trashed. Experimental code \ No newline at end of file diff --git a/packages/squiggle-lang/src/rescript/ForTS/ForTS_ReducerProject.res b/packages/squiggle-lang/src/rescript/ForTS/ForTS_ReducerProject.res index 1dc08768..77d5fbe9 100644 --- a/packages/squiggle-lang/src/rescript/ForTS/ForTS_ReducerProject.res +++ b/packages/squiggle-lang/src/rescript/ForTS/ForTS_ReducerProject.res @@ -129,7 +129,7 @@ let getRunOrderFor = (project: reducerProject, sourceId: string) => 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. -*/module Topology = ReducerProject_Topology +*/ module Topology = ReducerProject_Topology let parseIncludes = (project: reducerProject, sourceId: string): unit => project->T.Private.castToInternalProject->Private.parseIncludes(sourceId) diff --git a/packages/squiggle-lang/src/rescript/ForTS/ForTS__Functions.res b/packages/squiggle-lang/src/rescript/ForTS/ForTS__Functions.res index 8b137891..6a22297a 100644 --- a/packages/squiggle-lang/src/rescript/ForTS/ForTS__Functions.res +++ b/packages/squiggle-lang/src/rescript/ForTS/ForTS__Functions.res @@ -1 +1,6 @@ - +open ForTS__Types +/* +Global variables, functions, helpers, etc. +*/ +@genType +let defaultEnvironment: environment = DistributionOperation.defaultEnv diff --git a/packages/squiggle-lang/src/rescript/ForTS/ForTS__Types.res b/packages/squiggle-lang/src/rescript/ForTS/ForTS__Types.res index c7ac9210..1914e740 100644 --- a/packages/squiggle-lang/src/rescript/ForTS/ForTS__Types.res +++ b/packages/squiggle-lang/src/rescript/ForTS/ForTS__Types.res @@ -1,10 +1,10 @@ +@genType.opaque type result_<'a, 'e> = result<'a, 'e> + /* 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 = ReducerInterface_InternalExpressionValue.t @genType.opaque type squiggleValue_Array = ReducerInterface_InternalExpressionValue.squiggleArray @genType.opaque @@ -17,7 +17,8 @@ type squiggleValue_Declaration = ReducerInterface_InternalExpressionValue.lambda @genType.opaque type reducerProject = ReducerProject_T.t -// From now on one should introduce any new types as opaque types +// From now on one should introduce any new types as opaque types. +// Exception: The intended type is really a JavaScript type or record. Not by coincidence // Already existing open types we cannot dive in now @genType type environment = GenericDist.env @genType type squiggleValue_Distribution = DistributionTypes.genericDist