From 9648926431399587847b8c4fb8612a51e02d863e Mon Sep 17 00:00:00 2001 From: Abel Braaksma Date: Thu, 24 Nov 2022 16:31:02 +0100 Subject: [PATCH] Remove `invalidArg` exception from `TaskSeq.zip` --- .../TaskSeq.Zip.Tests.fs | 29 ------------------- .../FSharp.Control.TaskSeq.fsproj | 2 ++ src/FSharp.Control.TaskSeq/TaskSeqInternal.fs | 11 ------- 3 files changed, 2 insertions(+), 40 deletions(-) diff --git a/src/FSharp.Control.TaskSeq.Test/TaskSeq.Zip.Tests.fs b/src/FSharp.Control.TaskSeq.Test/TaskSeq.Zip.Tests.fs index 2d0b2f12..1206d74c 100644 --- a/src/FSharp.Control.TaskSeq.Test/TaskSeq.Zip.Tests.fs +++ b/src/FSharp.Control.TaskSeq.Test/TaskSeq.Zip.Tests.fs @@ -132,32 +132,3 @@ module Other = combined |> should equal [| ("one", 42L); ("two", 43L) |] } - - [] - let ``TaskSeq-zip throws on unequal lengths, variant`` leftThrows = task { - let long = Gen.sideEffectTaskSeq 11 - let short = Gen.sideEffectTaskSeq 10 - - let combined = - if leftThrows then - TaskSeq.zip short long - else - TaskSeq.zip long short - - fun () -> TaskSeq.toArrayAsync combined |> Task.ignore - |> should throwAsyncExact typeof - } - - [] - let ``TaskSeq-zip throws on unequal lengths with empty seq`` leftThrows = task { - let one = Gen.sideEffectTaskSeq 1 - - let combined = - if leftThrows then - TaskSeq.zip TaskSeq.empty one - else - TaskSeq.zip one TaskSeq.empty - - fun () -> TaskSeq.toArrayAsync combined |> Task.ignore - |> should throwAsyncExact typeof - } diff --git a/src/FSharp.Control.TaskSeq/FSharp.Control.TaskSeq.fsproj b/src/FSharp.Control.TaskSeq/FSharp.Control.TaskSeq.fsproj index d0298601..260225ff 100644 --- a/src/FSharp.Control.TaskSeq/FSharp.Control.TaskSeq.fsproj +++ b/src/FSharp.Control.TaskSeq/FSharp.Control.TaskSeq.fsproj @@ -23,6 +23,8 @@ Generates optimized IL code through the new resumable state machines, and comes nuget-package-readme.md Release notes: + 0.2.3 + - do not throw exception for unequal lengths in TaskSeq.zip, fixes #32 0.2.2 - removes TaskSeq.toSeqCachedAsync, which was incorrectly named. Use toSeq or toListAsync instead. - renames TaskSeq.toSeqCached to TaskSeq.toSeq, which was its actual operational behavior. diff --git a/src/FSharp.Control.TaskSeq/TaskSeqInternal.fs b/src/FSharp.Control.TaskSeq/TaskSeqInternal.fs index 7779429a..a6499178 100644 --- a/src/FSharp.Control.TaskSeq/TaskSeqInternal.fs +++ b/src/FSharp.Control.TaskSeq/TaskSeqInternal.fs @@ -272,28 +272,17 @@ module internal TaskSeqInternal = } let zip (source1: taskSeq<_>) (source2: taskSeq<_>) = taskSeq { - let inline validate step1 step2 = - if step1 <> step2 then - if step1 then - invalidArg "taskSequence1" "The task sequences have different lengths." - - if step2 then - invalidArg "taskSequence2" "The task sequences have different lengths." - - use e1 = source1.GetAsyncEnumerator(CancellationToken()) use e2 = source2.GetAsyncEnumerator(CancellationToken()) let mutable go = true let! step1 = e1.MoveNextAsync() let! step2 = e2.MoveNextAsync() go <- step1 && step2 - validate step1 step2 while go do yield e1.Current, e2.Current let! step1 = e1.MoveNextAsync() let! step2 = e2.MoveNextAsync() - validate step1 step2 go <- step1 && step2 }