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
2 changes: 2 additions & 0 deletions gitbook/SUMMARY.md
Original file line number Diff line number Diff line change
Expand Up @@ -131,6 +131,7 @@
* [apply](asyncResultOption/apply.md)
* [bind](asyncResultOption/bind.md)
* [Computation Expression](asyncResultOption/ce.md)
* [error](asyncResultOption/error.md)
* [ignore](asyncResultOption/ignore.md)
* [map](asyncResultOption/map.md)
* [map2](asyncResultOption/map2.md)
Expand Down Expand Up @@ -196,6 +197,7 @@
* [apply](taskResultOption/apply.md)
* [bind](taskResultOption/bind.md)
* [Computation Expression](taskResultOption/ce.md)
* [error](taskResultOption/error.md)
* [ignore](taskResultOption/ignore.md)
* [map](taskResultOption/map.md)
* [map2](taskResultOption/map2.md)
Expand Down
22 changes: 22 additions & 0 deletions gitbook/asyncResultOption/error.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
## AsyncResultOption.error

Namespace: `FsToolkit.ErrorHandling`

Lift an `'error` value into an `Async<Result<'ok option, 'error>>`

## Function Signature:

```fsharp
'error -> Async<Result<'ok option, 'error>>
```

## Examples

### Example 1


```fsharp
let result : Async<Result<int option, string>> =
AsyncResultOption.error "Something bad happened"
```

22 changes: 22 additions & 0 deletions gitbook/taskResultOption/error.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
## TaskResultOption.error

Namespace: `FsToolkit.ErrorHandling`

Lift an `'error` value into an `Task<Result<'ok option, 'error>>`

## Function Signature:

```fsharp
'error -> Task<Result<'ok option, 'error>>
```

## Examples

### Example 1


```fsharp
let result : Task<Result<int option, string>> =
TaskResultOption.error "Something bad happened"
```

7 changes: 7 additions & 0 deletions src/FsToolkit.ErrorHandling/AsyncResultOption.fs
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,13 @@ module AsyncResultOption =
)
input

let inline ok x =
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nit: maybe we want to start adding some xml doc comments to these functions with the links to where they will be found like what we have been adding recently.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sure, I can do that. I didn't here because the others didn't and I wondered if it wasn't because the function is so simple

Ok(Some x)
|> Async.singleton

let inline error x : Async<Result<'ok option, 'error>> =
Error x
|> Async.singleton

let inline map2
([<InlineIfLambda>] mapper: 'okInput1 -> 'okInput2 -> 'okOutput)
Expand Down
4 changes: 4 additions & 0 deletions src/FsToolkit.ErrorHandling/TaskResultOption.fs
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,10 @@ module TaskResultOption =

let inline singleton value = TaskResult.ok (Some value)

let inline ok x = singleton x

let inline error x : TaskResult<'ok option, 'error> = TaskResult.error x

let inline apply fTRO xTRO = map2 (fun f x -> f x) fTRO xTRO

/// Replaces the wrapped value with unit
Expand Down
Loading