diff --git a/packages/squiggle-lang/src/rescript/ForTS/ForTS_Result.res b/packages/squiggle-lang/src/rescript/ForTS/ForTS_Result.res index 19bf6ee0..7ace5c9c 100644 --- a/packages/squiggle-lang/src/rescript/ForTS/ForTS_Result.res +++ b/packages/squiggle-lang/src/rescript/ForTS/ForTS_Result.res @@ -16,3 +16,16 @@ let getValue = (r: result_<'a, 'e>): option<'a> => | Ok(v) => Some(v) | Error(_) => None } + +@module("ForTS_Result_tag") @scope("ResultTag") +external rtOk_: int = "RtOk" + +@module("ForTS_Result_tag") @scope("ResultTag") +external rtError_: int = "RtError" + +@genType +let getTag = (r: result_<'a, 'e>): int => + switch r { + | Ok(_) => rtOk_ + | Error(_) => rtError_ + } diff --git a/packages/squiggle-lang/src/rescript/ForTS/ForTS_Result_tag.ts b/packages/squiggle-lang/src/rescript/ForTS/ForTS_Result_tag.ts new file mode 100644 index 00000000..571de93a --- /dev/null +++ b/packages/squiggle-lang/src/rescript/ForTS/ForTS_Result_tag.ts @@ -0,0 +1,4 @@ +enum ResultTag { + Ok, + Error, +} \ No newline at end of file