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
144 changes: 111 additions & 33 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,37 +13,115 @@ documentation will be added soon(ish):

```f#
module TaskSeq =
val toList: t: taskSeq<'T> -> 'T list
val toArray: taskSeq: taskSeq<'T> -> 'T[]
val empty<'T> : IAsyncEnumerable<'T>
val ofArray: array: 'T[] -> IAsyncEnumerable<'T>
val ofList: list: 'T list -> IAsyncEnumerable<'T>
val ofSeq: sequence: seq<'T> -> IAsyncEnumerable<'T>
val ofResizeArray: data: ResizeArray<'T> -> IAsyncEnumerable<'T>
val ofTaskSeq: sequence: seq<#Task<'T>> -> IAsyncEnumerable<'T>
val ofTaskList: list: #Task<'T> list -> IAsyncEnumerable<'T>
val ofTaskArray: array: #Task<'T> array -> IAsyncEnumerable<'T>
val ofAsyncSeq: sequence: seq<Async<'T>> -> IAsyncEnumerable<'T>
val ofAsyncList: list: Async<'T> list -> IAsyncEnumerable<'T>
val ofAsyncArray: array: Async<'T> array -> IAsyncEnumerable<'T>
val toArrayAsync: taskSeq: taskSeq<'a> -> Task<'a[]>
val toListAsync: taskSeq: taskSeq<'a> -> Task<'a list>
val toResizeArrayAsync: taskSeq: taskSeq<'a> -> Task<ResizeArray<'a>>
val toIListAsync: taskSeq: taskSeq<'a> -> Task<IList<'a>>
val toSeqCachedAsync: taskSeq: taskSeq<'a> -> Task<seq<'a>>
val iter: action: ('a -> unit) -> taskSeq: taskSeq<'a> -> Task<unit>
val iteri: action: (int -> 'a -> unit) -> taskSeq: taskSeq<'a> -> Task<unit>
val iterAsync: action: ('a -> #Task<unit>) -> taskSeq: taskSeq<'a> -> Task<unit>
val iteriAsync: action: (int -> 'a -> #Task<unit>) -> taskSeq: taskSeq<'a> -> Task<unit>
val map: mapper: ('T -> 'U) -> taskSeq: taskSeq<'T> -> IAsyncEnumerable<'U>
val mapi: mapper: (int -> 'T -> 'U) -> taskSeq: taskSeq<'T> -> IAsyncEnumerable<'U>
val mapAsync: mapper: ('a -> #Task<'c>) -> taskSeq: taskSeq<'a> -> IAsyncEnumerable<'c>
val mapiAsync: mapper: (int -> 'a -> #Task<'c>) -> taskSeq: taskSeq<'a> -> IAsyncEnumerable<'c>
val collect: binder: ('T -> #IAsyncEnumerable<'U>) -> taskSeq: taskSeq<'T> -> IAsyncEnumerable<'U>
val collectSeq: binder: ('T -> #seq<'U>) -> taskSeq: taskSeq<'T> -> IAsyncEnumerable<'U>
val collectAsync: binder: ('T -> #Task<'b>) -> taskSeq: taskSeq<'T> -> taskSeq<'U> when 'b :> IAsyncEnumerable<'U>
val collectSeqAsync: binder: ('T -> #Task<'b>) -> taskSeq: taskSeq<'T> -> taskSeq<'U> when 'b :> seq<'U>
val zip: taskSeq1: taskSeq<'a> -> taskSeq2: taskSeq<'b> -> IAsyncEnumerable<'a * 'b>
val fold: folder: ('State -> 'T -> 'State) -> state: 'State -> taskSeq: IAsyncEnumerable<'T> -> Task<'State>
val foldAsync: folder: ('State -> 'T -> #Task<'State>) -> state: 'State -> taskSeq: IAsyncEnumerable<'T> -> Task<'State>
open System.Collections.Generic
open System.Threading.Tasks
open FSharpy.TaskSeqBuilders

/// Initialize an empty taskSeq.
val empty<'T> : taskSeq<'T>

/// Returns taskSeq as an array. This function is blocking until the sequence is exhausted and will properly dispose of the resources.
val toList: t: taskSeq<'T> -> 'T list

/// Returns taskSeq as an array. This function is blocking until the sequence is exhausted and will properly dispose of the resources.
val toArray: taskSeq: taskSeq<'T> -> 'T[]

/// Returns taskSeq as a seq, similar to Seq.cached. This function is blocking until the sequence is exhausted and will properly dispose of the resources.
val toSeqCached: taskSeq: taskSeq<'T> -> seq<'T>

/// Unwraps the taskSeq as a Task<array<_>>. This function is non-blocking.
val toArrayAsync: taskSeq: taskSeq<'T> -> Task<'T[]>

/// Unwraps the taskSeq as a Task<list<_>>. This function is non-blocking.
val toListAsync: taskSeq: taskSeq<'T> -> Task<'T list>

/// Unwraps the taskSeq as a Task<ResizeArray<_>>. This function is non-blocking.
val toResizeArrayAsync: taskSeq: taskSeq<'T> -> Task<ResizeArray<'T>>

/// Unwraps the taskSeq as a Task<IList<_>>. This function is non-blocking.
val toIListAsync: taskSeq: taskSeq<'T> -> Task<IList<'T>>

/// Unwraps the taskSeq as a Task<seq<_>>. This function is non-blocking,
/// exhausts the sequence and caches the results of the tasks in the sequence.
val toSeqCachedAsync: taskSeq: taskSeq<'T> -> Task<seq<'T>>

/// Create a taskSeq of an array.
val ofArray: array: 'T[] -> taskSeq<'T>

/// Create a taskSeq of a list.
val ofList: list: 'T list -> taskSeq<'T>

/// Create a taskSeq of a seq.
val ofSeq: sequence: seq<'T> -> taskSeq<'T>

/// Create a taskSeq of a ResizeArray, aka List.
val ofResizeArray: data: ResizeArray<'T> -> taskSeq<'T>

/// Create a taskSeq of a sequence of tasks, that may already have hot-started.
val ofTaskSeq: sequence: seq<#Task<'T>> -> taskSeq<'T>

/// Create a taskSeq of a list of tasks, that may already have hot-started.
val ofTaskList: list: #Task<'T> list -> taskSeq<'T>

/// Create a taskSeq of an array of tasks, that may already have hot-started.
val ofTaskArray: array: #Task<'T> array -> taskSeq<'T>

/// Create a taskSeq of a seq of async.
val ofAsyncSeq: sequence: seq<Async<'T>> -> taskSeq<'T>

/// Create a taskSeq of a list of async.
val ofAsyncList: list: Async<'T> list -> taskSeq<'T>

/// Create a taskSeq of an array of async.
val ofAsyncArray: array: Async<'T> array -> taskSeq<'T>

/// Iterates over the taskSeq applying the action function to each item. This function is non-blocking
/// exhausts the sequence as soon as the task is evaluated.
val iter: action: ('T -> unit) -> taskSeq: taskSeq<'T> -> Task<unit>

/// Iterates over the taskSeq applying the action function to each item. This function is non-blocking,
/// exhausts the sequence as soon as the task is evaluated.
val iteri: action: (int -> 'T -> unit) -> taskSeq: taskSeq<'T> -> Task<unit>

/// Iterates over the taskSeq applying the async action to each item. This function is non-blocking
/// exhausts the sequence as soon as the task is evaluated.
val iterAsync: action: ('T -> #Task<unit>) -> taskSeq: taskSeq<'T> -> Task<unit>

/// Iterates over the taskSeq, applying the async action to each item. This function is non-blocking,
/// exhausts the sequence as soon as the task is evaluated.
val iteriAsync: action: (int -> 'T -> #Task<unit>) -> taskSeq: taskSeq<'T> -> Task<unit>

/// Maps over the taskSeq, applying the mapper function to each item. This function is non-blocking.
val map: mapper: ('T -> 'U) -> taskSeq: taskSeq<'T> -> taskSeq<'U>

/// Maps over the taskSeq with an index, applying the mapper function to each item. This function is non-blocking.
val mapi: mapper: (int -> 'T -> 'U) -> taskSeq: taskSeq<'T> -> taskSeq<'U>

/// Maps over the taskSeq, applying the async mapper function to each item. This function is non-blocking.
val mapAsync: mapper: ('T -> #Task<'U>) -> taskSeq: taskSeq<'T> -> taskSeq<'U>

/// Maps over the taskSeq with an index, applying the async mapper function to each item. This function is non-blocking.
val mapiAsync: mapper: (int -> 'T -> #Task<'U>) -> taskSeq: taskSeq<'T> -> taskSeq<'U>

/// Applies the given function to the items in the taskSeq and concatenates all the results in order.
val collect: binder: ('T -> #taskSeq<'U>) -> taskSeq: taskSeq<'T> -> taskSeq<'U>

/// Applies the given function to the items in the taskSeq and concatenates all the results in order.
val collectSeq: binder: ('T -> #seq<'U>) -> taskSeq: taskSeq<'T> -> taskSeq<'U>

/// Applies the given async function to the items in the taskSeq and concatenates all the results in order.
val collectAsync: binder: ('T -> #Task<'TSeqU>) -> taskSeq: taskSeq<'T> -> taskSeq<'U> when 'TSeqU :> taskSeq<'U>

/// Applies the given async function to the items in the taskSeq and concatenates all the results in order.
val collectSeqAsync: binder: ('T -> #Task<'SeqU>) -> taskSeq: taskSeq<'T> -> taskSeq<'U> when 'SeqU :> seq<'U>

/// Zips two task sequences, returning a taskSeq of the tuples of each sequence, in order. May raise ArgumentException
/// if the sequences are or unequal length.
val zip: taskSeq1: taskSeq<'T> -> taskSeq2: taskSeq<'U> -> taskSeq<'T * 'U>

/// Applies a function to each element of the task sequence, threading an accumulator argument through the computation.
val fold: folder: ('State -> 'T -> 'State) -> state: 'State -> taskSeq: taskSeq<'T> -> Task<'State>

/// Applies an async function to each element of the task sequence, threading an accumulator argument through the computation.
val foldAsync: folder: ('State -> 'T -> #Task<'State>) -> state: 'State -> taskSeq: taskSeq<'T> -> Task<'State>
```
2 changes: 1 addition & 1 deletion src/FSharpy.TaskSeq.Test/TaskSeq.Collect.Tests.fs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
module FSharpy.TaskSeq.Tests.Collect
module FSharpy.Tests.Collect

