Skip to content

Xml doc comment cleanup #220

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 19 commits into from
Closed
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
5 changes: 5 additions & 0 deletions src/FSharp.Control.TaskSeq.sln.DotSettings
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
<wpf:ResourceDictionary xml:space="preserve" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" xmlns:s="clr-namespace:System;assembly=mscorlib" xmlns:ss="urn:shemas-jetbrains-com:settings-storage-xaml" xmlns:wpf="http://schemas.microsoft.com/winfx/2006/xaml/presentation">
<s:Boolean x:Key="/Default/UserDictionary/Words/=infinitum/@EntryIndexedValue">True</s:Boolean>
<s:Boolean x:Key="/Default/UserDictionary/Words/=iteri/@EntryIndexedValue">True</s:Boolean>
<s:Boolean x:Key="/Default/UserDictionary/Words/=taskseqs/@EntryIndexedValue">True</s:Boolean>
<s:Boolean x:Key="/Default/UserDictionary/Words/=typeref/@EntryIndexedValue">True</s:Boolean></wpf:ResourceDictionary>
8 changes: 3 additions & 5 deletions src/FSharp.Control.TaskSeq/TaskSeq.fs
Original file line number Diff line number Diff line change
Expand Up @@ -314,15 +314,15 @@ type TaskSeq private () =

static member exists predicate source =
Internal.tryFind (Predicate predicate) source
|> Task.map (Option.isSome)
|> Task.map Option.isSome

static member existsAsync predicate source =
Internal.tryFind (PredicateAsync predicate) source
|> Task.map (Option.isSome)
|> Task.map Option.isSome

static member contains value source =
Internal.tryFind (Predicate((=) value)) source
|> Task.map (Option.isSome)
|> Task.map Option.isSome

static member pick chooser source =
Internal.tryPick (TryPick chooser) source
Expand All @@ -348,8 +348,6 @@ type TaskSeq private () =
Internal.tryFindIndex (PredicateAsync predicate) source
|> Task.map (Option.defaultWith Internal.raiseNotFound)



//
// zip/unzip/fold etc functions
//
Expand Down
56 changes: 29 additions & 27 deletions src/FSharp.Control.TaskSeq/TaskSeq.fsi
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@ type TaskSeq =

/// <summary>
/// Generates a new task sequence which, when iterated, will return successive elements by calling the given function
/// with the curren zero-basedt index, up to the given count. Each element is saved after its initialization for successive access to
/// with the current zero-based index, up to the given count. Each element is saved after its initialization for successive access to
/// <see cref="IAsyncEnumerator.Current" />, which will not re-evaluate the <paramref name="initializer" />. However,
/// re-iterating the returned task sequence will re-evaluate the initialization function. The returned sequence may
/// be passed between threads safely. However, individual IEnumerator values generated from the returned sequence should
Expand Down Expand Up @@ -454,58 +454,58 @@ type TaskSeq =
static member indexed: source: TaskSeq<'T> -> TaskSeq<int * 'T>

/// <summary>
/// Builds a new task sequence whose elements are the results of applying the <paramref name="action" />
/// Builds a new task sequence whose elements are the results of applying the <paramref name="mapper" />
/// function to each of the elements of the input task sequence in <paramref name="source" />.
/// The given function will be applied as elements are pulled using the <see cref="MoveNextAsync" />
/// method on async enumerators retrieved from the input task sequence.
/// Does not evaluate the input sequence until requested.
/// </summary>
///
/// <param name="mapping">A function to transform items from the input task sequence.</param>
/// <param name="mapper">A function to transform items from the input task sequence.</param>
/// <param name="source">The input task sequence.</param>
/// <returns>The resulting task sequence.</returns>
/// <exception cref="T:ArgumentNullException">Thrown when the input task sequence is null.</exception>
static member map: mapper: ('T -> 'U) -> source: TaskSeq<'T> -> TaskSeq<'U>

