diff --git a/gitbook/asyncOption/ce.md b/gitbook/asyncOption/ce.md index 4177bbf6..4d104e9e 100644 --- a/gitbook/asyncOption/ce.md +++ b/gitbook/asyncOption/ce.md @@ -9,13 +9,13 @@ Namespace: `FsToolkit.ErrorHandling` Given a personId and an age, find a person and update their age. ```fsharp -tryParseInt : string -> Option -tryFindPersonById : int -> Async> +tryParseInt : string -> int option +tryFindPersonById : int -> Async updatePerson : Person -> Async ``` ```fsharp -// Async> +// Async let addResult = asyncOption { let! personId = tryParseInt "3001" let! age = tryParseInt "35" diff --git a/gitbook/asyncResultOption/operators.md b/gitbook/asyncResultOption/operators.md index 4061fbd8..e75cc922 100644 --- a/gitbook/asyncResultOption/operators.md +++ b/gitbook/asyncResultOption/operators.md @@ -2,7 +2,7 @@ Namespace: `FsToolkit.ErrorHandling.Operator.AsyncResultOption` -FsToolkit.ErrorHandling provides the standard infix operators for the `map` (``), `apply` (`<*>`), and `bind` (`>>=`) functions of the `Result,_>` type. +FsToolkit.ErrorHandling provides the standard infix operators for the `map` (``), `apply` (`<*>`), and `bind` (`>>=`) functions of the `Result<'T option, 'E>` type. ## Examples diff --git a/gitbook/cancellableTaskOption/ce.md b/gitbook/cancellableTaskOption/ce.md index a525ea22..4df822ca 100644 --- a/gitbook/cancellableTaskOption/ce.md +++ b/gitbook/cancellableTaskOption/ce.md @@ -9,7 +9,7 @@ Namespace: `FsToolkit.ErrorHandling` Given a personId and an age, find a person and update their age. ```fsharp -tryParseInt : string -> Option +tryParseInt : string -> int option tryFindPersonById : int -> CancellableTask updatePerson : Person -> CancellableTask ``` diff --git a/gitbook/jobOption/ce.md b/gitbook/jobOption/ce.md index 6ba0a4c8..d330cfa7 100644 --- a/gitbook/jobOption/ce.md +++ b/gitbook/jobOption/ce.md @@ -9,13 +9,13 @@ Namespace: `FsToolkit.ErrorHandling` Given a personId and an age, find a person and update their age. ```fsharp -tryParseInt : string -> Option -tryFindPersonById : int -> Job> +tryParseInt : string -> int option +tryFindPersonById : int -> Job updatePerson : Person -> Job ``` ```fsharp -// Job> +// Job let addResult = jobOption { let! personId = tryParseInt "3001" let! age = tryParseInt "35" diff --git a/gitbook/option/bindNull.md b/gitbook/option/bindNull.md index bb7a50fd..943a550f 100644 --- a/gitbook/option/bindNull.md +++ b/gitbook/option/bindNull.md @@ -28,7 +28,7 @@ Option.bindNull toNullable userInput ```fsharp open System -let userInput : Option = None +let userInput : int option = None let toNullable<'T> x = Nullable x Option.bindNull toNullable userInput diff --git a/gitbook/option/ce.md b/gitbook/option/ce.md index e11f95e6..cbb159c5 100644 --- a/gitbook/option/ce.md +++ b/gitbook/option/ce.md @@ -7,7 +7,7 @@ Namespace: `FsToolkit.ErrorHandling` ### Example 1 ```fsharp -// Option +// int option let addResult = option { let! x = tryParseInt "35" let! y = tryParseInt "5" diff --git a/gitbook/resultOption/ofOption.md b/gitbook/resultOption/ofOption.md index 3be295fc..ec3d49f4 100644 --- a/gitbook/resultOption/ofOption.md +++ b/gitbook/resultOption/ofOption.md @@ -7,7 +7,7 @@ Transforms a `'T Option` value to `Result<'T option, 'Error>`. ## Function Signature ```fsharp -Option<'T> -> Result<'T option, 'Error> +'T option -> Result<'T option, 'Error> ``` ## Examples diff --git a/gitbook/resultOption/operators.md b/gitbook/resultOption/operators.md index 0df09976..9cb3d018 100644 --- a/gitbook/resultOption/operators.md +++ b/gitbook/resultOption/operators.md @@ -2,7 +2,7 @@ Namespace: `FsToolkit.ErrorHandling.Operator.ResultOption` -FsToolkit.ErrorHandling provides the standard infix operators for the `map` (``), `apply` (`<*>`), and `bind` (`>>=`) functions of the `Result,_>` type. +FsToolkit.ErrorHandling provides the standard infix operators for the `map` (``), `apply` (`<*>`), and `bind` (`>>=`) functions of the `Result<'T option, 'E>` type. In addition to these, it also offers an another infix operator `<*^>` for usage with normal `Result` values (without an inner `Option`). It has the following function signature: diff --git a/gitbook/taskOption/ce.md b/gitbook/taskOption/ce.md index 531532c3..e55d0639 100644 --- a/gitbook/taskOption/ce.md +++ b/gitbook/taskOption/ce.md @@ -9,13 +9,13 @@ Namespace: `FsToolkit.ErrorHandling` Given a personId and an age, find a person and update their age. ```fsharp -tryParseInt : string -> Option -tryFindPersonById : int -> Task> +tryParseInt : string -> int option +tryFindPersonById : int -> Task updatePerson : Person -> Task ``` ```fsharp -// Task> +// Task let addResult = taskOption { let! personId = tryParseInt "3001" let! age = tryParseInt "35" diff --git a/gitbook/taskResultOption/operators.md b/gitbook/taskResultOption/operators.md index 1cd7d455..443be35e 100644 --- a/gitbook/taskResultOption/operators.md +++ b/gitbook/taskResultOption/operators.md @@ -2,7 +2,7 @@ Namespace: `FsToolkit.ErrorHandling.Operator.TaskResultOption` -FsToolkit.ErrorHandling provides the standard infix operators for the `map` (``), `apply` (`<*>`), and `bind` (`>>=`) functions of the `Result,_>` type. +FsToolkit.ErrorHandling provides the standard infix operators for the `map` (``), `apply` (`<*>`), and `bind` (`>>=`) functions of the `Result<'T option, 'E>` type. ## Examples diff --git a/src/FsToolkit.ErrorHandling/Array.fs b/src/FsToolkit.ErrorHandling/Array.fs index a8f2cca7..ac2b0409 100644 --- a/src/FsToolkit.ErrorHandling/Array.fs +++ b/src/FsToolkit.ErrorHandling/Array.fs @@ -127,7 +127,7 @@ module Array = let sequenceAsyncResultA xs = traverseAsyncResultA id xs - let rec private traverseOptionM' (state: Option<_>) (f: _ -> Option<_>) xs = + let rec private traverseOptionM' (state: _ option) (f: _ -> _ option) xs = match xs with | [||] -> state @@ -147,7 +147,7 @@ module Array = | Some _ -> traverseOptionM' r f xs | None -> r - let rec private traverseAsyncOptionM' (state: Async>) (f: _ -> Async>) xs = + let rec private traverseAsyncOptionM' (state: Async<_ option>) (f: _ -> Async<_ option>) xs = match xs with | [||] -> state diff --git a/src/FsToolkit.ErrorHandling/AsyncOption.fs b/src/FsToolkit.ErrorHandling/AsyncOption.fs index 4b3001e9..5f16748c 100644 --- a/src/FsToolkit.ErrorHandling/AsyncOption.fs +++ b/src/FsToolkit.ErrorHandling/AsyncOption.fs @@ -96,9 +96,9 @@ module AsyncOption = /// The option if the option is Some, else returns . /// let inline orElse - (ifNone: Async>) - (input: Async>) - : Async> = + (ifNone: Async<'value option>) + (input: Async<'value option>) + : Async<'value option> = Async.bind (Option.either some (fun _ -> ifNone)) input /// @@ -121,7 +121,7 @@ module AsyncOption = /// The option if the option is Some, else the result of executing . /// let inline orElseWith - ([] ifNoneFunc: unit -> Async>) - (input: Async>) - : Async> = + ([] ifNoneFunc: unit -> Async<'value option>) + (input: Async<'value option>) + : Async<'value option> = Async.bind (Option.either some ifNoneFunc) input diff --git a/src/FsToolkit.ErrorHandling/AsyncResultOption.fs b/src/FsToolkit.ErrorHandling/AsyncResultOption.fs index cb426fea..b0d7195b 100644 --- a/src/FsToolkit.ErrorHandling/AsyncResultOption.fs +++ b/src/FsToolkit.ErrorHandling/AsyncResultOption.fs @@ -1,7 +1,7 @@ namespace FsToolkit.ErrorHandling -type AsyncResultOption<'ok, 'error> = Async, 'error>> +type AsyncResultOption<'ok, 'error> = Async> [] module AsyncResultOption = @@ -77,11 +77,11 @@ module AsyncResultOption = r |> AsyncResult.map Some - let inline ofOption (r: Option<'ok>) = + let inline ofOption (r: 'ok option) = r |> Ok |> Async.singleton - let inline ofAsyncOption (r: Async>) = + let inline ofAsyncOption (r: Async<'ok option>) = r |> Async.map Ok diff --git a/src/FsToolkit.ErrorHandling/AsyncResultOptionCE.fs b/src/FsToolkit.ErrorHandling/AsyncResultOptionCE.fs index da5370b9..ae52c939 100644 --- a/src/FsToolkit.ErrorHandling/AsyncResultOptionCE.fs +++ b/src/FsToolkit.ErrorHandling/AsyncResultOptionCE.fs @@ -130,7 +130,7 @@ module AsyncResultOptionCEExtensions = /// /// Method lets us transform data types into our internal representation. /// - member inline this.Source(optional: Option<'ok>) : AsyncResultOption<'ok, 'error> = + member inline this.Source(optional: 'ok option) : AsyncResultOption<'ok, 'error> = AsyncResultOption.ofOption optional /// @@ -194,7 +194,7 @@ module AsyncResultOptionCEExtensionsHighPriority = /// /// Method lets us transform data types into our internal representation. /// - member inline _.Source(result: Async>) : AsyncResultOption<'ok, 'error> = + member inline _.Source(result: Async<'ok option>) : AsyncResultOption<'ok, 'error> = AsyncResultOption.ofAsyncOption result @@ -210,7 +210,7 @@ module AsyncResultOptionCEExtensionsHighPriority = /// /// Method lets us transform data types into our internal representation. /// - member inline _.Source(result: Task>) : AsyncResultOption<'ok, 'error> = + member inline _.Source(result: Task<'ok option>) : AsyncResultOption<'ok, 'error> = result |> Async.AwaitTask |> AsyncResultOption.ofAsyncOption @@ -229,7 +229,7 @@ module AsyncResultOptionCEExtensionsHighPriority2 = /// See https://stackoverflow.com/questions/35286541/why-would-you-use-builder-source-in-a-custom-computation-expression-builder /// member inline _.Source - (result: Task, 'error>>) + (result: Task>) : AsyncResultOption<'ok, 'error> = result |> Async.AwaitTask diff --git a/src/FsToolkit.ErrorHandling/List.fs b/src/FsToolkit.ErrorHandling/List.fs index 390cc05e..c1888077 100644 --- a/src/FsToolkit.ErrorHandling/List.fs +++ b/src/FsToolkit.ErrorHandling/List.fs @@ -118,7 +118,7 @@ module List = let sequenceAsyncResultA xs = traverseAsyncResultA id xs - let rec private traverseOptionM' (state: Option<_>) (f: _ -> Option<_>) xs = + let rec private traverseOptionM' (state: _ option) (f: _ -> _ option) xs = match xs with | [] -> state @@ -135,7 +135,7 @@ module List = | Some _ -> traverseOptionM' r f xs | None -> r - let rec private traverseAsyncOptionM' (state: Async>) (f: _ -> Async>) xs = + let rec private traverseAsyncOptionM' (state: Async<_ option>) (f: _ -> Async<_ option>) xs = match xs with | [] -> state diff --git a/src/FsToolkit.ErrorHandling/Option.fs b/src/FsToolkit.ErrorHandling/Option.fs index 93ac40c3..9f044665 100644 --- a/src/FsToolkit.ErrorHandling/Option.fs +++ b/src/FsToolkit.ErrorHandling/Option.fs @@ -240,7 +240,7 @@ module Option = /// let inline bindNull ([] binder: 'value -> 'nullableValue) - (option: Option<'value>) + (option: 'value option) : 'nullableValue option = match option with | Some x -> @@ -329,7 +329,7 @@ module Option = /// /// Documentation is found here: /// - let inline sequenceTask (optTask: Option>) : Task> = + let inline sequenceTask (optTask: Task<'T> option) : Task<'T option> = task { match optTask with | Some tsk -> @@ -348,8 +348,8 @@ module Option = /// A Task<'U option> with the mapped value. let inline traverseTask ([] f: 'T -> Task<'U>) - (opt: Option<'T>) - : Task> = + (opt: 'T option) + : Task<'U option> = sequenceTask ((map f) opt) /// @@ -387,11 +387,11 @@ module Option = #endif /// - /// Converts a Option> to an Async> + /// Converts a Async<'T> option to an Async<'T option> /// /// Documentation is found here: https://demystifyfp.gitbook.io/fstoolkit-errorhandling/fstoolkit.errorhandling/option/sequenceasync /// - let inline sequenceAsync (optAsync: Option>) : Async> = + let inline sequenceAsync (optAsync: Async<'T> option) : Async<'T option> = async { match optAsync with | Some asnc -> @@ -407,11 +407,11 @@ module Option = /// /// The function to map over the Option. /// The Option to map over. - /// An Async<Option<'U>> with the mapped value. + /// An Async<'U option> with the mapped value. let inline traverseAsync ([] f: 'T -> Async<'U>) - (opt: Option<'T>) - : Async> = + (opt: 'T option) + : Async<'U option> = sequenceAsync ((map f) opt) /// diff --git a/src/FsToolkit.ErrorHandling/OptionOp.fs b/src/FsToolkit.ErrorHandling/OptionOp.fs index 4bc60d55..4dabf8a3 100644 --- a/src/FsToolkit.ErrorHandling/OptionOp.fs +++ b/src/FsToolkit.ErrorHandling/OptionOp.fs @@ -15,7 +15,7 @@ module Option = /// The function to bind over the Option value. /// The result of binding the function over the Option value. let inline (>>=) - (input: Option<'input>) - ([] binder: 'input -> Option<'output>) - : Option<'output> = + (input: 'input option) + ([] binder: 'input -> 'output option) + : 'output option = Option.bind binder input diff --git a/src/FsToolkit.ErrorHandling/TaskOptionCE.fs b/src/FsToolkit.ErrorHandling/TaskOptionCE.fs index 764a33ef..dd24a031 100644 --- a/src/FsToolkit.ErrorHandling/TaskOptionCE.fs +++ b/src/FsToolkit.ErrorHandling/TaskOptionCE.fs @@ -589,7 +589,7 @@ module TaskOptionCEExtensionsMediumPriority = return Some() } - member inline this.Source(opt: Option<'T>) : TaskOption<'T> = Task.FromResult opt + member inline this.Source(opt: 'T option) : TaskOption<'T> = Task.FromResult opt member inline this.Source(computation: Async<'T>) : TaskOption<'T> = computation diff --git a/src/FsToolkit.ErrorHandling/TaskValueOptionCE.fs b/src/FsToolkit.ErrorHandling/TaskValueOptionCE.fs index 51f63a69..f9f7174f 100644 --- a/src/FsToolkit.ErrorHandling/TaskValueOptionCE.fs +++ b/src/FsToolkit.ErrorHandling/TaskValueOptionCE.fs @@ -604,7 +604,7 @@ module TaskValueOptionCEExtensionsMediumPriority = return ValueSome() } - member inline this.Source(opt: ValueOption<'T>) : TaskValueOption<'T> = Task.FromResult opt + member inline this.Source(opt: 'T voption) : TaskValueOption<'T> = Task.FromResult opt member inline this.Source(computation: Async<'T>) : TaskValueOption<'T> = computation diff --git a/src/FsToolkit.ErrorHandling/ValueOption.fs b/src/FsToolkit.ErrorHandling/ValueOption.fs index 358f74cf..c90fa24b 100644 --- a/src/FsToolkit.ErrorHandling/ValueOption.fs +++ b/src/FsToolkit.ErrorHandling/ValueOption.fs @@ -115,7 +115,7 @@ module ValueOption = /// let inline bindNull ([] binder: 'value -> 'nullableValue) - (voption: ValueOption<'value>) + (voption: 'value voption) : 'nullableValue voption = match voption with | ValueSome x ->