You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: gitbook/taskOption/ce.md
+22Lines changed: 22 additions & 0 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -24,3 +24,25 @@ let addResult = taskOption {
24
24
do! updatePerson person
25
25
}
26
26
```
27
+
28
+
### Example 2 - IAsyncEnumerable
29
+
30
+
The `taskOption` CE supports `for .. in ..` iteration over `IAsyncEnumerable<'T>` sequences. Iteration stops immediately when the body returns `None`, without consuming further elements.
31
+
32
+
```fsharp
33
+
tryProcessItem : Item -> Task<unit option>
34
+
getItemsAsync : unit -> IAsyncEnumerable<Item>
35
+
```
36
+
37
+
```fsharp
38
+
// Task<string option>
39
+
let processItems () =
40
+
taskOption {
41
+
for item in getItemsAsync () do
42
+
do! tryProcessItem item
43
+
return "done"
44
+
}
45
+
// Returns None and stops iteration on the first None result
46
+
```
47
+
48
+
The `backgroundTaskOption` CE inherits this support automatically.
return! user |> createAuthToken |> Result.mapError TokenErr
34
34
}
35
35
```
36
+
37
+
### Example 2 - IAsyncEnumerable
38
+
39
+
The `taskResult` CE supports `for .. in ..` iteration over `IAsyncEnumerable<'T>` sequences. Iteration stops immediately when the body returns an `Error`, without consuming further elements.
Copy file name to clipboardExpand all lines: gitbook/taskValidation/ce.md
+24Lines changed: 24 additions & 0 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -39,3 +39,27 @@ let addResult = taskValidation {
39
39
40
40
// task { return Error [ "Am"; "I"; "async?" ] }
41
41
```
42
+
43
+
### IAsyncEnumerable
44
+
45
+
The `taskValidation` CE supports `for .. in ..` iteration over `IAsyncEnumerable<'T>` sequences. Iteration stops immediately when the body returns an `Error`, without consuming further elements.
Copy file name to clipboardExpand all lines: gitbook/taskValueOption/ce.md
+22Lines changed: 22 additions & 0 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -24,3 +24,25 @@ let addResult = taskValueOption {
24
24
do! updatePerson person
25
25
}
26
26
```
27
+
28
+
### Example 2 - IAsyncEnumerable
29
+
30
+
The `taskValueOption` CE supports `for .. in ..` iteration over `IAsyncEnumerable<'T>` sequences. Iteration stops immediately when the body returns `ValueNone`, without consuming further elements.
31
+
32
+
```fsharp
33
+
tryProcessItem : Item -> Task<unit voption>
34
+
getItemsAsync : unit -> IAsyncEnumerable<Item>
35
+
```
36
+
37
+
```fsharp
38
+
// Task<string voption>
39
+
let processItems () =
40
+
taskValueOption {
41
+
for item in getItemsAsync () do
42
+
do! tryProcessItem item
43
+
return "done"
44
+
}
45
+
// Returns ValueNone and stops iteration on the first ValueNone result
46
+
```
47
+
48
+
The `backgroundTaskValueOption` CE inherits this support automatically.
0 commit comments