open Xunit
open FsUnit.Xunit
Expand Down
2 changes: 1 addition & 1 deletion src/FSharpy.TaskSeq.Test/TaskSeq.Fold.Tests.fs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
module FSharpy.TaskSeq.Tests.Fold
module FSharpy.Tests.Fold

open System.Text
open Xunit
Expand Down
2 changes: 1 addition & 1 deletion src/FSharpy.TaskSeq.Test/TaskSeq.Iter.Tests.fs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
module FSharpy.TaskSeq.Tests.Iter
module FSharpy.Tests.Iter

open Xunit
open FsUnit.Xunit
Expand Down
2 changes: 1 addition & 1 deletion src/FSharpy.TaskSeq.Test/TaskSeq.Map.Tests.fs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
module FSharpy.TaskSeq.Tests.Map
module FSharpy.Tests.Map

open Xunit
open FsUnit.Xunit
Expand Down
2 changes: 1 addition & 1 deletion src/FSharpy.TaskSeq.Test/TaskSeq.OfXXX.Tests.fs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
module FSharpy.TaskSeq.Tests.``Conversion-From``
module FSharpy.Tests.``Conversion-From``

open Xunit
open FsUnit.Xunit
Expand Down
2 changes: 1 addition & 1 deletion src/FSharpy.TaskSeq.Test/TaskSeq.PocTests.fs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
namespace FSharpy.TaskSeq.Tests
namespace FSharpy.Tests

