Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions gitbook/asyncOption/ce.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,13 +9,13 @@ Namespace: `FsToolkit.ErrorHandling`
Given a personId and an age, find a person and update their age.

```fsharp
tryParseInt : string -> Option<int>
tryFindPersonById : int -> Async<Option<Person>>
tryParseInt : string -> int option
tryFindPersonById : int -> Async<Person option>
updatePerson : Person -> Async<unit>
```

```fsharp
// Async<Option<unit>>
// Async<unit option>
let addResult = asyncOption {
let! personId = tryParseInt "3001"
let! age = tryParseInt "35"
Expand Down
2 changes: 1 addition & 1 deletion gitbook/asyncResultOption/operators.md
Original file line number Diff line number Diff line change
Expand Up @@ -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<Option<_>,_>` type.
FsToolkit.ErrorHandling provides the standard infix operators for the `map` (`<!>`), `apply` (`<*>`), and `bind` (`>>=`) functions of the `Result<'T option, 'E>` type.

## Examples

Expand Down
2 changes: 1 addition & 1 deletion gitbook/cancellableTaskOption/ce.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ Namespace: `FsToolkit.ErrorHandling`
Given a personId and an age, find a person and update their age.

```fsharp
tryParseInt : string -> Option<int>
tryParseInt : string -> int option
tryFindPersonById : int -> CancellableTask<Person option>
updatePerson : Person -> CancellableTask<unit>
```
Expand Down
6 changes: 3 additions & 3 deletions gitbook/jobOption/ce.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,13 +9,13 @@ Namespace: `FsToolkit.ErrorHandling`
Given a personId and an age, find a person and update their age.

```fsharp
tryParseInt : string -> Option<int>
tryFindPersonById : int -> Job<Option<Person>>
tryParseInt : string -> int option
tryFindPersonById : int -> Job<Person option>
updatePerson : Person -> Job<unit>
```

```fsharp
// Job<Option<unit>>
// Job<unit option>
let addResult = jobOption {
let! personId = tryParseInt "3001"
let! age = tryParseInt "35"
Expand Down
2 changes: 1 addition & 1 deletion gitbook/option/bindNull.md
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ Option.bindNull toNullable userInput
```fsharp
open System

let userInput : Option<int> = None
let userInput : int option = None
let toNullable<'T> x = Nullable x

Option.bindNull toNullable userInput
Expand Down
2 changes: 1 addition & 1 deletion gitbook/option/ce.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ Namespace: `FsToolkit.ErrorHandling`
### Example 1

```fsharp
// Option<int>
// int option
let addResult = option {
let! x = tryParseInt "35"
let! y = tryParseInt "5"
Expand Down
2 changes: 1 addition & 1 deletion gitbook/resultOption/ofOption.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion gitbook/resultOption/operators.md
Original file line number Diff line number Diff line change
Expand Up @@ -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<Option<_>,_>` 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:

Expand Down
6 changes: 3 additions & 3 deletions gitbook/taskOption/ce.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,13 +9,13 @@ Namespace: `FsToolkit.ErrorHandling`
Given a personId and an age, find a person and update their age.

```fsharp
tryParseInt : string -> Option<int>
tryFindPersonById : int -> Task<Option<Person>>
tryParseInt : string -> int option
tryFindPersonById : int -> Task<Person option>
updatePerson : Person -> Task<unit>
```

```fsharp
// Task<Option<unit>>
// Task<unit option>
let addResult = taskOption {
let! personId = tryParseInt "3001"
let! age = tryParseInt "35"
Expand Down
2 changes: 1 addition & 1 deletion gitbook/taskResultOption/operators.md
Original file line number Diff line number Diff line change
Expand Up @@ -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<Option<_>,_>` type.
FsToolkit.ErrorHandling provides the standard infix operators for the `map` (`<!>`), `apply` (`<*>`), and `bind` (`>>=`) functions of the `Result<'T option, 'E>` type.

## Examples

Expand Down
4 changes: 2 additions & 2 deletions src/FsToolkit.ErrorHandling/Array.fs
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -147,7 +147,7 @@ module Array =
| Some _ -> traverseOptionM' r f xs
| None -> r

