Skip to content

Commit

Permalink
Add Task.ignore
Browse files Browse the repository at this point in the history
  • Loading branch information
odytrice committed Jul 14, 2024
1 parent e68fdf2 commit e3c7984
Show file tree
Hide file tree
Showing 2 changed files with 30 additions and 0 deletions.
27 changes: 27 additions & 0 deletions gitbook/task/ignore.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
## Task.ignore

Namespace: `FsToolkit.ErrorHandling`

Function Signature:

```fsharp
Task<'a> -> Task<unit>
```

This is a shortcut for `Task.map ignore`.

## Examples

### Example 1

```fsharp
let savePost : CreatePostRequest -> Task<PostId, exn>
```

We can call this with the `do!` syntax inside a computation expression using `Task.ignore` as below:

```fsharp
let makePost = task {
do! savePost createPostRequest |> Task.ignore
}
```
3 changes: 3 additions & 0 deletions src/FsToolkit.ErrorHandling.TaskResult/Task.fs
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,9 @@ module Task =

let inline map3 ([<InlineIfLambda>] f) x y z = apply (map2 f x y) z

let inline ignore (x: Task<'a>) =
x
|> map ignore

/// Takes two tasks and returns a tuple of the pair
let zip (a1: Task<_>) (a2: Task<_>) =
Expand Down

0 comments on commit e3c7984

Please sign in to comment.