From fd9460f0bfa9b670d7ef95ba48ec274a5146871c Mon Sep 17 00:00:00 2001 From: "J. Rinaldi" <2664441+m-rinaldi@users.noreply.github.com> Date: Thu, 18 Jul 2024 23:29:16 +0200 Subject: [PATCH] About Option doc (#273) * XML doc for Option.sequenceResult * doc for Option.traverseResult and Option.sequenceResult moved under Option * minor doc changes to get the code referenced by the traverseResult tutorial working --- gitbook/SUMMARY.md | 5 ++--- gitbook/{resultOption => option}/sequenceResult.md | 0 gitbook/{resultOption => option}/traverseResult.md | 0 gitbook/result/map2.md | 2 +- gitbook/result/map3.md | 4 ++-- src/FsToolkit.ErrorHandling/Option.fs | 5 +++++ 6 files changed, 10 insertions(+), 6 deletions(-) rename gitbook/{resultOption => option}/sequenceResult.md (100%) rename gitbook/{resultOption => option}/traverseResult.md (100%) diff --git a/gitbook/SUMMARY.md b/gitbook/SUMMARY.md index b28bc49c..7f912108 100644 --- a/gitbook/SUMMARY.md +++ b/gitbook/SUMMARY.md @@ -36,7 +36,9 @@ * [map](option/map.md) * [map2](option/map2.md) * [map3](option/map3.md) + * [sequenceResult](option/sequenceResult.md) * [tee Functions](option/teeFunctions.md) + * [traverseResult](option/traverseResult.md) * [zip](option/zip.md) * Lists * [traverseOptionM](option/traverseOptionM.md) @@ -62,9 +64,6 @@ * [Operators](resultOption/operators.md) * [zip](resultOption/zip.md) * [zipError](resultOption/zipError.md) - * Lists - * [traverseResult](resultOption/traverseResult.md) - * [sequenceResult](resultOption/sequenceResult.md) * Transforms * [ofChoice](resultOption/ofChoice.md) * [ofOption](resultOption/ofOption.md) diff --git a/gitbook/resultOption/sequenceResult.md b/gitbook/option/sequenceResult.md similarity index 100% rename from gitbook/resultOption/sequenceResult.md rename to gitbook/option/sequenceResult.md diff --git a/gitbook/resultOption/traverseResult.md b/gitbook/option/traverseResult.md similarity index 100% rename from gitbook/resultOption/traverseResult.md rename to gitbook/option/traverseResult.md diff --git a/gitbook/result/map2.md b/gitbook/result/map2.md index 8581cfd5..df6cbc4a 100644 --- a/gitbook/result/map2.md +++ b/gitbook/result/map2.md @@ -26,7 +26,7 @@ And an another function that converts a string to an integer: ```fsharp // string -> Result -let tryParseInt str = +let tryParseInt (str: string) = match System.Int32.TryParse str with | true, x -> Ok x | false, _ -> diff --git a/gitbook/result/map3.md b/gitbook/result/map3.md index a211cf01..25a3fab5 100644 --- a/gitbook/result/map3.md +++ b/gitbook/result/map3.md @@ -26,7 +26,7 @@ And an another function that converts a string to an integer: ```fsharp // string -> Result -let tryParseInt str = +let tryParseInt (str: string) = match System.Int32.TryParse str with | true, x -> Ok x | false, _ -> @@ -66,7 +66,7 @@ type Tweet = private Tweet of string with Error "Tweet shouldn't be empty" elif tweet.Length > 280 then Error "Tweet shouldn't contain more than 280 characters" - else Ok (Tweet x) + else Ok (Tweet tweet) ``` #### CreatePostRequest diff --git a/src/FsToolkit.ErrorHandling/Option.fs b/src/FsToolkit.ErrorHandling/Option.fs index 33dec41f..5ab7d473 100644 --- a/src/FsToolkit.ErrorHandling/Option.fs +++ b/src/FsToolkit.ErrorHandling/Option.fs @@ -128,6 +128,11 @@ module Option = binder v |> Result.map Some + /// + /// Flips around the option and result structures of an option that contains a result. + /// + /// The option containing a result. + /// A result containing an option. let inline sequenceResult (opt: Result<'ok, 'error> option) : Result<'ok option, 'error> = traverseResult id opt