/// <summary>
/// Builds a new task sequence whose elements are the results of applying the <paramref name="action" />
/// Builds a new task sequence whose elements are the results of applying the <paramref name="mapper" />
/// function to each of the elements of the input task sequence in <paramref name="source" />, passing
/// an extra zero-based index argument to the <paramref name="action" /> function.
/// an extra zero-based index argument to the <paramref name="mapper" /> function.
/// The given function will be applied as elements are pulled using the <see cref="MoveNextAsync" />
/// method on async enumerators retrieved from the input task sequence.
/// Does not evaluate the input sequence until requested.
/// </summary>
///
/// <param name="mapping">A function to transform items from the input task sequence that also access the current index.</param>
/// <param name="mapper">A function to transform items from the input task sequence that also access the current index.</param>
/// <param name="source">The input task sequence.</param>
/// <returns>The resulting task sequence.</returns>
/// <exception cref="T:ArgumentNullException">Thrown when the input task sequence is null.</exception>
static member mapi: mapper: (int -> 'T -> 'U) -> source: TaskSeq<'T> -> TaskSeq<'U>

/// <summary>
/// Builds a new task sequence whose elements are the results of applying the asynchronous <paramref name="action" />
/// Builds a new task sequence whose elements are the results of applying the asynchronous <paramref name="mapper" />
/// function to each of the elements of the input task sequence in <paramref name="source" />.
/// The given function will be applied as elements are pulled using the <see cref="MoveNextAsync" />
/// method on async enumerators retrieved from the input task sequence.
/// Does not evaluate the input sequence until requested.
/// </summary>
///
/// <param name="mapping">An asynchronous function to transform items from the input task sequence.</param>
/// <param name="mapper">An asynchronous function to transform items from the input task sequence.</param>
/// <param name="source">The input task sequence.</param>
/// <returns>The resulting task sequence.</returns>
/// <exception cref="T:ArgumentNullException">Thrown when the input task sequence is null.</exception>
static member mapAsync: mapper: ('T -> #Task<'U>) -> source: TaskSeq<'T> -> TaskSeq<'U>

/// <summary>
/// Builds a new task sequence whose elements are the results of applying the asynchronous <paramref name="action" />
/// Builds a new task sequence whose elements are the results of applying the asynchronous <paramref name="mapper" />
/// function to each of the elements of the input task sequence in <paramref name="source" />, passing
/// an extra zero-based index argument to the <paramref name="action" /> function.
/// an extra zero-based index argument to the <paramref name="mapper" /> function.
/// The given function will be applied as elements are pulled using the <see cref="MoveNextAsync" />
/// method on async enumerators retrieved from the input task sequence.
/// Does not evaluate the input sequence until requested.
/// </summary>
///
/// <param name="mapping">An asynchronous function to transform items from the input task sequence that also access the current index.</param>
/// <param name="mapper">An asynchronous function to transform items from the input task sequence that also access the current index.</param>
/// <param name="source">The input task sequence.</param>
/// <returns>The resulting task sequence.</returns>
/// <exception cref="T:ArgumentNullException">Thrown when the input task sequence is null.</exception>
Expand Down Expand Up @@ -640,6 +640,7 @@ type TaskSeq =
/// </summary>
///
/// <param name="source">The input task sequence.</param>
/// <param name="index">The index of the item to retrieve.</param>
/// <returns>The nth element of the task sequence, or None if it doesn't exist.</returns>
/// <exception cref="T:ArgumentNullException">Thrown when the input task sequence is null.</exception>
static member tryItem: index: int -> source: TaskSeq<'T> -> Task<'T option>
Expand All @@ -651,6 +652,7 @@ type TaskSeq =
/// </summary>
///
/// <param name="source">The input task sequence.</param>
/// <param name="index">The index of the item to retrieve.</param>
/// <returns>The nth element of the task sequence.</returns>
/// <exception cref="T:ArgumentNullException">Thrown when the input task sequence is null.</exception>
/// <exception cref="T:ArgumentException">Thrown when the sequence has insufficient length or <paramref name="index" /> is negative.</exception>
Expand Down Expand Up @@ -818,7 +820,7 @@ type TaskSeq =
/// <summary>
/// Returns a task sequence that, when iterated, yields elements of the underlying sequence while the
/// given function <paramref name="predicate" /> returns <see cref="true" />, and then returns no further elements.
/// The first element where the predicate returns <see cref="false" /> is not included in the resulting sequence
/// Stops consuming the source and yielding items as soon as the predicate returns <c>false</c>.
/// (see also <see cref="TaskSeq.takeWhileInclusive" />).
/// If <paramref name="predicate" /> is asynchronous, consider using <see cref="TaskSeq.takeWhileAsync" />.
/// </summary>
Expand All @@ -832,7 +834,7 @@ type TaskSeq =
/// <summary>
/// Returns a task sequence that, when iterated, yields elements of the underlying sequence while the
/// given asynchronous function <paramref name="predicate" /> returns <see cref="true" />, and then returns no further elements.
/// The first element where the predicate returns <see cref="false" /> is not included in the resulting sequence
/// Stops consuming the source and yielding items as soon as the predicate returns <c>false</c>.
/// (see also <see cref="TaskSeq.takeWhileInclusiveAsync" />).
/// If <paramref name="predicate" /> is synchronous, consider using <see cref="TaskSeq.takeWhile" />.
/// </summary>
Expand Down Expand Up @@ -874,8 +876,8 @@ type TaskSeq =
/// <summary>
/// Returns a task sequence that, when iterated, skips elements of the underlying sequence while the
/// given function <paramref name="predicate" /> returns <see cref="true" />, and then yields the remaining
/// elements. The first element where the predicate returns <see cref="false" /> is returned, which means that this
/// function will skip 0 or more elements (see also <see cref="TaskSeq.skipWhileInclusive" />).
/// elements. Elements where the predicate returns <see cref="false" /> are propagated, which means that this
/// function may not skip any elements (see also <see cref="TaskSeq.skipWhileInclusive" />).
/// If <paramref name="predicate" /> is asynchronous, consider using <see cref="TaskSeq.skipWhileAsync" />.
/// </summary>
///
Expand All @@ -888,8 +890,8 @@ type TaskSeq =
/// <summary>
/// Returns a task sequence that, when iterated, skips elements of the underlying sequence while the
/// given asynchronous function <paramref name="predicate" /> returns <see cref="true" />, and then yields the
/// remaining elements. The first element where the predicate returns <see cref="false" /> is returned, which
/// means that this function will skip 0 or more elements (see also <see cref="TaskSeq.skipWhileInclusiveAsync" />).
/// remaining elements. Elements where the predicate returns <see cref="false" /> are propagated, which means that this
/// function may not skip any elements (see also <see cref="TaskSeq.skipWhileInclusiveAsync" />).
/// If <paramref name="predicate" /> is synchronous, consider using <see cref="TaskSeq.skipWhile" />.
/// </summary>
///
Expand All @@ -901,27 +903,27 @@ type TaskSeq =