open Xunit
open FsUnit.Xunit
Expand Down
2 changes: 1 addition & 1 deletion src/FSharpy.TaskSeq.Test/TaskSeq.Tests.Utility.fs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
module FSharpy.TaskSeq.Tests.``Utility functions``
module FSharpy.Tests.``Utility functions``

open Xunit
open FsUnit.Xunit
Expand Down
2 changes: 1 addition & 1 deletion src/FSharpy.TaskSeq.Test/TaskSeq.Tests.fs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
module FSharpy.TaskSeq.Tests.``taskSeq Computation Expression``
module FSharpy.Tests.``taskSeq Computation Expression``

open Xunit
open FsUnit.Xunit
Expand Down
2 changes: 1 addition & 1 deletion src/FSharpy.TaskSeq.Test/TaskSeq.ToXXX.Tests.fs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
module FSharpy.TaskSeq.Tests.``Conversion-To``
module FSharpy.Tests.``Conversion-To``

open Xunit
open FsUnit.Xunit
Expand Down
2 changes: 1 addition & 1 deletion src/FSharpy.TaskSeq.Test/TestUtils.fs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
namespace FSharpy.TaskSeq.Tests
namespace FSharpy.Tests

open System
open System.Threading
Expand Down
9 changes: 9 additions & 0 deletions src/FSharpy.TaskSeq/FSharpy.TaskSeq.fsproj
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,19 @@
<GenerateDocumentationFile>true</GenerateDocumentationFile>
</PropertyGroup>

