fsprojects / FSharp.Control.AsyncSeq

Asynchronous sequences for F#
https://fsprojects.github.io/FSharp.Control.AsyncSeq/
Other
161 stars 59 forks source link

choose does not work for async seq generated using AsyncSeq.unfold #63

Closed denskh closed 7 years ago

denskh commented 7 years ago

Description

When async seq is generated using AsyncSeq.unfold method choose only returns elements until first exclusion (None).

Repro steps

let chooser x = if x % 3 = 0 then None else Some x let inputLst = [ 1 .. 9 ] let expected = inputLst |> Seq.choose chooser |> Seq.toList // expected is [1; 2; 4; 5; 7; 8] let inputASeq = AsyncSeq.unfold (fun i -> if i <= 9 then Some (i,i+1) else None) 1 let actual = inputASeq |> AsyncSeq.choose chooser |> AsyncSeq.toList // actual is [1; 2]

Expected behavior

Both should return [1; 2; 4; 5; 7; 8]

Actual behavior

AsyncSeq.choose returns [1; 2]

Known workarounds

Use map & filter for sequences generated using AsyncSeq.unfold

Related information

eulerfx commented 7 years ago

This looks like a bug. Thanks! Will work on a fix.

eulerfx commented 7 years ago

Fixed in https://www.nuget.org/packages/FSharp.Control.AsyncSeq/2.0.12

denskh commented 7 years ago

Works, thanks for a quick fix!