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
Operating system
Windows 7
Branch
master
Database versions and sample databases being used
.NET Runtime, CoreCLR or Mono Version
VS2015 F# interactive
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