<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|AnyCPU'">
<OtherFlags></OtherFlags>
</PropertyGroup>

<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|AnyCPU'">
<OtherFlags></OtherFlags>
</PropertyGroup>

<ItemGroup>
<Compile Include="Utils.fs" />
<Compile Include="TaskSeqBuilder.fs" />
<Compile Include="TaskSeqInternal.fs" />
<Compile Include="TaskSeq.fsi" />
<Compile Include="TaskSeq.fs" />
</ItemGroup>

Expand Down
114 changes: 114 additions & 0 deletions src/FSharpy.TaskSeq/TaskSeq.fsi
Original file line number Diff line number Diff line change
@@ -0,0 +1,114 @@
namespace FSharpy

module TaskSeq =
open System.Collections.Generic
open System.Threading.Tasks
open FSharpy.TaskSeqBuilders

/// Initialize an empty taskSeq.
val empty<'T> : taskSeq<'T>

/// Returns taskSeq as an array. This function is blocking until the sequence is exhausted and will properly dispose of the resources.
val toList: t: taskSeq<'T> -> 'T list

/// Returns taskSeq as an array. This function is blocking until the sequence is exhausted and will properly dispose of the resources.
val toArray: taskSeq: taskSeq<'T> -> 'T[]

/// Returns taskSeq as a seq, similar to Seq.cached. This function is blocking until the sequence is exhausted and will properly dispose of the resources.
val toSeqCached: taskSeq: taskSeq<'T> -> seq<'T>

/// Unwraps the taskSeq as a Task<array<_>>. This function is non-blocking.
val toArrayAsync: taskSeq: taskSeq<'T> -> Task<'T[]>

/// Unwraps the taskSeq as a Task<list<_>>. This function is non-blocking.
val toListAsync: taskSeq: taskSeq<'T> -> Task<'T list>

/// Unwraps the taskSeq as a Task<ResizeArray<_>>. This function is non-blocking.
val toResizeArrayAsync: taskSeq: taskSeq<'T> -> Task<ResizeArray<'T>>

/// Unwraps the taskSeq as a Task<IList<_>>. This function is non-blocking.
val toIListAsync: taskSeq: taskSeq<'T> -> Task<IList<'T>>

/// Unwraps the taskSeq as a Task<seq<_>>. This function is non-blocking,
/// exhausts the sequence and caches the results of the tasks in the sequence.
val toSeqCachedAsync: taskSeq: taskSeq<'T> -> Task<seq<'T>>

/// Create a taskSeq of an array.
val ofArray: array: 'T[] -> taskSeq<'T>

/// Create a taskSeq of a list.
val ofList: list: 'T list -> taskSeq<'T>

/// Create a taskSeq of a seq.
val ofSeq: sequence: seq<'T> -> taskSeq<'T>

/// Create a taskSeq of a ResizeArray, aka List.
val ofResizeArray: data: ResizeArray<'T> -> taskSeq<'T>

/// Create a taskSeq of a sequence of tasks, that may already have hot-started.
val ofTaskSeq: sequence: seq<#Task<'T>> -> taskSeq<'T>

