Skip to content

Commit 2729006

Browse files
committed
Add examples to readme.md and add doc comments to the fsi files and update release notes
1 parent c30010a commit 2729006

File tree

5 files changed

+43
-17
lines changed

5 files changed

+43
-17
lines changed

README.md

Lines changed: 16 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -29,8 +29,8 @@ Latest version [can be installed from Nuget][nuget].
2929
- [Progress `taskSeq` CE](#progress-taskseq-ce)
3030
- [Progress and implemented `TaskSeq` module functions](#progress-and-implemented-taskseq-module-functions)
3131
- [More information](#more-information)
32-
- [Futher reading `IAsyncEnumerable`](#futher-reading-iasyncenumerable)
33-
- [Futher reading on resumable state machines](#futher-reading-on-resumable-state-machines)
32+
- [Further reading `IAsyncEnumerable`](#further-reading-iasyncenumerable)
33+
- [Further reading on resumable state machines](#further-reading-on-resumable-state-machines)
3434
- [Further reading on computation expressions](#further-reading-on-computation-expressions)
3535
- [Building & testing](#building--testing)
3636
- [Prerequisites](#prerequisites)
@@ -109,15 +109,25 @@ As package reference in `fsproj` or `csproj` file:
109109

110110
```f#
111111
open System.IO
112-
113112
open FSharp.Control
114113
115114
// singleton is fine
116-
let hello = taskSeq { yield "Hello, World!" }
115+
let helloTs = taskSeq { yield "Hello, World!" }
116+
117+
// cold-started, that is, delay-executed
118+
let f() = task {
119+
// using toList forces execution of whole sequence
120+
let! hello = TaskSeq.toList helloTs // toList returns a Task<'T list>
121+
return List.head hello
122+
}
117123
118124
// can be mixed with normal sequences
119125
let oneToTen = taskSeq { yield! [1..10] }
120126
127+
// can be used with F#'s task and async in a for-loop
128+
let f() = task { for x in oneToTen do printfn "Number %i" x }
129+
let g() = async { for x in oneToTen do printfn "Number %i" x }
130+
121131
// returns a delayed sequence of IAsyncEnumerable<string>
122132
let allFilesAsLines() = taskSeq {
123133
let files = Directory.EnumerateFiles(@"c:\temp")
@@ -313,14 +323,14 @@ The following is the progress report:
313323

314324
## More information
315325

316-
### Futher reading `IAsyncEnumerable`
326+
### Further reading `IAsyncEnumerable`
317327

318328
- A good C#-based introduction [can be found in this blog][8].
319329
- [An MSDN article][9] written shortly after it was introduced.
320330
- Converting a `seq` to an `IAsyncEnumerable` [demo gist][10] as an example, though `TaskSeq` contains many more utility functions and uses a slightly different approach.
321331
- If you're looking for using `IAsyncEnumerable` with `async` and not `task`, the excellent [`AsyncSeq`][11] library should be used. While `TaskSeq` is intended to consume `async` just like `task` does, it won't create an `AsyncSeq` type (at least not yet). If you want classic Async and parallelism, you should get this library instead.
322332

323-
### Futher reading on resumable state machines
333+
### Further reading on resumable state machines
324334

325335
- A state machine from a monadic perspective in F# [can be found here][12], which works with the pre-F# 6.0 non-resumable internals.
326336
- The [original RFC for F# 6.0 on resumable state machines][13]

assets/nuget-package-readme.md

Lines changed: 16 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -19,8 +19,8 @@ An implementation of [`IAsyncEnumerable<'T>`][3] as a computation expression: `t
1919
- [Examples](#examples)
2020
- [`TaskSeq` module functions](#taskseq-module-functions)
2121
- [More information](#more-information)
22-
- [Futher reading `IAsyncEnumerable`](#futher-reading-iasyncenumerable)
23-
- [Futher reading on resumable state machines](#futher-reading-on-resumable-state-machines)
22+
- [Further reading `IAsyncEnumerable`](#further-reading-iasyncenumerable)
23+
- [Further reading on resumable state machines](#further-reading-on-resumable-state-machines)
2424
- [Further reading on computation expressions](#further-reading-on-computation-expressions)
2525

2626
-----------------------------------------
@@ -47,15 +47,25 @@ for `use` and `use!`, `try-with` and `try-finally` and `while` loops within the
4747

4848
```f#
4949
open System.IO
50-
5150
open FSharp.Control
5251
5352
// singleton is fine
54-
let hello = taskSeq { yield "Hello, World!" }
53+
let helloTs = taskSeq { yield "Hello, World!" }
54+
55+
// cold-started, that is, delay-executed
56+
let f() = task {
57+
// using toList forces execution of whole sequence
58+
let! hello = TaskSeq.toList helloTs // toList returns a Task<'T list>
59+
return List.head hello
60+
}
5561
5662
// can be mixed with normal sequences
5763
let oneToTen = taskSeq { yield! [1..10] }
5864
65+
// can be used with F#'s task and async in a for-loop
66+
let f() = task { for x in oneToTen do printfn "Number %i" x }
67+
let g() = async { for x in oneToTen do printfn "Number %i" x }
68+
5969
// returns a delayed sequence of IAsyncEnumerable<string>
6070
let allFilesAsLines() = taskSeq {
6171
let files = Directory.EnumerateFiles(@"c:\temp")
@@ -237,14 +247,14 @@ _The motivation for `readOnly` in `Seq` is that a cast from a mutable array or l
237247

238248
## More information
239249

240-
### Futher reading `IAsyncEnumerable`
250+
### Further reading `IAsyncEnumerable`
241251

242252
- A good C#-based introduction [can be found in this blog][8].
243253
- [An MSDN article][9] written shortly after it was introduced.
244254
- Converting a `seq` to an `IAsyncEnumerable` [demo gist][10] as an example, though `TaskSeq` contains many more utility functions and uses a slightly different approach.
245255
- If you're looking for using `IAsyncEnumerable` with `async` and not `task`, the excellent [`AsyncSeq`][11] library should be used. While `TaskSeq` is intended to consume `async` just like `task` does, it won't create an `AsyncSeq` type (at least not yet). If you want classic Async and parallelism, you should get this library instead.
246256

247-
### Futher reading on resumable state machines
257+
### Further reading on resumable state machines
248258

249259
- A state machine from a monadic perspective in F# [can be found here][12], which works with the pre-F# 6.0 non-resumable internals.
250260
- The [original RFC for F# 6.0 on resumable state machines][13]

src/FSharp.Control.TaskSeq/AsyncExtensions.fsi

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,5 +6,7 @@ module AsyncExtensions =
66

77
type AsyncBuilder with
88

9-
/// Iterate over all values of a taskSeq.
9+
/// <summary>
10+
/// Inside <see cref="async" />, iterate over all values of a <see cref="taskSeq" />.
11+
/// </summary>
1012
member For: source: taskSeq<'T> * action: ('T -> Async<unit>) -> Async<unit>

src/FSharp.Control.TaskSeq/FSharp.Control.TaskSeq.fsproj

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -23,10 +23,11 @@ Generates optimized IL code through the new resumable state machines, and comes
2323
<PackageReadmeFile>nuget-package-readme.md</PackageReadmeFile>
2424
<PackageReleaseNotes>
2525
Release notes:
26-
0.2.3 (unreleased)
27-
- add TaskSeq.singleton, #90 (by @gusty)
28-
- improve TaskSeq.empty by not relying on resumable state, #89 (by @gusty)
29-
- do not throw exception for unequal lengths in TaskSeq.zip, fixes #32
26+
0.3.0 (unreleased)
27+
- adds support for 'for .. in ..' with task sequences in F# tasks and async, #75, #93 and #99 (with help from @theangrybyrd)
28+
- adds TaskSeq.singleton, #90 (by @gusty)
29+
- improves TaskSeq.empty by not relying on resumable state, #89 (by @gusty)
30+
- does not throw exceptions anymore for unequal lengths in TaskSeq.zip, fixes #32
3031
0.2.2
3132
- removes TaskSeq.toSeqCachedAsync, which was incorrectly named. Use toSeq or toListAsync instead.
3233
- renames TaskSeq.toSeqCached to TaskSeq.toSeq, which was its actual operational behavior.

src/FSharp.Control.TaskSeq/TaskExtensions.fsi

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,4 +8,7 @@ module TaskExtensions =
88

99
type TaskBuilder with
1010

11+
/// <summary>
12+
/// Inside <see cref="task" />, iterate over all values of a <see cref="taskSeq" />.
13+
/// </summary>
1114
member inline For: source: taskSeq<'T> * body: ('T -> TaskCode<'TOverall, unit>) -> TaskCode<'TOverall, unit>

0 commit comments

Comments
 (0)