From 47244677bf51a386502ef362ce5d675d06cb0194 Mon Sep 17 00:00:00 2001 From: "github-actions[bot]" Date: Sat, 21 Feb 2026 02:57:57 +0000 Subject: [PATCH] Allow AsyncSeq.mergeAll to accept seq instead of list Widen the parameter type of AsyncSeq.mergeAll from 'AsyncSeq<'T> list' to 'seq>'. This is backward-compatible since list implements seq in F#, but also allows callers to pass arrays, other collections, or lazy sequences without needing an explicit conversion. The implementation materialises the seq to an array immediately since random-access (indexed look-up) and Length are needed internally. Closes #165 Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> --- src/FSharp.Control.AsyncSeq/AsyncSeq.fs | 3 ++- src/FSharp.Control.AsyncSeq/AsyncSeq.fsi | 2 +- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/src/FSharp.Control.AsyncSeq/AsyncSeq.fs b/src/FSharp.Control.AsyncSeq/AsyncSeq.fs index f749ea7b..6ec35694 100644 --- a/src/FSharp.Control.AsyncSeq/AsyncSeq.fs +++ b/src/FSharp.Control.AsyncSeq/AsyncSeq.fs @@ -1700,8 +1700,9 @@ module AsyncSeq = /// Merges all specified async sequences into an async sequence non-deterministically. // By moving the last emitted task to the end of the array, this algorithm achieves max-min fairness when merging AsyncSeqs - let mergeAll (ss:AsyncSeq<'T> list) : AsyncSeq<'T> = + let mergeAll (ss:seq>) : AsyncSeq<'T> = asyncSeq { + let ss = Seq.toArray ss let n = ss.Length let moveToEnd i (a: 'a[]) = diff --git a/src/FSharp.Control.AsyncSeq/AsyncSeq.fsi b/src/FSharp.Control.AsyncSeq/AsyncSeq.fsi index 15c1bf56..78504ea9 100644 --- a/src/FSharp.Control.AsyncSeq/AsyncSeq.fsi +++ b/src/FSharp.Control.AsyncSeq/AsyncSeq.fsi @@ -502,7 +502,7 @@ module AsyncSeq = /// Merges all specified async sequences into an async sequence non-deterministically. /// The resulting async sequence produces elements when any argument sequence produces an element. - val mergeAll : sources:AsyncSeq<'T> list -> AsyncSeq<'T> + val mergeAll : sources:seq> -> AsyncSeq<'T> #endif /// Returns an async sequence which contains no contiguous duplicate elements based on the specified comparison function.