/// Create a taskSeq of a list of tasks, that may already have hot-started.
val ofTaskList: list: #Task<'T> list -> taskSeq<'T>

/// Create a taskSeq of an array of tasks, that may already have hot-started.
val ofTaskArray: array: #Task<'T> array -> taskSeq<'T>

/// Create a taskSeq of a seq of async.
val ofAsyncSeq: sequence: seq<Async<'T>> -> taskSeq<'T>

/// Create a taskSeq of a list of async.
val ofAsyncList: list: Async<'T> list -> taskSeq<'T>

/// Create a taskSeq of an array of async.
val ofAsyncArray: array: Async<'T> array -> taskSeq<'T>

/// Iterates over the taskSeq applying the action function to each item. This function is non-blocking
/// exhausts the sequence as soon as the task is evaluated.
val iter: action: ('T -> unit) -> taskSeq: taskSeq<'T> -> Task<unit>

/// Iterates over the taskSeq applying the action function to each item. This function is non-blocking,
/// exhausts the sequence as soon as the task is evaluated.
val iteri: action: (int -> 'T -> unit) -> taskSeq: taskSeq<'T> -> Task<unit>

/// Iterates over the taskSeq applying the async action to each item. This function is non-blocking
/// exhausts the sequence as soon as the task is evaluated.
val iterAsync: action: ('T -> #Task<unit>) -> taskSeq: taskSeq<'T> -> Task<unit>

/// Iterates over the taskSeq, applying the async action to each item. This function is non-blocking,
/// exhausts the sequence as soon as the task is evaluated.
val iteriAsync: action: (int -> 'T -> #Task<unit>) -> taskSeq: taskSeq<'T> -> Task<unit>

/// Maps over the taskSeq, applying the mapper function to each item. This function is non-blocking.
val map: mapper: ('T -> 'U) -> taskSeq: taskSeq<'T> -> taskSeq<'U>

/// Maps over the taskSeq with an index, applying the mapper function to each item. This function is non-blocking.
val mapi: mapper: (int -> 'T -> 'U) -> taskSeq: taskSeq<'T> -> taskSeq<'U>

/// Maps over the taskSeq, applying the async mapper function to each item. This function is non-blocking.
val mapAsync: mapper: ('T -> #Task<'U>) -> taskSeq: taskSeq<'T> -> taskSeq<'U>

/// Maps over the taskSeq with an index, applying the async mapper function to each item. This function is non-blocking.
val mapiAsync: mapper: (int -> 'T -> #Task<'U>) -> taskSeq: taskSeq<'T> -> taskSeq<'U>

/// Applies the given function to the items in the taskSeq and concatenates all the results in order.
val collect: binder: ('T -> #taskSeq<'U>) -> taskSeq: taskSeq<'T> -> taskSeq<'U>

/// Applies the given function to the items in the taskSeq and concatenates all the results in order.
val collectSeq: binder: ('T -> #seq<'U>) -> taskSeq: taskSeq<'T> -> taskSeq<'U>

/// Applies the given async function to the items in the taskSeq and concatenates all the results in order.
val collectAsync: binder: ('T -> #Task<'TSeqU>) -> taskSeq: taskSeq<'T> -> taskSeq<'U> when 'TSeqU :> taskSeq<'U>

/// Applies the given async function to the items in the taskSeq and concatenates all the results in order.
val collectSeqAsync: binder: ('T -> #Task<'SeqU>) -> taskSeq: taskSeq<'T> -> taskSeq<'U> when 'SeqU :> seq<'U>

/// Zips two task sequences, returning a taskSeq of the tuples of each sequence, in order. May raise ArgumentException
/// if the sequences are or unequal length.
val zip: taskSeq1: taskSeq<'T> -> taskSeq2: taskSeq<'U> -> taskSeq<'T * 'U>

/// Applies a function to each element of the task sequence, threading an accumulator argument through the computation.
val fold: folder: ('State -> 'T -> 'State) -> state: 'State -> taskSeq: taskSeq<'T> -> Task<'State>

/// Applies an async function to each element of the task sequence, threading an accumulator argument through the computation.
val foldAsync: folder: ('State -> 'T -> #Task<'State>) -> state: 'State -> taskSeq: taskSeq<'T> -> Task<'State>