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 new file mode 100644 index 00000000..e9e0bfeb --- /dev/null +++ b/packages/squiggle-lang/src/rescript/Dummy-TypeScriptingRescript/ForTS/ForTS_InternalValue/ForTS_InternalValue.res @@ -0,0 +1,33 @@ +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" + +let getTag = (variant: internalValue) => + switch variant { + | IvVoid(_) => ivtVoid_ + | IvString(_) => ivtString_ + | IvRecordLike(_) => ivtRecordLike_ + } + +let getVoid = (variant: internalValue): option => + switch variant { + | IvVoid(v) => Some(v) + | _ => None + } + +let getString = (variant: internalValue): option => + switch variant { + | IvString(s) => Some(s) + | _ => None + } + +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 new file mode 100644 index 00000000..630cd72e --- /dev/null +++ b/packages/squiggle-lang/src/rescript/Dummy-TypeScriptingRescript/ForTS/ForTS_InternalValue/ForTS_InternalValue_RecordLike.res @@ -0,0 +1,8 @@ +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 new file mode 100644 index 00000000..dffb46e1 --- /dev/null +++ b/packages/squiggle-lang/src/rescript/Dummy-TypeScriptingRescript/ForTS/ForTS_InternalValue/ForTS_InternalValue_String.res @@ -0,0 +1 @@ +@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 new file mode 100644 index 00000000..7b5b85e6 --- /dev/null +++ b/packages/squiggle-lang/src/rescript/Dummy-TypeScriptingRescript/ForTS/ForTS_InternalValue/ForTS_InternalValue_Void.res @@ -0,0 +1,3 @@ +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 new file mode 100644 index 00000000..a8438d1d --- /dev/null +++ b/packages/squiggle-lang/src/rescript/Dummy-TypeScriptingRescript/ForTS/ForTS_InternalValue/ForTS_InternalValue_tag.tsx @@ -0,0 +1,7 @@ +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 new file mode 100644 index 00000000..f677ec42 --- /dev/null +++ b/packages/squiggle-lang/src/rescript/Dummy-TypeScriptingRescript/ForTS/ForTS_MyProject.res @@ -0,0 +1,4 @@ +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/ForTS_Result_InternalValue.res b/packages/squiggle-lang/src/rescript/Dummy-TypeScriptingRescript/ForTS/ForTS_Result/ForTS_Result_InternalValue.res new file mode 100644 index 00000000..fd55b6ff --- /dev/null +++ b/packages/squiggle-lang/src/rescript/Dummy-TypeScriptingRescript/ForTS/ForTS_Result/ForTS_Result_InternalValue.res @@ -0,0 +1,18 @@ +open ForTS_Types + +@genType let isError = (r: result_internalValue): bool => Belt.Result.isError(r) +@genType let isOk = (r: result_internalValue): bool => Belt.Result.isOk(r) + +@genType +let getError = (r: result_internalValue): option => + switch r { + | Ok(_) => None + | Error(e) => Some(e) + } + +@genType +let getValue = (r: result_internalValue): option => + 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 new file mode 100644 index 00000000..4345c405 --- /dev/null +++ b/packages/squiggle-lang/src/rescript/Dummy-TypeScriptingRescript/ForTS/ForTS_Types.res @@ -0,0 +1,12 @@ +/* + 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_internalValue = result // There has to be a type for each result permutation +@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 new file mode 100644 index 00000000..a4a2304a --- /dev/null +++ b/packages/squiggle-lang/src/rescript/Dummy-TypeScriptingRescript/My/My_ErrorValue.res @@ -0,0 +1,10 @@ +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 new file mode 100644 index 00000000..b4037564 --- /dev/null +++ b/packages/squiggle-lang/src/rescript/Dummy-TypeScriptingRescript/MyInterface/MyInterface_InternalValue.res @@ -0,0 +1,9 @@ +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 new file mode 100644 index 00000000..ccf7bc45 --- /dev/null +++ b/packages/squiggle-lang/src/rescript/Dummy-TypeScriptingRescript/MyInterface/MyInterface_InternalValue/MyInterface_InternalValue_RecordLike.res @@ -0,0 +1,12 @@ +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 new file mode 100644 index 00000000..21c261ef --- /dev/null +++ b/packages/squiggle-lang/src/rescript/Dummy-TypeScriptingRescript/MyInterface/MyInterface_InternalValue/MyInterface_InternalValue_String.res @@ -0,0 +1 @@ +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 new file mode 100644 index 00000000..b41f0b82 --- /dev/null +++ b/packages/squiggle-lang/src/rescript/Dummy-TypeScriptingRescript/MyInterface/MyInterface_InternalValue/MyInterface_InternalValue_Void.res @@ -0,0 +1 @@ +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 new file mode 100644 index 00000000..c37ef95a --- /dev/null +++ b/packages/squiggle-lang/src/rescript/Dummy-TypeScriptingRescript/MyInterface/MyInterface_InternalValue_T.res @@ -0,0 +1,7 @@ +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 new file mode 100644 index 00000000..93dd1be2 --- /dev/null +++ b/packages/squiggle-lang/src/rescript/Dummy-TypeScriptingRescript/README.md @@ -0,0 +1 @@ +To be trashed. Experimental code \ No newline at end of file