/// <summary>
/// Returns a task sequence that, when iterated, skips elements of the underlying sequence until the given
/// function <paramref name="predicate" /> returns <see cref="false" />, also skips that element
/// and then yields the remaining elements (see also <see cref="TaskSeq.skipWhile" />). This function skips
/// function <paramref name="predicate" /> returns <see cref="false" />, <i>also skips that element</i>
/// and then yields the remaining elements (see also <see cref="TaskSeq.skipWhile" />). It will thus always skip
/// at least one element of a non-empty sequence, or returns the empty task sequence if the input is empty.
/// If <paramref name="predicate" /> is asynchronous, consider using <see cref="TaskSeq.skipWhileInclusiveAsync" />.
/// </summary>`
///
/// <param name="predicate">A function that evaluates to false when no more items should be skipped.</param>
/// <param name="predicate">A function that evaluates to false for the final item to be skipped.</param>
/// <param name="source">The input task sequence.</param>
/// <returns>The resulting task sequence.</returns>
/// <exception cref="T:ArgumentNullException">Thrown when the input task sequence is null.</exception>
static member skipWhileInclusive: predicate: ('T -> bool) -> source: TaskSeq<'T> -> TaskSeq<'T>

/// <summary>
/// Returns a task sequence that, when iterated, skips elements of the underlying sequence until the given
/// function <paramref name="predicate" /> returns <see cref="false" />, also skips that element
/// and then yields the remaining elements (see also <see cref="TaskSeq.skipWhileAsync" />). This function skips
/// function <paramref name="predicate" /> returns <see cref="false" />, <i>also skips that element</i>
/// and then yields the remaining elements (see also <see cref="TaskSeq.skipWhileAsync" />). It will thus always skip
/// at least one element of a non-empty sequence, or returns the empty task sequence if the input is empty.
/// If <paramref name="predicate" /> is synchronous, consider using <see cref="TaskSeq.skipWhileInclusive" />.
/// </summary>
///
/// <param name="predicate">An asynchronous function that evaluates to false when no more items should be skipped.</param>
/// <param name="predicate">An asynchronous function that evaluates to false for the final item to be skipped.</param>
/// <param name="source">The input task sequence.</param>
/// <returns>The resulting task sequence.</returns>
/// <exception cref="T:ArgumentNullException">Thrown when the input task sequence is null.</exception>
Expand Down Expand Up @@ -1163,8 +1165,8 @@ type TaskSeq =

/// <summary>
/// Applies the function <paramref name="folder" /> to each element in the task sequence, threading an accumulator
/// argument of type <typeref name="'State" /> through the computation. If the input function is <paramref name="f" /> and the elements are <paramref name="i0...iN" />
/// then computes <paramref name="f (... (f s i0)...) iN" />.
/// argument of type <typeref name="'State" /> through the computation. If the input function is <code>f</code> and the elements are <code>i0...iN</code>
/// then computes <code>f (... (f s i0)...) iN</code>.
/// If the accumulator function <paramref name="folder" /> is asynchronous, consider using <see cref="TaskSeq.foldAsync" />.
/// </summary>
///
Expand All @@ -1177,8 +1179,8 @@ type TaskSeq =

/// <summary>
/// Applies the asynchronous function <paramref name="folder" /> to each element in the task sequence, threading an accumulator
/// argument of type <typeref name="'State" /> through the computation. If the input function is <paramref name="f" /> and the elements are <paramref name="i0...iN" />
/// then computes <paramref name="f (... (f s i0)...) iN" />.
/// argument of type <typeref name="'State" /> through the computation. If the input function is <code>f</code> and the elements are <code>i0...iN</code>
/// then computes <code>f (... (f s i0)...) iN</code>.
/// If the accumulator function <paramref name="folder" /> is synchronous, consider using <see cref="TaskSeq.fold" />.
/// </summary>
///
Expand Down
72 changes: 71 additions & 1 deletion src/FSharp.Control.TaskSeq/TaskSeqInternal.fs
Original file line number Diff line number Diff line change
Expand Up @@ -163,7 +163,6 @@ module internal TaskSeqInternal =
checkNonNull (nameof source) source

task {

use e = source.GetAsyncEnumerator CancellationToken.None
let mutable go = true
let mutable i = 0
Expand All @@ -178,6 +177,77 @@ module internal TaskSeqInternal =
return i
}

let inline maxMin ([<InlineIfLambda>] maxOrMin) (source: TaskSeq<_>) =
checkNonNull (nameof source) source

task {
use e = source.GetAsyncEnumerator CancellationToken.None
let! nonEmpty = e.MoveNextAsync()

if not nonEmpty then
raiseEmptySeq ()

let mutable acc = e.Current

while! e.MoveNextAsync() do
acc <- maxOrMin e.Current acc

return acc
}

// 'compare' is either `<` or `>` (i.e, less-than, greater-than resp.)
let inline maxMinBy ([<InlineIfLambda>] compare) ([<InlineIfLambda>] projection) (source: TaskSeq<_>) =
checkNonNull (nameof source) source

task {
use e = source.GetAsyncEnumerator CancellationToken.None
let! nonEmpty = e.MoveNextAsync()

if not nonEmpty then
raiseEmptySeq ()

let value = e.Current
let mutable accProjection = projection value
let mutable accValue = value

while! e.MoveNextAsync() do
let value = e.Current
let currentProjection = projection value

if compare accProjection currentProjection then
accProjection <- currentProjection
accValue <- value

return accValue
}

// 'compare' is either `<` or `>` (i.e, less-than, greater-than resp.)
let inline maxMinByAsync ([<InlineIfLambda>] compare) ([<InlineIfLambda>] projectionAsync) (source: TaskSeq<_>) =
checkNonNull (nameof source) source

task {
use e = source.GetAsyncEnumerator CancellationToken.None
let! nonEmpty = e.MoveNextAsync()

if not nonEmpty then
raiseEmptySeq ()

let value = e.Current
let! projValue = projectionAsync value
let mutable accProjection = projValue
let mutable accValue = value

while! e.MoveNextAsync() do
let value = e.Current
let! currentProjection = projectionAsync value

if compare accProjection currentProjection then
accProjection <- currentProjection
accValue <- value

return accValue
}

let tryExactlyOne (source: TaskSeq<_>) =
checkNonNull (nameof source) source

Expand Down