From 4bf5f33f25a0d597b8a1e8c554563df91450f95d Mon Sep 17 00:00:00 2001 From: Umur Ozkul Date: Fri, 19 Aug 2022 22:03:55 +0200 Subject: [PATCH] result tag --- .../src/rescript/ForTS/ForTS_Result.res | 13 +++++++++++++ .../src/rescript/ForTS/ForTS_Result_tag.ts | 4 ++++ 2 files changed, 17 insertions(+) create mode 100644 packages/squiggle-lang/src/rescript/ForTS/ForTS_Result_tag.ts 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