Skip to content

Commit

Permalink
About Option doc (#273)
Browse files Browse the repository at this point in the history
* 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
  • Loading branch information
m-rinaldi authored Jul 18, 2024
1 parent d1ca343 commit fd9460f
Show file tree
Hide file tree
Showing 6 changed files with 10 additions and 6 deletions.
5 changes: 2 additions & 3 deletions gitbook/SUMMARY.md
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand All @@ -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)
Expand Down
File renamed without changes.
File renamed without changes.
2 changes: 1 addition & 1 deletion gitbook/result/map2.md
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ And an another function that converts a string to an integer:

```fsharp
// string -> Result<int, string>
let tryParseInt str =
let tryParseInt (str: string) =
match System.Int32.TryParse str with
| true, x -> Ok x
| false, _ ->
Expand Down
4 changes: 2 additions & 2 deletions gitbook/result/map3.md
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ And an another function that converts a string to an integer:

```fsharp
// string -> Result<int, string>
let tryParseInt str =
let tryParseInt (str: string) =
match System.Int32.TryParse str with
| true, x -> Ok x
| false, _ ->
Expand Down Expand Up @@ -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
Expand Down
5 changes: 5 additions & 0 deletions src/FsToolkit.ErrorHandling/Option.fs
Original file line number Diff line number Diff line change
Expand Up @@ -128,6 +128,11 @@ module Option =
binder v
|> Result.map Some

/// <summary>
/// Flips around the option and result structures of an option that contains a result.
/// </summary>
/// <param name="opt">The option containing a result.</param>
/// <returns>A result containing an option.</returns>
let inline sequenceResult (opt: Result<'ok, 'error> option) : Result<'ok option, 'error> =
traverseResult id opt

Expand Down

0 comments on commit fd9460f

Please sign in to comment.