Given the following (simplified) F# asynchronous code, to partition items coming from an asyncSeq
open FSharp.Control
let s : AsyncSeq<'t> = ...
let a =
s
|> AsyncSeq.mapi (fun i a -> (i, a))
|> AsyncSeq.groupBy (fun (i, _) -> int(i) % 3)
|> AsyncSeq.map (fun (index, tWithIndex) -> (index + 1, tWithIndex |> AsyncSeq.map (fun (_, t) -> t)))
|> AsyncSeq.toArraySynchronously
|> Map.ofArray
|> Map.map (fun i a -> a |> AsyncSeq.toArraySynchronously)
let b =
s
|> AsyncSeq.mapi (fun i a -> (i, a))
|> AsyncSeq.groupBy (fun (i, _) -> int(i) % 3)
|> AsyncSeq.map (fun (index, tWithIndex) -> index + 1, AsyncSeq.toArraySynchronously tWithIndex |> Array.map (fun (_, t) -> t))
|> AsyncSeq.toArraySynchronously
|> Map.ofArray
I was expecting a and b to contain the same Map<int, 't[]> value, but b calculation never completes, it gets stuck. What's wrong with b's expression?