let rec private traverseAsyncOptionM' (state: Async<Option<_>>) (f: _ -> Async<Option<_>>) xs =
let rec private traverseAsyncOptionM' (state: Async<_ option>) (f: _ -> Async<_ option>) xs =
match xs with
| [||] ->
state
Expand Down
12 changes: 6 additions & 6 deletions src/FsToolkit.ErrorHandling/AsyncOption.fs
Original file line number Diff line number Diff line change
Expand Up @@ -96,9 +96,9 @@ module AsyncOption =
/// The option if the option is Some, else returns <paramref name="ifNone"/>.
/// </returns>
let inline orElse
(ifNone: Async<Option<'value>>)
(input: Async<Option<'value>>)
: Async<Option<'value>> =
(ifNone: Async<'value option>)
(input: Async<'value option>)
: Async<'value option> =
Async.bind (Option.either some (fun _ -> ifNone)) input

/// <summary>
Expand All @@ -121,7 +121,7 @@ module AsyncOption =
/// The option if the option is Some, else the result of executing <paramref name="ifNoneFunc"/>.
/// </returns>
let inline orElseWith
([<InlineIfLambda>] ifNoneFunc: unit -> Async<Option<'value>>)
(input: Async<Option<'value>>)
: Async<Option<'value>> =
([<InlineIfLambda>] ifNoneFunc: unit -> Async<'value option>)
(input: Async<'value option>)
: Async<'value option> =
Async.bind (Option.either some ifNoneFunc) input
6 changes: 3 additions & 3 deletions src/FsToolkit.ErrorHandling/AsyncResultOption.fs
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
namespace FsToolkit.ErrorHandling


type AsyncResultOption<'ok, 'error> = Async<Result<Option<'ok>, 'error>>
type AsyncResultOption<'ok, 'error> = Async<Result<'ok option, 'error>>

[<RequireQualifiedAccess>]
module AsyncResultOption =
Expand Down Expand Up @@ -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<Option<'ok>>) =
let inline ofAsyncOption (r: Async<'ok option>) =
r
|> Async.map Ok
8 changes: 4 additions & 4 deletions src/FsToolkit.ErrorHandling/AsyncResultOptionCE.fs
Original file line number Diff line number Diff line change
Expand Up @@ -130,7 +130,7 @@ module AsyncResultOptionCEExtensions =
/// <summary>
/// Method lets us transform data types into our internal representation.
/// </summary>
member inline this.Source(optional: Option<'ok>) : AsyncResultOption<'ok, 'error> =
member inline this.Source(optional: 'ok option) : AsyncResultOption<'ok, 'error> =
AsyncResultOption.ofOption optional

/// <summary>
Expand Down Expand Up @@ -194,7 +194,7 @@ module AsyncResultOptionCEExtensionsHighPriority =
/// <summary>
/// Method lets us transform data types into our internal representation.
/// </summary>
member inline _.Source(result: Async<Option<'ok>>) : AsyncResultOption<'ok, 'error> =
member inline _.Source(result: Async<'ok option>) : AsyncResultOption<'ok, 'error> =
AsyncResultOption.ofAsyncOption result


Expand All @@ -210,7 +210,7 @@ module AsyncResultOptionCEExtensionsHighPriority =
/// <summary>
/// Method lets us transform data types into our internal representation.
/// </summary>
member inline _.Source(result: Task<Option<'ok>>) : AsyncResultOption<'ok, 'error> =
member inline _.Source(result: Task<'ok option>) : AsyncResultOption<'ok, 'error> =
result
|> Async.AwaitTask
|> AsyncResultOption.ofAsyncOption
Expand All @@ -229,7 +229,7 @@ module AsyncResultOptionCEExtensionsHighPriority2 =
/// See https://stackoverflow.com/questions/35286541/why-would-you-use-builder-source-in-a-custom-computation-expression-builder
/// </summary>
member inline _.Source
(result: Task<Result<Option<'ok>, 'error>>)
(result: Task<Result<'ok option, 'error>>)
: AsyncResultOption<'ok, 'error> =
result
|> Async.AwaitTask
Expand Down
4 changes: 2 additions & 2 deletions src/FsToolkit.ErrorHandling/List.fs
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -135,7 +135,7 @@ module List =
| Some _ -> traverseOptionM' r f xs
| None -> r

let rec private traverseAsyncOptionM' (state: Async<Option<_>>) (f: _ -> Async<Option<_>>) xs =
let rec private traverseAsyncOptionM' (state: Async<_ option>) (f: _ -> Async<_ option>) xs =
match xs with
| [] ->
state
Expand Down
18 changes: 9 additions & 9 deletions src/FsToolkit.ErrorHandling/Option.fs
Original file line number Diff line number Diff line change
Expand Up @@ -240,7 +240,7 @@ module Option =
/// <seealso cref="ofNull"/>
let inline bindNull
([<InlineIfLambda>] binder: 'value -> 'nullableValue)
(option: Option<'value>)
(option: 'value option)
: 'nullableValue option =
match option with
| Some x ->
Expand Down Expand Up @@ -329,7 +329,7 @@ module Option =
///
/// Documentation is found here: <see href="https://demystifyfp.gitbook.io/fstoolkit-errorhandling/fstoolkit.errorhandling/option/sequencetask" />
/// </summary>
let inline sequenceTask (optTask: Option<Task<'T>>) : Task<Option<'T>> =
let inline sequenceTask (optTask: Task<'T> option) : Task<'T option> =
task {
match optTask with
| Some tsk ->
Expand All @@ -348,8 +348,8 @@ module Option =
/// <returns>A <c>Task&lt;'U option&gt;</c> with the mapped value.</returns>
let inline traverseTask
([<InlineIfLambda>] f: 'T -> Task<'U>)
(opt: Option<'T>)
: Task<Option<'U>> =
(opt: 'T option)
: Task<'U option> =
sequenceTask ((map f) opt)

/// <summary>
Expand Down Expand Up @@ -387,11 +387,11 @@ module Option =
#endif

/// <summary>
/// Converts a Option<Async<_>> to an Async<Option<_>>
/// Converts a Async<'T> option to an Async<'T option>
///
/// Documentation is found here: <href>https://demystifyfp.gitbook.io/fstoolkit-errorhandling/fstoolkit.errorhandling/option/sequenceasync</href>
/// </summary>
let inline sequenceAsync (optAsync: Option<Async<'T>>) : Async<Option<'T>> =
let inline sequenceAsync (optAsync: Async<'T> option) : Async<'T option> =
async {
match optAsync with
| Some asnc ->
Expand All @@ -407,11 +407,11 @@ module Option =
/// </summary>
/// <param name="f">The function to map over the Option.</param>
/// <param name="opt">The Option to map over.</param>
/// <returns>An <c>Async&lt;Option&lt;'U&gt;&gt;</c> with the mapped value.</returns>
/// <returns>An <c>Async&lt;'U option&gt;</c> with the mapped value.</returns>
let inline traverseAsync
([<InlineIfLambda>] f: 'T -> Async<'U>)
(opt: Option<'T>)
: Async<Option<'U>> =
(opt: 'T option)
: Async<'U option> =
sequenceAsync ((map f) opt)

/// <summary>
Expand Down
6 changes: 3 additions & 3 deletions src/FsToolkit.ErrorHandling/OptionOp.fs
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ module Option =
/// <param name="binder">The function to bind over the <c>Option</c> value.</param>
/// <returns>The result of binding the function over the <c>Option</c> value.</returns>
let inline (>>=)
(input: Option<'input>)
([<InlineIfLambda>] binder: 'input -> Option<'output>)
: Option<'output> =
(input: 'input option)
([<InlineIfLambda>] binder: 'input -> 'output option)
: 'output option =
Option.bind binder input
2 changes: 1 addition & 1 deletion src/FsToolkit.ErrorHandling/TaskOptionCE.fs
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion src/FsToolkit.ErrorHandling/TaskValueOptionCE.fs
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion src/FsToolkit.ErrorHandling/ValueOption.fs
Original file line number Diff line number Diff line change
Expand Up @@ -115,7 +115,7 @@ module ValueOption =
/// <seealso cref="ofNull"/>
let inline bindNull
([<InlineIfLambda>] binder: 'value -> 'nullableValue)
(voption: ValueOption<'value>)
(voption: 'value voption)
: 'nullableValue voption =
match voption with
| ValueSome x ->
Expand Down
Loading