From feb7627ad07a3d1ac2fc09dd67e9c4f3722c2c10 Mon Sep 17 00:00:00 2001 From: Umur Ozkul Date: Sat, 20 Aug 2022 06:47:23 +0200 Subject: [PATCH] result fmap --- packages/squiggle-lang/src/rescript/ForTS/ForTS_Result.res | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/packages/squiggle-lang/src/rescript/ForTS/ForTS_Result.res b/packages/squiggle-lang/src/rescript/ForTS/ForTS_Result.res index 7ace5c9c..39aad100 100644 --- a/packages/squiggle-lang/src/rescript/ForTS/ForTS_Result.res +++ b/packages/squiggle-lang/src/rescript/ForTS/ForTS_Result.res @@ -29,3 +29,10 @@ let getTag = (r: result_<'a, 'e>): int => | Ok(_) => rtOk_ | Error(_) => rtError_ } + +@genType +let fmap = (r: result_<'a, 'e>, f: 'a => 'b): result_<'b, 'e> => + switch r { + | Ok(v) => Ok(f(v)) + | Error(e) => Error(e) + }