From d64ae8a340aa47cf7b0595c6661c20f08f1039b4 Mon Sep 17 00:00:00 2001 From: 1eyewonder Date: Mon, 10 Jul 2023 15:49:30 -0500 Subject: [PATCH 01/10] Moved Result.tryCreate under Result instead of Validation --- gitbook/{validation => result}/tryCreate.md | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) rename gitbook/{validation => result}/tryCreate.md (93%) diff --git a/gitbook/validation/tryCreate.md b/gitbook/result/tryCreate.md similarity index 93% rename from gitbook/validation/tryCreate.md rename to gitbook/result/tryCreate.md index 878fd095..9d0dde53 100644 --- a/gitbook/validation/tryCreate.md +++ b/gitbook/result/tryCreate.md @@ -1,8 +1,8 @@ -## Result.tryCreate +# Result.tryCreate Namespace: `FsToolkit.ErrorHandling` -Function Signature: +## Function Signature ```fsharp string -> 'a -> Result<^b, (string * 'c)> @@ -14,7 +14,7 @@ string -> 'a -> Result<^b, (string * 'c)> ^b : (static member TryCreate : 'a -> Result< ^b, 'c>) ``` -This can be useful when constructing types for collecting construction validation errors associated with passed-in parameter names, as the example below demonstrate. +This can be useful when constructing types for collecting construction result errors associated with passed-in parameter names, as the example below demonstrate. ## Examples @@ -97,10 +97,10 @@ type CreatePostRequestDto = { } ``` -We can then do validation using `Result.tryResult` and the [`Validation` infix operators](../validation/operators.md) as below: +We can then do result using `Result.tryResult` and the [`Result` infix operators](../result/operators.md) as below: ```fsharp -open FsToolkit.ErrorHandling.Operator.Validation +open FsToolkit.ErrorHandling.Operator.Result // CreatePostRequestDto -> Result let validateCreatePostRequest (dto : CreatePostRequestDto) = @@ -141,7 +141,7 @@ When serialized: ### Example 2 -In Example 1, we collected all the error messages. But what if we wanted to stop on the first error? One way to do this is to make use of the `result` computation expression instead of using infix operators from `Validation` module. +In Example 1, we collected all the error messages. But what if we wanted to stop on the first error? One way to do this is to make use of the `result` computation expression instead of using infix operators from `Result` module. ```fsharp // CreatePostRequestDto -> Result @@ -198,4 +198,4 @@ validateCreatePostRequest validateCreatePostRequest {Tweet = ""; Location = None} // Error [("tweet", "Tweet shouldn't be empty")] -``` \ No newline at end of file +``` From 85eea3801bdfc859cf9ce8f11a92cc9f0b0b64d1 Mon Sep 17 00:00:00 2001 From: 1eyewonder Date: Mon, 10 Jul 2023 15:51:06 -0500 Subject: [PATCH 02/10] Alphabetized Result & ResultOption functions in summary. Added missing Result functions --- gitbook/SUMMARY.md | 28 ++++++++++++++++++++-------- 1 file changed, 20 insertions(+), 8 deletions(-) diff --git a/gitbook/SUMMARY.md b/gitbook/SUMMARY.md index 104e3b89..2e857430 100644 --- a/gitbook/SUMMARY.md +++ b/gitbook/SUMMARY.md @@ -2,15 +2,25 @@ * FsToolkit.ErrorHandling * Result - * [map2](result/map2.md) - * [map3](result/map3.md) * [apply](result/apply.md) + * [bind](result/bind.md) + * [Computation Expression](result/ce.md) + * [either Functions](result/eitherFunctions.md) * [fold](result/fold.md) - * [ofChoice](result/ofChoice.md) * [ignore](result/ignore.md) - * [Computation Expression](result/ce.md) + * [map](result/map.md) + * [map2](result/map2.md) + * [map3](result/map3.md) + * [mapError](result/mapError.md) + * [ofChoice](result/ofChoice.md) * [Operators](result/operators.md) + * [orElse Functions](result/orElseFunctions.md) * [Other Functions](result/others.md) + * [require Functions](result/requireFunctions.md) + * [tee Functions](result/teeFunctions.md) + * [tryCreate](result/tryCreate.md) + * [zip](result/zip.md) + * [zipError](result/zipError.md) * Lists * [traverseResultM](list/traverseResultM.md) * [sequenceResultM](list/sequenceResultM.md) @@ -23,14 +33,16 @@ * [Computation Expression](option/ce.md) * ResultOption - * [map](resultOption/map.md) - * [map2](resultOption/map2.md) - * [map3](resultOption/map3.md) * [apply](resultOption/apply.md) * [bind](resultOption/bind.md) - * [ignore](resultOption/ignore.md) * [Computation Expression](resultOption/ce.md) + * [ignore](resultOption/ignore.md) + * [map](resultOption/map.md) + * [map2](resultOption/map2.md) + * [map3](resultOption/map3.md) * [Operators](resultOption/operators.md) + * [zip](resultOption/zip.md) + * [zipError](resultOption/zipError.md) * AsyncResult * [map](asyncResult/map.md) From 2625779cb40f706bcc35e02796f9d64b3eeb0b26 Mon Sep 17 00:00:00 2001 From: 1eyewonder Date: Mon, 10 Jul 2023 15:51:34 -0500 Subject: [PATCH 03/10] Updated Result documentation to add more examples and have common structure --- gitbook/list/sequenceResultA.md | 6 +- gitbook/list/sequenceResultM.md | 6 +- gitbook/list/traverseResultA.md | 6 +- gitbook/list/traverseResultM.md | 6 +- gitbook/result/apply.md | 10 +- gitbook/result/bind.md | 54 +++++ gitbook/result/ce.md | 4 +- gitbook/result/eitherFunctions.md | 61 ++++++ gitbook/result/fold.md | 7 +- gitbook/result/ignore.md | 10 +- gitbook/result/map.md | 42 ++++ gitbook/result/map2.md | 8 +- gitbook/result/map3.md | 6 +- gitbook/result/mapError.md | 44 ++++ gitbook/result/ofChoice.md | 9 +- gitbook/result/operators.md | 4 +- gitbook/result/orElseFunctions.md | 111 ++++++++++ gitbook/result/others.md | 147 +++---------- gitbook/result/requireFunctions.md | 319 +++++++++++++++++++++++++++++ gitbook/result/teeFunctions.md | 131 ++++++++++++ gitbook/result/zip.md | 32 +++ gitbook/result/zipError.md | 32 +++ gitbook/resultOption/map.md | 2 +- 23 files changed, 903 insertions(+), 154 deletions(-) create mode 100644 gitbook/result/bind.md create mode 100644 gitbook/result/eitherFunctions.md create mode 100644 gitbook/result/map.md create mode 100644 gitbook/result/mapError.md create mode 100644 gitbook/result/orElseFunctions.md create mode 100644 gitbook/result/requireFunctions.md create mode 100644 gitbook/result/teeFunctions.md create mode 100644 gitbook/result/zip.md create mode 100644 gitbook/result/zipError.md diff --git a/gitbook/list/sequenceResultA.md b/gitbook/list/sequenceResultA.md index ba295b62..a2e0dacc 100644 --- a/gitbook/list/sequenceResultA.md +++ b/gitbook/list/sequenceResultA.md @@ -1,10 +1,10 @@ -## List.sequenceResultA +# List.sequenceResultA Namespace: `FsToolkit.ErrorHandling` -Function Signature: +## Function Signature -``` +```fsharp Result<'a, 'b> list -> Result<'a list, 'b list> ``` diff --git a/gitbook/list/sequenceResultM.md b/gitbook/list/sequenceResultM.md index 64c307e6..ec81dd0d 100644 --- a/gitbook/list/sequenceResultM.md +++ b/gitbook/list/sequenceResultM.md @@ -1,10 +1,10 @@ -## List.sequenceResultM +# List.sequenceResultM Namespace: `FsToolkit.ErrorHandling` -Function Signature: +## Function Signature -``` +```fsharp Result<'a, 'b> list -> Result<'a list, 'b> ``` diff --git a/gitbook/list/traverseResultA.md b/gitbook/list/traverseResultA.md index e5a95d6f..0a26bae5 100644 --- a/gitbook/list/traverseResultA.md +++ b/gitbook/list/traverseResultA.md @@ -1,10 +1,10 @@ -## List.traverseResultA +# List.traverseResultA Namespace: `FsToolkit.ErrorHandling` -Function Signature: +## Function Signature -``` +```fsharp ('a -> Result<'b,'c>) -> 'a list -> Result<'b list, 'c list> ``` diff --git a/gitbook/list/traverseResultM.md b/gitbook/list/traverseResultM.md index 13be2663..4f14101a 100644 --- a/gitbook/list/traverseResultM.md +++ b/gitbook/list/traverseResultM.md @@ -1,10 +1,10 @@ -## List.traverseResultM +# List.traverseResultM Namespace: `FsToolkit.ErrorHandling` -Function Signature: +## Function Signature -``` +```fsharp ('a -> Result<'b,'c>) -> 'a list -> Result<'b list, 'c> ``` diff --git a/gitbook/result/apply.md b/gitbook/result/apply.md index 6ef8bb8e..591f959e 100644 --- a/gitbook/result/apply.md +++ b/gitbook/result/apply.md @@ -1,11 +1,14 @@ -## Result.apply +# Result.apply Namespace: `FsToolkit.ErrorHandling` -Function Signature: +`apply` combines two Result values and returns a new Result value. If both Result values are Ok, it applies the function from the first Result to the value from the second Result, producing a new Result type. If either Result is an Error, the apply function propagates the error by returning the corresponding Error value. + +## Function Signature ```fsharp -Result<('a -> 'b), 'c> -> Result<'a, 'c> -> Result<'b, 'c> +Result<('okInput -> 'okOutput), 'error> -> Result<'okInput, 'error> + -> Result<'okOutput, 'error> ``` ## Examples @@ -39,4 +42,3 @@ let remainingCharactersStr (tweetStr : string) = Tweet.TryCreate tweet |> Result.map remainingCharacters ``` - diff --git a/gitbook/result/bind.md b/gitbook/result/bind.md new file mode 100644 index 00000000..b14c131c --- /dev/null +++ b/gitbook/result/bind.md @@ -0,0 +1,54 @@ +# Result.bind + +Namespace: `FsToolkit.ErrorHandling` + +`bind` takes a transformation function `'okInput -> Result<'okOutput, 'error>` and a `Result<'okInput, 'error>`. If the Result is `Ok x`, it applies the transformation function to `x`, which returns a new `Result<'okOutput, 'error>`. The bind function then returns the new `Result<'okOutput, 'error>`. If the original Result is an Error, it simply returns the original Error unchanged without invoking the transformation function. + +## Function Signature + +```fsharp +('okInput -> Result<'okOutput, 'error>) -> Result<'okInput, 'error> + -> Result<'okOutput, 'error> +``` + +## Examples + +Take the following function for example + +```fsharp +// string -> Result +let tryParseInt (s: string) = + match Int32.TryParse(s) with + | true, i -> Ok i + | false, _ -> Error "Could not parse string as int" +``` + +### Example 1 + +```fsharp +let result = + Ok "123" // Result + |> ResultOption.bind tryParseInt // Result + +// Ok 123 +``` + +### Example 2 + +```fsharp +let result = + Ok "bad things happened" // Result + |> ResultOption.bind tryParseInt // Result + +// Error "Could not parse string as int" +``` + +### Example 3 + +```fsharp +let result = + Error "bad things happened" // Result + |> ResultOption.bind tryParseInt // Result + +// Error "bad things happened" +``` diff --git a/gitbook/result/ce.md b/gitbook/result/ce.md index 80d534b5..5f7520de 100644 --- a/gitbook/result/ce.md +++ b/gitbook/result/ce.md @@ -1,8 +1,8 @@ -## Result Computation Expression +# Result Computation Expression Namespace: `FsToolkit.ErrorHandling` -## Examples: +## Examples ### Example 1 diff --git a/gitbook/result/eitherFunctions.md b/gitbook/result/eitherFunctions.md new file mode 100644 index 00000000..35209983 --- /dev/null +++ b/gitbook/result/eitherFunctions.md @@ -0,0 +1,61 @@ +# Either Functions + +Consider the following code for the examples below + +```fsharp +// int -> int +let okF (x : int) = x + 1 + +// int -> int +let errorF (x : int) = x - 1 +``` + +## Result.either + +Namespace: `FsToolkit.ErrorHandling` + +If the result is ok, perform a function on the ok value which returns a value. If the result is an error, perform a function on the error value which returns a value. + +### Function Signature + +```fsharp +('okInput -> 'output) -> ('errorInput -> 'output) + -> Result<'okInput, 'errorInput> -> 'output +``` + +### Examples + +#### Example 1 + +```fsharp +let result = + Ok 1 + |> Result.either okF errorF + +// 2 +``` + +## Result.eitherMap + +Namespace: `FsToolkit.ErrorHandling` + +If the result is ok, perform a function on the ok value to map it to another result type. If the result is an error, perform a function on the error value to map it to another result type. + +### Function Signature + +```fsharp +('okInput -> 'okOutput) -> ('errorInput -> 'errorOutput) -> Result<'okInput, 'errorInput> + -> Result<'okOutput, 'errorOutput> +``` + +### Examples + +#### Example 1 + +```fsharp +let result = + Error 1 + |> Result.eitherMap okF errorF + +// 0 +``` diff --git a/gitbook/result/fold.md b/gitbook/result/fold.md index b780cd40..228469a5 100644 --- a/gitbook/result/fold.md +++ b/gitbook/result/fold.md @@ -1,11 +1,12 @@ -## Result.fold +# Result.fold Namespace: `FsToolkit.ErrorHandling` -Function Signature: +## Function Signature ```fsharp -('a -> 'b) -> ('c -> 'b) -> Result<'a, 'c> -> 'b +('a -> 'b) -> ('c -> 'b) + -> Result<'a, 'c> -> 'b ``` ## Examples diff --git a/gitbook/result/ignore.md b/gitbook/result/ignore.md index 03237f2a..b181e657 100644 --- a/gitbook/result/ignore.md +++ b/gitbook/result/ignore.md @@ -1,15 +1,15 @@ -## Result.ignore +# Result.ignore Namespace: `FsToolkit.ErrorHandling` -Function Signature: +This is a shortcut for `Result.map ignore`. + +## Function Signature ```fsharp Result<'a, 'b> -> Result ``` -This is a shortcut for `Result.map ignore`. - ## Examples ### Example 1 @@ -24,4 +24,4 @@ We can call this with the `do!` syntax inside a computation expression using `Re let makePost = result { do! savePost createPostRequest |> Result.ignore } -``` \ No newline at end of file +``` diff --git a/gitbook/result/map.md b/gitbook/result/map.md new file mode 100644 index 00000000..6ecaec08 --- /dev/null +++ b/gitbook/result/map.md @@ -0,0 +1,42 @@ +# Result.map + +Namespace: `FsToolkit.ErrorHandling` + +`map` applies a transformation to the value inside a `Result` if it represents a successful result (`Ok`). It allows you to perform a computation on the value while preserving the success/error status of the original `Result`. If the original `Result` is an `Error`, `map` does nothing and returns the same `Error` unchanged. + +## Function Signature + +```fsharp +('okInput -> 'okOutput) -> Result<'okInput, 'error> + -> Result<'okOutput, 'error> +``` + +## Examples + +Take the following functions for example + +```fsharp +// string -> int +let remainingCharacters (prompt: string) = + 280 - prompt.Length +``` + +### Example 1 + +```fsharp +let result = + Ok "foo" // Result + |> ResultOption.map remainingCharacters // Result + +// Ok 277 +``` + +### Example 2 + +```fsharp +let result = + Error "bad things happened" // Result + |> ResultOption.map remainingCharacters // Result + +// Error "bad things happened" +``` diff --git a/gitbook/result/map2.md b/gitbook/result/map2.md index 19cd48f6..8581cfd5 100644 --- a/gitbook/result/map2.md +++ b/gitbook/result/map2.md @@ -1,12 +1,12 @@ -## Result.map2 +# Result.map2 Namespace: `FsToolkit.ErrorHandling` -Function Signature: +## Function Signature ```fsharp ('a -> 'b -> 'c) -> Result<'a, 'd> -> Result<'b, 'd> - -> Result<'c, 'd> + -> Result<'c, 'd> ``` ## Examples @@ -108,4 +108,4 @@ let invalidLatR = Latitude.TryCreate 200. let result = Result.map2 Location.Create invalidLatR validLngR // Error "200.0 is a invalid latitude value" -``` \ No newline at end of file +``` diff --git a/gitbook/result/map3.md b/gitbook/result/map3.md index 7f9abd0a..a211cf01 100644 --- a/gitbook/result/map3.md +++ b/gitbook/result/map3.md @@ -1,12 +1,12 @@ -## Result.map3 +# Result.map3 Namespace: `FsToolkit.ErrorHandling` -Function Signature: +## Function Signature ```fsharp ('a -> 'b -> 'c -> 'd) -> Result<'a, 'e> -> Result<'b, 'e> - -> Result<'c, 'e> -> Result<'d, 'e> + -> Result<'c, 'e> -> Result<'d, 'e> ``` ## Examples diff --git a/gitbook/result/mapError.md b/gitbook/result/mapError.md new file mode 100644 index 00000000..8e6774cf --- /dev/null +++ b/gitbook/result/mapError.md @@ -0,0 +1,44 @@ +# Result.mapError + +Namespace: `FsToolkit.ErrorHandling` + +`mapError` takes a result and a normal function and returns a new result value based on the input error value and the function + +## Function Signature + +```fsharp +('errorInput -> 'errorOutput) -> Result<'ok, 'errorInput> + -> Result<'ok, 'errorOutput> +``` + +## Examples + +Take the following functions for example + +```fsharp +// string -> int +let getErrorCode (message: string) = + match message with + | "bad things happened" -> 1 + | _ -> 0 +``` + +### Example 1 + +```fsharp +let result = + Ok "bad things happened" // Result + |> ResultOption.mapError getErrorCode // Result + +// Ok "bad things happened" +``` + +### Example 2 + +```fsharp +let result = + Error "bad things happened" // Result + |> ResultOption.mapError getErrorCode // Result + +// Error 1 +``` diff --git a/gitbook/result/ofChoice.md b/gitbook/result/ofChoice.md index 60777108..26e1335a 100644 --- a/gitbook/result/ofChoice.md +++ b/gitbook/result/ofChoice.md @@ -1,10 +1,10 @@ -## Result.ofChoice - -Transforms F#'s `Choice` value to `Result`. +# Result.ofChoice Namespace: `FsToolkit.ErrorHandling` -Function Signature: +Transforms F#'s `Choice` value to `Result`. + +## Function Signature ```fsharp Choice<'a,'b> -> Result<'a, 'b> @@ -21,4 +21,3 @@ Result.ofChoice (Choice1Of2 42) Result.ofChoice (Choice2Of2 "Something went wrong!") // Error "Something went wrong!" ``` - diff --git a/gitbook/result/operators.md b/gitbook/result/operators.md index b7bc6d8e..a0abbd90 100644 --- a/gitbook/result/operators.md +++ b/gitbook/result/operators.md @@ -1,4 +1,4 @@ -## Result Infix Operators +# Result Infix Operators Namespace: `FsToolkit.ErrorHandling.Operator.Result` @@ -46,4 +46,4 @@ Note that `>>=` is just a shortcut for `|> Result.bind`: let tryParseEvenInt str = tryParseInt str |> Result.bind evenInt -``` \ No newline at end of file +``` diff --git a/gitbook/result/orElseFunctions.md b/gitbook/result/orElseFunctions.md new file mode 100644 index 00000000..cd47e6e7 --- /dev/null +++ b/gitbook/result/orElseFunctions.md @@ -0,0 +1,111 @@ +# OrElse Functions + +## Result.orElse + +Namespace: `FsToolkit.ErrorHandling` + +Returns the result if the result is Ok, otherwise returns the given result + +### Function Signature + +```fsharp +Result<'ok, 'errorOutput> -> Result<'ok, 'error> + -> Result<'ok, 'errorOutput> +``` + +### Examples + +#### Example 1 + +```fsharp +let result : Result = + Ok 1 + |> Result.orElse (Ok 2) + +// Ok 1 +``` + +#### Example 2 + +```fsharp +let result : Result = + Ok 1 + |> Result.orElse (Error "Error") + +// Ok 1 +``` + +#### Example 3 + +```fsharp +let result : Result = + Error "Error" + |> Result.orElse (Ok 2) + +// Ok 2 +``` + +#### Example 4 + +```fsharp +let result : Result = + Error "Error" + |> Result.orElse (Error "Error 2") + +// Error "Error 2" +``` + +## Result.orElseWith + +Namespace: `FsToolkit.ErrorHandling` + +Returns the result if the result is Ok, otherwise evaluates the given function and returns the result. + +### Function Signature + +```fsharp +('error -> Result<'ok, 'errorOutput>) -> Result<'ok, 'error> + -> Result<'ok, 'errorOutput> +``` + +### Examples + +#### Example 1 + +```fsharp +let result : Result = + Ok 1 + |> Result.orElseWith (fun e -> e + 1 |> Ok) + +// Ok 1 +``` + +#### Example 2 + +```fsharp +let result : Result = + Ok 1 + |> Result.orElseWith (fun e -> e + 1 |> Error) + +// Ok 1 +``` + +#### Example 3 + +```fsharp +let result : Result = + Error 1 + |> Result.orElseWith (fun e -> e + 1 |> Ok) + +// Ok 2 +``` + +#### Example 4 + +```fsharp +let result : Result = + Error 1 + |> Result.orElseWith (fun e -> e + 1 |> Error) + +// Error 2 +``` diff --git a/gitbook/result/others.md b/gitbook/result/others.md index e9727753..ccb530cd 100644 --- a/gitbook/result/others.md +++ b/gitbook/result/others.md @@ -1,183 +1,104 @@ -## Other Useful Functions +# Other Result Functions -### isOk +## isOk Returns `true` if the value is Ok, otherwise returns `false`. -```fsharp -Result<_> -> bool -``` -### isError +### Function Signature -Returns `true` if the value is Error, otherwise returns `false`. ```fsharp Result<_> -> bool ``` -### requireTrue - -Returns the specified error if the value is `false`. -```fsharp -'a -> bool -> Result -``` -### requireFalse - -Returns the specified error if the value is `true`. -```fsharp -'a -> bool -> Result -``` - - -### requireSome - -Converts an Option to a Result, using the given error if None. -```fsharp -'a -> 'b option -> Result<'b, 'a> -``` -### requireNone - -Converts an Option to a Result, using the given error if Some. -```fsharp -'a -> 'b option -> Result -``` -### requireNotNull - -Converts a nullable value to a Result, using the given error if null. -```fsharp -'a -> 'b -> Result<'b, 'a> -``` +## isError +Returns `true` if the value is Error, otherwise returns `false`. -### requireEqual +### Function Signature -Returns Ok if the two values are equal, or the specified error if not. Same as `requireEqualTo`, but with a parameter order that fits normal function application better than piping. ```fsharp -'a -> 'a -> 'b -> Result +Result<_> -> bool ``` +## sequenceAsync -### requireEqualTo - -Returns Ok if the two values are equal, or the specified error if not. Same as `requireEqual`, but with a parameter order that fits piping better than normal function application. - -```fsharp -'a -> 'b -> 'a -> Result -``` - -### requireEmpty +Converts a `Result, 'b>` to `Async>`. -Returns Ok if the sequence is empty, or the specified error if not. +### Function Signature ```fsharp -'a -> seq<'b> -> Result +Result, 'b> -> Async> ``` -### requireNotEmpty +## traverseAsync -Returns the specified error if the sequence is empty, or Ok if not. +Converts a `Result<'a, 'error>` to `Async>` by applying the given function to the Ok value. -```fsharp -'a -> seq<'b> -> Result -``` - -### requireHead - -Returns the first item of the sequence if it exists, or the specified error if the sequence is empty +### Function Signature ```fsharp -'a -> seq<'b> -> Result<'b, 'a> +('okInput -> Async<'okOutput>) -> Result<'okInput, 'error> + -> Async> ``` - -### setError +## setError Replaces an error value with a custom error value +### Function Signature + ```fsharp 'a -> Result<'b, 'c> -> Result<'b, 'a> ``` -### withError +## withError Replaces a unit error value with a custom error value. Safer than `setError` since you're not losing any information. +### Function Signature + ```fsharp 'a -> Result<'b, unit> -> Result<'b, 'a> ``` - -### defaultValue +## defaultValue Returns the contained value if Ok, otherwise returns the provided value +### Function Signature + ```fsharp 'a -> Result<'a, 'b> -> 'a ``` -### defaultWith +## defaultWith Returns the contained value if Ok, otherwise evaluates the given function and returns the result. +### Function Signature + ```fsharp (unit -> 'a) -> Result<'a, 'b> -> 'a ``` -### valueOr +## valueOr Returns the Ok value or runs the specified function over the error value. +### Function Signature + ```fsharp ('b -> 'a) -> Result<'a, 'b> -> 'a ``` -### ignoreError +## ignoreError Same as `defaultValue` for a result where the Ok value is unit. The name describes better what is actually happening in this case. -```fsharp -Result -> unit -``` - -### tee - -If the result is Ok, executes the function on the Ok value. Passes through the input value unchanged. +### Function Signature ```fsharp -('a -> unit) -> Result<'a, 'b> -> Result<'a, 'b> -``` - -### teeError - -If the result is Error, executes the function on the Error value. Passes through the input value unchanged. - -```fsharp -('a -> unit) -> Result<'b, 'a> -> Result<'b, 'a> -``` - -### teeIf - -If the result is Ok and the predicate returns true for the wrapped value, executes the function on the Ok value. Passes through the input value unchanged. - -```fsharp -('a -> bool) -> ('a -> unit) -> Result<'a, 'b> -> Result<'a, 'b> -``` - -### teeErrorIf - -If the result is Error and the predicate returns true for the wrapped value, executes the function on the Error value. Passes through the input value unchanged. - -```fsharp -('a -> bool) -> ('a -> unit) -> Result<'b, 'a> -> Result<'b, 'a> -``` - - -### sequenceAsync - - -Converts a `Result, 'b>` to `Async>`. - -```fsharp -Result, 'b> -> Async> +Result -> unit ``` diff --git a/gitbook/result/requireFunctions.md b/gitbook/result/requireFunctions.md new file mode 100644 index 00000000..1e73cf0b --- /dev/null +++ b/gitbook/result/requireFunctions.md @@ -0,0 +1,319 @@ +# Require Functions + +## requireTrue + +Returns the specified error if the value is `false`. + +### Function Signature + +```fsharp +'a -> bool -> Result +``` + +### Examples + +#### Example 1 + +```fsharp +let result : Result = + true + |> Result.requireTrue "Value must be true" + +// Ok () +``` + +#### Example 2 + +```fsharp +let result : Result = + false + |> Result.requireTrue "Value must be true" + +// Error "Value must be true" +``` + +## requireFalse + +Returns the specified error if the value is `true`. + +### Function Signature + +```fsharp +'a -> bool -> Result +``` + +### Examples + +#### Example 1 + +```fsharp +let result : Result = + false + |> Result.requireFalse "Value must be false" + +// Ok () +``` + +#### Example 2 + +```fsharp +let result : Result = + true + |> Result.requireFalse "Value must be false" + +// Error "Value must be false" +``` + +## requireSome + +Converts an Option to a Result, using the given error if None. + +### Function Signature + +```fsharp +'a -> 'b option -> Result<'b, 'a> +``` + +### Examples + +#### Example 1 + +```fsharp +let result : Result = + Some 1 + |> Result.requireSome "Value must be Some" + +// Ok () +``` + +#### Example 2 + +```fsharp +let result : Result = + None + |> Result.requireSome "Value must be Some" + +// Error "Value must be Some" +``` + +## requireNone + +Converts an Option to a Result, using the given error if Some. + +### Function Signature + +```fsharp +'a -> 'b option -> Result +``` + +### Examples + +#### Example 1 + +```fsharp +let result : Result = + None + |> Result.requireNone "Value must be None" + +// Ok () +``` + +#### Example 2 + +```fsharp +let result : Result = + Some 1 + |> Result.requireNone "Value must be None" + +// Error "Value must be None" +``` + +## requireNotNull + +Converts a nullable value to a Result, using the given error if null. + +### Function Signature + +```fsharp +'a -> 'b -> Result<'b, 'a> +``` + +### Examples + +#### Example 1 + +```fsharp +let result : Result = + 1 + |> Result.requireNotNull "Value must be not null" + +// Ok () +``` + +#### Example 2 + +```fsharp +let result : Result = + null + |> Result.requireNotNull "Value must be not null" + +// Error "Value must be not null" +``` + +## requireEqual + +Returns Ok if the two values are equal, or the specified error if not. Same as `requireEqualTo`, but with a parameter order that fits normal function application better than piping. + +### Function Signature + +```fsharp +'a -> 'a -> 'b -> Result +``` + +### Examples + +#### Example 1 + +```fsharp +let result : Result = + Result.requireEqual 1 1 "Value must be equal to 1" + +// Ok () +``` + +#### Example 2 + +```fsharp +let result : Result = + Result.requireEqual 1 2 "Value must be equal to 1" + +// Error "Value must be equal to 1" +``` + +## requireEqualTo + +Returns Ok if the two values are equal, or the specified error if not. Same as `requireEqual`, but with a parameter order that fits piping better than normal function application. + +### Function Signature + +```fsharp +'a -> 'b -> 'a -> Result +``` + +### Examples + +#### Example 1 + +```fsharp +let result : Result = + 1 + |> Result.requireEqualTo "Value must be equal to 1" 1 + +// Ok () +``` + +#### Example 2 + +```fsharp +let result : Result = + 2 + |> Result.requireEqualTo "Value must be equal to 1" 1 + +// Error "Value must be equal to 1" +``` + +## requireEmpty + +Returns Ok if the sequence is empty, or the specified error if not. + +### Function Signature + +```fsharp +'a -> seq<'b> -> Result +``` + +### Examples + +#### Example 1 + +```fsharp +let result : Result = + [] + |> Result.requireEmpty "Value must be empty" + +// Ok () +``` + +#### Example 2 + +```fsharp +let result : Result = + [1] + |> Result.requireEmpty "Value must be empty" + +// Error "Value must be empty" +``` + +## requireNotEmpty + +Returns the specified error if the sequence is empty, or Ok if not. + +### Function Signature + +```fsharp +'a -> seq<'b> -> Result +``` + +### Examples + +#### Example 1 + +```fsharp +let result : Result = + [1] + |> Result.requireNotEmpty "Value must not be empty" + +// Ok () +``` + +#### Example 2 + +```fsharp +let result : Result = + [] + |> Result.requireNotEmpty "Value must not be empty" + +// Error "Value must not be empty" +``` + +## requireHead + +Returns the first item of the sequence if it exists, or the specified error if the sequence is empty + +### Function Signature + +```fsharp +'a -> seq<'b> -> Result<'b, 'a> +``` + +### Examples + +#### Example 1 + +```fsharp +let result : Result = + [1; 2; 3] + |> Result.requireHead "Seq must have head" + +// Ok 1 +``` + +#### Example 2 + +```fsharp +let result : Result = + [] + |> Result.requireHead "Seq must have head" + +// Error "Seq must have head" +``` diff --git a/gitbook/result/teeFunctions.md b/gitbook/result/teeFunctions.md new file mode 100644 index 00000000..10364bf9 --- /dev/null +++ b/gitbook/result/teeFunctions.md @@ -0,0 +1,131 @@ +# Tee Functions + +These functions allow us to execute side effects based on our result. They are useful for logging and other side effects that we want to execute without changing the result. + +Consider the following code for the examples below + +```fsharp +// string -> unit +let log (message: string) = + printfn "%s" message +``` + +## tee + +If the result is Ok, executes the function on the Ok value. Passes through the input value unchanged. + +### Function Signature + +```fsharp +('a -> unit) -> Result<'a, 'b> -> Result<'a, 'b> +``` + +### Examples + +#### Example 1 + +```fsharp +let result : Result = + Ok 1 + |> Result.tee (fun value -> log (sprintf "Value is %s" value)) + +// Value is 1 +// Ok 1 +``` + +## teeError + +If the result is Error, executes the function on the Error value. Passes through the input value unchanged. + +### Function Signature + +```fsharp +('a -> unit) -> Result<'b, 'a> -> Result<'b, 'a> +``` + +### Examples + +#### Example 1 + +```fsharp +let result : Result = + Error "Something bad happened" + |> Result.teeError (fun error -> log (sprintf "Error: %s" error)) + +// Error: Something bad happened +// Error "Something bad happened" +``` + +## teeIf + +If the result is Ok and the predicate returns true for the wrapped value, executes the function on the Ok value. Passes through the input value unchanged. + +### Function Signature + +```fsharp +('a -> bool) -> ('a -> unit) -> Result<'a, 'b> -> Result<'a, 'b> +``` + +### Examples + +#### Example 1 + +Since predicate condition is met, the log function is executed. + +```fsharp +let result : Result = + Ok 1 + |> Result.teeIf (fun value -> value = 1) (fun value -> log (sprintf "Value is %s" value)) + +// Value is 1 +// Ok 1 +``` + +#### Example 2 + +Since predicate condition is not met, the log function is not executed. + +```fsharp +let result : Result = + Ok 2 + |> Result.teeIf (fun value -> value = 1) (fun value -> log (sprintf "Value is %s" value)) + +// Ok 1 +``` + +## teeErrorIf + +If the result is Error and the predicate returns true for the wrapped value, executes the function on the Error value. Passes through the input value unchanged. + +### Function Signature + +```fsharp +('a -> bool) -> ('a -> unit) -> Result<'b, 'a> -> Result<'b, 'a> +``` + +### Examples + +#### Example 1 + +Since predicate condition is met, the log function is executed. + +```fsharp +let result : Result = + Error "Something bad happened" + |> Result.teeErrorIf (fun error -> error = "Something bad happened") (fun error -> log (sprintf "Error: %s" error)) + +// Error: Something bad happened +// Error "Something bad happened" +``` + +#### Example 2 + +Since predicate condition is not met, the log function is not executed. + +```fsharp +let result : Result = + Error "Something bad happened" + |> Result.teeErrorIf (fun error -> error = "Something else bad happened") (fun error -> log (sprintf "Error: %s" error)) + +// Error "Something bad happened" +``` diff --git a/gitbook/result/zip.md b/gitbook/result/zip.md new file mode 100644 index 00000000..ef3b620c --- /dev/null +++ b/gitbook/result/zip.md @@ -0,0 +1,32 @@ +# Result.zip + +Namespace: `FsToolkit.ErrorHandling` + +## Function Signature + +```fsharp +Result<'leftOk, 'error> -> Result<'rightOk, 'error> -> Result<'leftOk * 'rightOk, 'error> +``` + +## Examples + +### Example 1 + +```fsharp +let result = Result.zip (Ok 1) (Ok 2) +// Ok (Some(1, 2)) +``` + +### Example 2 + +```fsharp +let result = Result.zip (Ok 1) (Error "Bad") +// Error "Bad" +``` + +### Example 3 + +```fsharp +let result = Result.zip (Error "Bad1") (Error "Bad2") +// Error "Bad1" +``` diff --git a/gitbook/result/zipError.md b/gitbook/result/zipError.md new file mode 100644 index 00000000..c0563f6d --- /dev/null +++ b/gitbook/result/zipError.md @@ -0,0 +1,32 @@ +# Result.zipError + +Namespace: `FsToolkit.ErrorHandling` + +## Function Signature + +```fsharp +Result<'ok, 'leftError> -> Result<'ok, 'rightError> -> Result<'ok, 'leftError * 'rightError> +``` + +## Examples + +### Example 1 + +```fsharp +let result = Result.zip (Ok 1) (Ok 2) +// Ok 1 +``` + +### Example 2 + +```fsharp +let result = Result.zip (Ok 1) (Error "Bad") +// Ok 1 +``` + +### Example 3 + +```fsharp +let result = Result.zip (Error "Bad1") (Error "Bad2") +// Error("Bad1", "Bad2") +``` diff --git a/gitbook/resultOption/map.md b/gitbook/resultOption/map.md index 88d279cc..646e14c6 100644 --- a/gitbook/resultOption/map.md +++ b/gitbook/resultOption/map.md @@ -16,7 +16,7 @@ Take the following functions for example ```fsharp // string -> int -let remainingCharacters (string: prompt) = +let remainingCharacters (prompt: string) = 280 - prompt.Length ``` From d9f8d0eca95042e109fa97df64f793a4a9e3a316 Mon Sep 17 00:00:00 2001 From: 1eyewonder Date: Mon, 10 Jul 2023 15:57:36 -0500 Subject: [PATCH 04/10] Created submenu to match other list functions --- gitbook/SUMMARY.md | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/gitbook/SUMMARY.md b/gitbook/SUMMARY.md index 2e857430..6b834cef 100644 --- a/gitbook/SUMMARY.md +++ b/gitbook/SUMMARY.md @@ -28,9 +28,10 @@ * [sequenceResultA](list/sequenceResultA.md) * Option - * [traverseResult](option/traverseResult.md) - * [sequenceResult](option/sequenceResult.md) * [Computation Expression](option/ce.md) + * Lists + * [traverseResult](option/traverseResult.md) + * [sequenceResult](option/sequenceResult.md) * ResultOption * [apply](resultOption/apply.md) From 75e7ab108b11766a3f6f872bad3606d0f432512e Mon Sep 17 00:00:00 2001 From: 1eyewonder Date: Mon, 10 Jul 2023 16:01:15 -0500 Subject: [PATCH 05/10] Alphabetized AsyncResult, AsyncResultOption, Validation, and AsyncValidation items in Summary --- gitbook/SUMMARY.md | 27 +++++++++++++-------------- 1 file changed, 13 insertions(+), 14 deletions(-) diff --git a/gitbook/SUMMARY.md b/gitbook/SUMMARY.md index 6b834cef..c7e739ef 100644 --- a/gitbook/SUMMARY.md +++ b/gitbook/SUMMARY.md @@ -46,17 +46,17 @@ * [zipError](resultOption/zipError.md) * AsyncResult + * [apply](asyncResult/apply.md) + * [bind](asyncResult/bind.md) + * [Computation Expression](asyncResult/ce.md) + * [foldResult](asyncResult/foldResult.md) + * [ignore](asyncResult/ignore.md) * [map](asyncResult/map.md) * [map2](asyncResult/map2.md) * [map3](asyncResult/map3.md) * [mapError](asyncResult/mapError.md) - * [apply](asyncResult/apply.md) - * [foldResult](asyncResult/foldResult.md) * [ofTask](asyncResult/ofTask.md) * [ofTaskAction](asyncResult/ofTaskAction.md) - * [bind](asyncResult/bind.md) - * [ignore](asyncResult/ignore.md) - * [Computation Expression](asyncResult/ce.md) * [Operators](asyncResult/operators.md) * [Other Functions](asyncResult/others.md) * List @@ -66,31 +66,30 @@ * [sequenceAsyncResultA](list/sequenceAsyncResultA.md) * AsyncResultOption - * [map](asyncResultOption/map.md) - * [map2](asyncResultOption/map2.md) - * [map3](asyncResultOption/map3.md) * [apply](asyncResultOption/apply.md) * [bind](asyncResultOption/bind.md) - * [ignore](asyncResultOption/ignore.md) * [Computation Expression](asyncResultOption/ce.md) + * [ignore](asyncResultOption/ignore.md) + * [map](asyncResultOption/map.md) + * [map2](asyncResultOption/map2.md) + * [map3](asyncResultOption/map3.md) * [Operators](asyncResultOption/operators.md) * [Validation](validation/index.md) + * [apply](validation/apply.md) + * [Computation Expression](validation/ce.md) * [map2](validation/map2.md) * [map3](validation/map3.md) - * [apply](validation/apply.md) * [ofResult](validation/ofResult.md) * [Operators](validation/operators.md) - * [Result.tryCreate](validation/tryCreate.md) - * [Computation Expression](validation/ce.md) * [AsyncValidation](asyncValidation/index.md) + * [apply](asyncValidation/apply.md) + * [Computation Expression](asyncValidation/ce.md) * [map2](asyncValidation/map2.md) * [map3](asyncValidation/map3.md) - * [apply](asyncValidation/apply.md) * [ofResult](asyncValidation/ofResult.md) * [Operators](asyncValidation/operators.md) - * [Computation Expression](asyncValidation/ce.md) * FsToolkit.ErrorHandling.AsyncSeq * FsToolkit.ErrorHandling.IcedTasks From 718c52fee0b729bc620eb725082ff62cb80ee0c5 Mon Sep 17 00:00:00 2001 From: 1eyewonder Date: Mon, 10 Jul 2023 16:09:03 -0500 Subject: [PATCH 06/10] Alphabetized IcedTasks in Summary and removed invalid ones --- gitbook/SUMMARY.md | 14 +++++--------- 1 file changed, 5 insertions(+), 9 deletions(-) diff --git a/gitbook/SUMMARY.md b/gitbook/SUMMARY.md index c7e739ef..b133de6d 100644 --- a/gitbook/SUMMARY.md +++ b/gitbook/SUMMARY.md @@ -94,24 +94,20 @@ * FsToolkit.ErrorHandling.AsyncSeq * FsToolkit.ErrorHandling.IcedTasks * [CancellableTaskResult](cancellableTaskResult/index.md) - * [map](cancellableTaskResult/map.md) - * [map2](cancellableTaskResult/map2.md) - * [map3](cancellableTaskResult/map3.md) - * [mapError](cancellableTaskResult/mapError.md) * [apply](cancellableTaskResult/apply.md) - * [foldResult](cancellableTaskResult/foldResult.md) - * [ofAsync](cancellableTaskResult/ofAsync.md) * [bind](cancellableTaskResult/bind.md) - * [ignore](cancellableTaskResult/ignore.md) * [Computation Expression](cancellableTaskResult/ce.md) + * [map](cancellableTaskResult/map.md) * [Operators](cancellableTaskResult/operators.md) * [Other Functions](cancellableTaskResult/others.md) + * [CancellableTaskValidation](cancellableTaskValidation/index.md) - * [map2](cancellableTaskValidation/map2.md) - * [map3](cancellableTaskValidation/map3.md) * [apply](cancellableTaskValidation/apply.md) * [Computation Expression](cancellableTaskValidation/ce.md) + * [map2](cancellableTaskValidation/map2.md) + * [map3](cancellableTaskValidation/map3.md) * [Operators](cancellableTaskValidation/operators.md) + * FsToolkit.ErrorHandling.JobResult * JobResult * [map](jobResult/map.md) From 677167c68e819c1a008ac9adf1d47c932f7cac9a Mon Sep 17 00:00:00 2001 From: 1eyewonder Date: Mon, 10 Jul 2023 16:15:35 -0500 Subject: [PATCH 07/10] Clean up JobResult Summary items --- gitbook/SUMMARY.md | 17 ++++++++++++----- 1 file changed, 12 insertions(+), 5 deletions(-) diff --git a/gitbook/SUMMARY.md b/gitbook/SUMMARY.md index b133de6d..dd6fc030 100644 --- a/gitbook/SUMMARY.md +++ b/gitbook/SUMMARY.md @@ -109,19 +109,26 @@ * [Operators](cancellableTaskValidation/operators.md) * FsToolkit.ErrorHandling.JobResult + * Job + + * JobOption + * [ce](jobOption/ce.md) + * JobResult + * [apply](jobResult/apply.md) + * [bind](jobResult/bind.md) + * [Computation Expression](jobResult/ce.md) + * [ignore](jobResult/ignore.md) * [map](jobResult/map.md) * [map2](jobResult/map2.md) * [map3](jobResult/map3.md) * [mapError](jobResult/mapError.md) - * [apply](jobResult/apply.md) - * [foldResult](jobResult/foldResult.md) * [ofTask](jobResult/ofTask.md) - * [bind](jobResult/bind.md) - * [ignore](jobResult/ignore.md) - * [Computation Expression](jobResult/ce.md) * [Operators](jobResult/operators.md) * [Other Functions](jobResult/others.md) + + * JobResultOption + * FsToolkit.ErrorHandling.TaskResult * TaskResult * [map](taskResult/map.md) From e69a50ab15cb72ead581b6d18ae258cfca960831 Mon Sep 17 00:00:00 2001 From: 1eyewonder Date: Mon, 10 Jul 2023 16:23:42 -0500 Subject: [PATCH 08/10] Cleaned up TaskResult items in Summary --- gitbook/SUMMARY.md | 27 +++++++++++++++------------ gitbook/asyncValidation/index.md | 2 +- gitbook/validation/index.md | 4 ++-- 3 files changed, 18 insertions(+), 15 deletions(-) diff --git a/gitbook/SUMMARY.md b/gitbook/SUMMARY.md index dd6fc030..bc1be765 100644 --- a/gitbook/SUMMARY.md +++ b/gitbook/SUMMARY.md @@ -130,17 +130,20 @@ * JobResultOption * FsToolkit.ErrorHandling.TaskResult + * Task + + * TaskOption + * [Computation Expression](taskOption/ce.md) + * TaskResult + * [apply](taskResult/apply.md) + * [bind](taskResult/bind.md) + * [Computation Expression](taskResult/ce.md) + * [ignore](taskResult/ignore.md) * [map](taskResult/map.md) * [map2](taskResult/map2.md) * [map3](taskResult/map3.md) * [mapError](taskResult/mapError.md) - * [apply](taskResult/apply.md) - * [foldResult](taskResult/foldResult.md) - * [ofAsync](taskResult/ofAsync.md) - * [bind](taskResult/bind.md) - * [ignore](taskResult/ignore.md) - * [Computation Expression](taskResult/ce.md) * [Operators](taskResult/operators.md) * [Other Functions](taskResult/others.md) * Lists @@ -148,16 +151,16 @@ * [sequenceTaskResultM](list/sequenceTaskResultM.md) * [traverseTaskResultA](list/traverseTaskResultA.md) * [sequenceTaskResultA](list/sequenceTaskResultA.md) + * TaskResultOption - * [map](taskResultOption/map.md) - * [map2](taskResultOption/map2.md) - * [map3](taskResultOption/map3.md) * [apply](taskResultOption/apply.md) * [bind](taskResultOption/bind.md) - * [ignore](taskResultOption/ignore.md) * [Computation Expression](taskResultOption/ce.md) + * [ignore](taskResultOption/ignore.md) + * [map](taskResultOption/map.md) + * [map2](taskResultOption/map2.md) + * [map3](taskResultOption/map3.md) * [Operators](taskResultOption/operators.md) - * TaskOption - * [Computation Expression](taskOption/ce.md) + * General Docs * [Bind Mappings](bindMappings.md) diff --git a/gitbook/asyncValidation/index.md b/gitbook/asyncValidation/index.md index 4a30e16a..b6de6115 100644 --- a/gitbook/asyncValidation/index.md +++ b/gitbook/asyncValidation/index.md @@ -1,4 +1,4 @@ -## AsyncValidation +# AsyncValidation Namespace: `FsToolkit.ErrorHandling` diff --git a/gitbook/validation/index.md b/gitbook/validation/index.md index 8f9b33e2..e2f617e8 100644 --- a/gitbook/validation/index.md +++ b/gitbook/validation/index.md @@ -1,5 +1,5 @@ -## Validation +# Validation Namespace: `FsToolkit.ErrorHandling` -This module provides utility functions and infix operators to work with `Result<'a, 'b list>`. \ No newline at end of file +This module provides utility functions and infix operators to work with `Result<'a, 'b list>`. From d0a95ee4ba6a6f18abe68f0efe0f1f1d3151d6ab Mon Sep 17 00:00:00 2001 From: 1eyewonder Date: Mon, 10 Jul 2023 18:08:02 -0500 Subject: [PATCH 09/10] WIP adding pr link to needed document pages --- gitbook/SUMMARY.md | 58 ++++++++++++++++++++++++++++++++++++++++++++++ gitbook/pr.md | 1 + 2 files changed, 59 insertions(+) create mode 100644 gitbook/pr.md diff --git a/gitbook/SUMMARY.md b/gitbook/SUMMARY.md index bc1be765..b82a77d6 100644 --- a/gitbook/SUMMARY.md +++ b/gitbook/SUMMARY.md @@ -28,7 +28,15 @@ * [sequenceResultA](list/sequenceResultA.md) * Option + * [bind](pr.md) + * [bindNull](pr.md) * [Computation Expression](option/ce.md) + * [either](pr.md) + * [map](pr.md) + * [ofPair](pr.md) + * [ofValueOption](pr.md) + * [toValueOption](pr.md) + * [zip](pr.md) * Lists * [traverseResult](option/traverseResult.md) * [sequenceResult](option/sequenceResult.md) @@ -41,6 +49,10 @@ * [map](resultOption/map.md) * [map2](resultOption/map2.md) * [map3](resultOption/map3.md) + * [mapError](pr.md) + * [ofResult](pr.md) + * [ofOption](pr.md) + * [ofChoice](pr.md) * [Operators](resultOption/operators.md) * [zip](resultOption/zip.md) * [zipError](resultOption/zipError.md) @@ -49,16 +61,23 @@ * [apply](asyncResult/apply.md) * [bind](asyncResult/bind.md) * [Computation Expression](asyncResult/ce.md) + * [error](pr.md) * [foldResult](asyncResult/foldResult.md) * [ignore](asyncResult/ignore.md) * [map](asyncResult/map.md) * [map2](asyncResult/map2.md) * [map3](asyncResult/map3.md) * [mapError](asyncResult/mapError.md) + * [ofAsync](pr.md) + * [ofResult](pr.md) * [ofTask](asyncResult/ofTask.md) * [ofTaskAction](asyncResult/ofTaskAction.md) + * [ok](pr.md) * [Operators](asyncResult/operators.md) * [Other Functions](asyncResult/others.md) + * [retn](pr.md) + * [zip](pr.md) + * [zipError](pr.md) * List * [traverseAsyncResultM](list/traverseAsyncResultM.md) * [sequenceAsyncResultM](list/sequenceAsyncResultM.md) @@ -73,33 +92,63 @@ * [map](asyncResultOption/map.md) * [map2](asyncResultOption/map2.md) * [map3](asyncResultOption/map3.md) + * [ofAsyncOption](pr.md) + * [ofAsyncResult](pr.md) + * [ofOption](pr.md) + * [ofResult](pr.md) * [Operators](asyncResultOption/operators.md) + * [retn](pr.md) * [Validation](validation/index.md) * [apply](validation/apply.md) * [Computation Expression](validation/ce.md) + * [error](pr.md) + * [map](pr.md) * [map2](validation/map2.md) * [map3](validation/map3.md) + * [mapError](pr.md) + * [mapErrors](pr.md) + * [ofChoice](pr.md) * [ofResult](validation/ofResult.md) + * [ok](pr.md) * [Operators](validation/operators.md) + * [retn](pr.md) + * [returnError](pr.md) + * [zip](pr.md) * [AsyncValidation](asyncValidation/index.md) * [apply](asyncValidation/apply.md) * [Computation Expression](asyncValidation/ce.md) + * [error](pr.md) + * [map](pr.md) * [map2](asyncValidation/map2.md) * [map3](asyncValidation/map3.md) + * [mapError](pr.md) + * [mapErrors](pr.md) + * [ofChoice](pr.md) * [ofResult](asyncValidation/ofResult.md) + * [ok](pr.md) * [Operators](asyncValidation/operators.md) + * [retn](pr.md) + * [returnError](pr.md) + * [zip](pr.md) * FsToolkit.ErrorHandling.AsyncSeq + * AsyncSeq + * [Computation Expression](pr.md) + * FsToolkit.ErrorHandling.IcedTasks * [CancellableTaskResult](cancellableTaskResult/index.md) * [apply](cancellableTaskResult/apply.md) * [bind](cancellableTaskResult/bind.md) * [Computation Expression](cancellableTaskResult/ce.md) + * [getCancellationToken](pr.md) * [map](cancellableTaskResult/map.md) * [Operators](cancellableTaskResult/operators.md) * [Other Functions](cancellableTaskResult/others.md) + * [singleton](pr.md) + * [zip](pr.md) + * [parallelZip](pr.md) * [CancellableTaskValidation](cancellableTaskValidation/index.md) * [apply](cancellableTaskValidation/apply.md) @@ -110,9 +159,18 @@ * FsToolkit.ErrorHandling.JobResult * Job + * [apply](pr.md) + * [map2](pr.md) + * [map3](pr.md) + * [singleton](pr.md) + * [zip](pr.md) * JobOption + * [apply](pr.md) + * [bind](pr.md) * [ce](jobOption/ce.md) + * [either](pr.md) + * [map](pr.md) * JobResult * [apply](jobResult/apply.md) diff --git a/gitbook/pr.md b/gitbook/pr.md new file mode 100644 index 00000000..d96ffe07 --- /dev/null +++ b/gitbook/pr.md @@ -0,0 +1 @@ +This feature is supported in the library, but we have not got to documenting it yet. Feel free to open an [issue or PR](https://github.com/demystifyfp/FsToolkit.ErrorHandling) to add documentation for this feature. From 6b3302cde25435a2c42eb1ff08c29427b8050686 Mon Sep 17 00:00:00 2001 From: 1eyewonder Date: Tue, 11 Jul 2023 12:49:35 -0500 Subject: [PATCH 10/10] Added pr-able items to Summary.md --- gitbook/SUMMARY.md | 65 ++++++++++++++++++++++++++++++++++++++++------ gitbook/pr.md | 2 ++ 2 files changed, 59 insertions(+), 8 deletions(-) diff --git a/gitbook/SUMMARY.md b/gitbook/SUMMARY.md index b82a77d6..b7c949c9 100644 --- a/gitbook/SUMMARY.md +++ b/gitbook/SUMMARY.md @@ -72,10 +72,8 @@ * [ofResult](pr.md) * [ofTask](asyncResult/ofTask.md) * [ofTaskAction](asyncResult/ofTaskAction.md) - * [ok](pr.md) * [Operators](asyncResult/operators.md) * [Other Functions](asyncResult/others.md) - * [retn](pr.md) * [zip](pr.md) * [zipError](pr.md) * List @@ -97,7 +95,6 @@ * [ofOption](pr.md) * [ofResult](pr.md) * [Operators](asyncResultOption/operators.md) - * [retn](pr.md) * [Validation](validation/index.md) * [apply](validation/apply.md) @@ -110,9 +107,7 @@ * [mapErrors](pr.md) * [ofChoice](pr.md) * [ofResult](validation/ofResult.md) - * [ok](pr.md) * [Operators](validation/operators.md) - * [retn](pr.md) * [returnError](pr.md) * [zip](pr.md) @@ -127,9 +122,7 @@ * [mapErrors](pr.md) * [ofChoice](pr.md) * [ofResult](asyncValidation/ofResult.md) - * [ok](pr.md) * [Operators](asyncValidation/operators.md) - * [retn](pr.md) * [returnError](pr.md) * [zip](pr.md) @@ -146,16 +139,25 @@ * [map](cancellableTaskResult/map.md) * [Operators](cancellableTaskResult/operators.md) * [Other Functions](cancellableTaskResult/others.md) - * [singleton](pr.md) * [zip](pr.md) * [parallelZip](pr.md) * [CancellableTaskValidation](cancellableTaskValidation/index.md) * [apply](cancellableTaskValidation/apply.md) + * [bind](pr.md) * [Computation Expression](cancellableTaskValidation/ce.md) + * [error](pr.md) + * [getCancellationToken](pr.md) + * [map](pr.md) * [map2](cancellableTaskValidation/map2.md) * [map3](cancellableTaskValidation/map3.md) + * [mapError](pr.md) + * [mapErrors](pr.md) + * [ofChoice](pr.md) + * [ofResult](pr.md) * [Operators](cancellableTaskValidation/operators.md) + * [zip](pr.md) + * [parallelZip](pr.md) * FsToolkit.ErrorHandling.JobResult * Job @@ -175,35 +177,82 @@ * JobResult * [apply](jobResult/apply.md) * [bind](jobResult/bind.md) + * [catch](pr.md) * [Computation Expression](jobResult/ce.md) + * [error](pr.md) + * [fromTask](pr.md) + * [fromUnitTask](pr.md) * [ignore](jobResult/ignore.md) * [map](jobResult/map.md) * [map2](jobResult/map2.md) * [map3](jobResult/map3.md) * [mapError](jobResult/mapError.md) + * [ofAsync](pr.md) + * [ofJob](pr.md) + * [ofResult](pr.md) * [ofTask](jobResult/ofTask.md) * [Operators](jobResult/operators.md) * [Other Functions](jobResult/others.md) + * [returnError](pr.md) + * [zip](pr.md) + * [zipError](pr.md) + * Lists + * [traverseJobResultM](pr.md) + * [sequenceJobResultM](pr.md) + * [traverseJobResultA](pr.md) + * [sequenceJobResultA](pr.md) * JobResultOption + * [apply](pr.md) + * [bind](pr.md) + * [Computation Expression](pr.md) + * [ignore](pr.md) + * [map](pr.md) + * [map2](pr.md) + * [map3](pr.md) * FsToolkit.ErrorHandling.TaskResult * Task + * [apply](pr.md) + * [bind](pr.md) + * [bindV](pr.md) + * [catch](pr.md) + * [Computation Expression](pr.md) + * [ignore](pr.md) + * [map](pr.md) + * [mapV](pr.md) + * [map2](pr.md) + * [map3](pr.md) + * [ofUnit](pr.md) + * [zip](pr.md) * TaskOption + * [apply](pr.md) + * [bind](pr.md) * [Computation Expression](taskOption/ce.md) + * [either](pr.md) + * [map](pr.md) + * [some](pr.md) + * [zip](pr.md) * TaskResult * [apply](taskResult/apply.md) * [bind](taskResult/bind.md) + * [catch](pr.md) * [Computation Expression](taskResult/ce.md) * [ignore](taskResult/ignore.md) * [map](taskResult/map.md) * [map2](taskResult/map2.md) * [map3](taskResult/map3.md) * [mapError](taskResult/mapError.md) + * [ofAsync](pr.md) + * [ofResult](pr.md) + * [ofTask](pr.md) * [Operators](taskResult/operators.md) * [Other Functions](taskResult/others.md) + * [returnError](pr.md) + * [zip](pr.md) + * [zipError](pr.md) * Lists * [traverseTaskResultM](list/traverseTaskResultM.md) * [sequenceTaskResultM](list/sequenceTaskResultM.md) diff --git a/gitbook/pr.md b/gitbook/pr.md index d96ffe07..966fe1f1 100644 --- a/gitbook/pr.md +++ b/gitbook/pr.md @@ -1 +1,3 @@ +# Sorry, this page is not yet documented + This feature is supported in the library, but we have not got to documenting it yet. Feel free to open an [issue or PR](https://github.com/demystifyfp/FsToolkit.ErrorHandling) to add documentation for this feature.