Skip to content

Commit c62fbc9

Browse files
committed
fix docs
1 parent 41a9741 commit c62fbc9

3 files changed

Lines changed: 31 additions & 143 deletions

File tree

docs/AsyncSeq.fsx

Lines changed: 11 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
(**
22
---
3-
title: F# Asynchronous Sequences
3+
title: Tutorial
44
category: Documentation
55
categoryindex: 2
66
index: 1
@@ -25,15 +25,9 @@ keywords: F#, asynchronous sequences, AsyncSeq, IAsyncEnumerable, async workflow
2525
(**
2626
[![Binder](https://mybinder.org/badge_logo.svg)](https://mybinder.org/v2/gh/fsprojects/FSharp.Control.AsyncSeq/gh-pages?filepath=AsyncSeq.ipynb)
2727
28-
# F# Asynchronous Sequences
28+
# Tutorial
2929
30-
An asynchronous sequence is a sequence in which individual elements are _awaited_, so the next element of the sequence is not necessarily available immediately. This allows for efficient composition of asynchronous workflows which involve sequences of data.
31-
32-
FSharp.Control.AsyncSeq is an implementation of functional-first programming over asynchronous sequences for F#. The central type of the library, `AsyncSeq<'T>`, is a type alias for the standard type `System.Collections.Generic.IAsyncEnumerable<'T>`.
33-
34-
This library was also [one of the world's first implementations of langauge integrated asynchronous sequences](http://tomasp.net/blog/async-sequences.aspx) - that is, asynchronous sequences with integrated language support through computation expressions. It is a mature library used in production for many years and is widely used in the F# community.
35-
36-
### Generating asynchronous sequences
30+
## Generating asynchronous sequences
3731
3832
To use the library, referrence the NuGet package `FSharp.Control.AsyncSeq` in your project and open the `FSharp.Control` namespace:
3933
*)
@@ -56,19 +50,6 @@ or more succinctly:
5650
let async12b = asyncSeq { 1; 2 }
5751

5852
(**
59-
### Comparison with `FSharp.Control.TaskSeq`
60-
61-
A related library is [`FSharp.Control.TaskSeq`](https://github.com/fsprojects/FSharp.Control.TaskSeq/) which provides a similar API for sequences of `Task<'T>` instead of `Async<'T>`. The two libraries are very similar and the choice between them is mostly a matter of preference or performance. The `AsyncSeq` library integrates well with the F# `Async` type, while the `TaskSeq` library is more performant and integrates well with the .NET `Task` type.
62-
63-
Both libraries implement that .NET standard `IAsyncEnumerable<'T>` interface, so they can be used interchangeably in most scenarios.
64-
65-
### Comparison with seq<'T>
66-
67-
The central difference between `seq<'T>` and `AsyncSeq<'T>` can be illustrated by introducing the notion of time.
68-
Suppose that generating subsequent elements of a sequence requires an IO-bound operation. Invoking long
69-
running IO-bound operations from within a `seq<'T>` will *block* the thread which calls `MoveNext` on the
70-
corresponding `IEnumerator`. An `AsyncSeq` on the other hand can use facilities provided by the F# `Async` type to make
71-
more efficient use of system resources.
7253
*)
7354

7455
open System.Threading
@@ -88,18 +69,14 @@ let withTime2 = asyncSeq {
8869
}
8970

9071
(**
91-
When the asynchronous sequence `withTime'` is iterated, the calls to `Async.Sleep` won't block threads. Instead,
92-
the *continuation* of the sequence will be scheduled by `Async` while the calling thread will be free to perform other work.
93-
Overall, a `seq<'a>` can be viewed as a special case of an `AsyncSeq<'a>` where subsequent elements are retrieved
94-
in a blocking manner.
95-
96-
### Performance Considerations
97-
98-
While an asynchronous computation obviates the need to block an OS thread for the duration of an operation, it isn't always the case
99-
that this will improve the overall performance of an application. Note however that an async computation does not *require* a
100-
non-blocking operation, it simply allows for it. Also of note is that unlike calling `IEnumerable.MoveNext()`, consuming
101-
an item from an asynchronous sequence requires several allocations. Usually this is greatly outweighed by the
102-
benefits, it can make a difference in some scenarios.
72+
When the asynchronous sequence `withTime'` is iterated, the calls to `Async.Sleep` won't block threads. Instead, the *continuation* of the sequence will be scheduled by `Async` while the calling thread will be free to perform other work. Overall, a `seq<'a>` can be viewed as a special case of an `AsyncSeq<'a>` where subsequent elements are retrieved in a blocking manner.
73+
74+
*)
75+
76+
(**
77+
## Performance Considerations
78+
79+
While an asynchronous computation obviates the need to block an OS thread for the duration of an operation, it isn't always the case that this will improve the overall performance of an application. Note however that an async computation does not *require* a non-blocking operation, it simply allows for it. Also of note is that unlike calling `IEnumerable.MoveNext()`, consuming an item from an asynchronous sequence requires several allocations. Usually this is greatly outweighed by the benefits, it can make a difference in some scenarios.
10380
10481
## Related Articles
10582

docs/index.md

Lines changed: 20 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,12 @@
1-
FSharp.Control.AsyncSeq
2-
=============
1+
# FSharp.Control.AsyncSeq
32

43
FSharp.Control.AsyncSeq is a collection of asynchronous programming utilities for F#.
54

6-
An `AsyncSeq<'T>` is a sequence in which individual elements are retrieved using an `Async` computation.
7-
The power of `AsyncSeq` lies in that many of these operations also have analogs based on `Async`
8-
allowing composition of complex asynchronous workflows, including compositional cancellation.
5+
An asynchronous sequence is a sequence in which individual elements are _awaited_, so the next element of the sequence is not necessarily available immediately. This allows for efficient composition of asynchronous workflows which involve sequences of data.
96

10-
> **v4.0:** `AsyncSeq<'T>` is now a type alias for `System.Collections.Generic.IAsyncEnumerable<'T>`.
11-
> Values flow freely between `AsyncSeq<'T>` and `IAsyncEnumerable<'T>` without any conversion.
12-
> `AsyncSeq.ofAsyncEnum` / `AsyncSeq.toAsyncEnum` are now no-ops and marked obsolete — remove them.
13-
> See the [README](https://github.com/fsprojects/FSharp.Control.AsyncSeq#version-40--bcl-iasyncenumerable-compatibility) for migration notes.
7+
FSharp.Control.AsyncSeq is an implementation of functional-first programming over asynchronous sequences for F#. The central type of the library, `AsyncSeq<'T>`, is a type alias for the standard type `System.Collections.Generic.IAsyncEnumerable<'T>`.
8+
9+
This was [one of the world's first implementations of langauge integrated asynchronous sequences](http://tomasp.net/blog/async-sequences.aspx) - that is, asynchronous sequences with integrated language support through computation expressions. It is a mature library used in production for many years and is widely used in the F# community.
1410

1511
An `AsyncSeq<'a>` can be generated using computation expression syntax much like `seq<'a>`:
1612

@@ -20,34 +16,26 @@ An `AsyncSeq<'a>` can be generated using computation expression syntax much like
2016
yield 2
2117
}
2218

23-
Learning
24-
--------------------------
19+
## Learning
20+
21+
* [Tutorial](AsyncSeq.fsx).
22+
* [Generating sequences](AsyncSeqGenerating.fsx)
23+
* [Transforming and reducing sequences](AsyncSeqTransforming.fsx)
24+
* [Combining sequences](AsyncSeqCombining.fsx)
25+
* [Advanced topics](AsyncSeqAdvanced.fsx)
2526

26-
[AsyncSeq](AsyncSeq.html) contains narrative and code samples explaining asynchronous sequences.
27+
## Related Libraries
2728

28-
[AsyncSeq Examples](AsyncSeqExamples.html) contains examples.
29+
### `FSharp.Control.TaskSeq`
2930

30-
[Terminology](terminology.html) a reference for some of the terminology around F# async.
31-
32-
[Comparison with IObservable](ComparisonWithIObservable.html) contains discussion about the difference between async sequences and IObservables.
31+
[`FSharp.Control.TaskSeq`](https://github.com/fsprojects/FSharp.Control.TaskSeq/) provides a similar API oriented towards `Task<'T>` instead of `Async<'T>`. The choice between them is mostly a matter of preference or performance. The `AsyncSeq` library integrates well with the F# `Async<_>` type, while the `TaskSeq` library is more performant and integrates well with the .NET `Task<_>` type.
3332

34-
[API Reference](reference/index.html) contains automatically generated documentation for all types, modules and functions in the library.
35-
This includes additional brief samples on using most of the functions.
33+
Both libraries implement that .NET standard `IAsyncEnumerable<'T>` interface, so they can be used interchangeably in most scenarios.
3634

37-
Contributing and copyright
38-
--------------------------
35+
### seq<'T>
3936

40-
The project is hosted on [GitHub][gh] where you can [report issues][issues], fork
41-
the project and submit pull requests. If you're adding a new public API, please also
42-
consider adding [samples][content] that can be turned into a documentation. You might
43-
also want to read the [library design notes][readme] to understand how it works.
37+
The central difference between `seq<'T>` and `AsyncSeq<'T>` can be illustrated by introducing the notion of time. Suppose that generating subsequent elements of a sequence requires an IO-bound operation. Invoking long running IO-bound operations from within a `seq<'T>` will _block_ the thread which calls `MoveNext` on the corresponding `IEnumerator`. An `AsyncSeq` on the other hand can use facilities provided by the F# `Async` type to make more efficient use of system resources.
4438

45-
The library is available under Apache 2.0 license, which allows modification and
46-
redistribution for both commercial and non-commercial purposes. For more information see the
47-
[License file][license] in the GitHub repository.
39+
### IObservable<'T>
4840

49-
[content]: https://github.com/fsprojects/FSharp.Control.AsyncSeq/tree/master/docs/content
50-
[gh]: https://github.com/fsprojects/FSharp.Control.AsyncSeq
51-
[issues]: https://github.com/fsprojects/FSharp.Control.AsyncSeq/issues
52-
[readme]: https://github.com/fsprojects/FSharp.Control.AsyncSeq/blob/master/README.md
53-
[license]: https://github.com/fsprojects/FSharp.Control.AsyncSeq/blob/master/LICENSE.txt
41+
See [Comparison with IObservable](ComparisonWithObservable.fsx).

docs/terminology.md

Lines changed: 0 additions & 77 deletions
This file was deleted.

0 commit comments

Comments
 (0)