From 609802d943d96e8ae33bf95f1af2e41ce06243ec Mon Sep 17 00:00:00 2001 From: rb Date: Fri, 2 Dec 2022 08:47:52 +0100 Subject: [PATCH] #1289 WIP example isOk --- src/stdlib/WebSharper.Main.Proxies/ResultModule.fs | 13 +++++++++---- tests/WebSharper.Tests/Result.fs | 7 +++++++ 2 files changed, 16 insertions(+), 4 deletions(-) diff --git a/src/stdlib/WebSharper.Main.Proxies/ResultModule.fs b/src/stdlib/WebSharper.Main.Proxies/ResultModule.fs index 26b0a0cfd..a08498157 100644 --- a/src/stdlib/WebSharper.Main.Proxies/ResultModule.fs +++ b/src/stdlib/WebSharper.Main.Proxies/ResultModule.fs @@ -24,18 +24,23 @@ FSharp.Core, Culture=neutral, \ PublicKeyToken=b03f5f7f11d50a3a">] module private WebSharper.ResultModuleProxy - + let Bind f r = match r with | Ok x -> f x | Error e -> Error e - + let Map f r = match r with | Ok x -> Ok (f x) | Error e -> Error e - + let MapError f r = match r with | Ok x -> Ok x - | Error e -> Error (f e) + | Error e -> Error (f e) + +let isOk r = + match r with + | Ok _ -> true + | _ -> false \ No newline at end of file diff --git a/tests/WebSharper.Tests/Result.fs b/tests/WebSharper.Tests/Result.fs index c4b1a1f30..e3eb7f363 100644 --- a/tests/WebSharper.Tests/Result.fs +++ b/tests/WebSharper.Tests/Result.fs @@ -57,4 +57,11 @@ let Tests = equal (r2 |> Result.bind (fun x -> Ok())) (Error "e") } + Test "isOk" { + let r = Ok 3 + let r2 = Error "e" + equal (r |> Result.isOk) true + equal (r2 |> Result.isOk) false + } + }