I have a mySources
variable, seq<Async <string []>>
. My aim is to flatten the sequence and join all elements in a sequence, in a single Async<string []>
I am using Seq.collect
method.
let myJoinedAsyncs = Seq.collect (fun elems -> elems) mySources
But this line gives me an error on mySource indicating that:
the type 'Async' is not compatible with the type 'seq<'a>'
Any ideas? Thanks!
You can use Async.Parallel
to collect the inner values and concat the resulting sequences:
let flattenAsync (asyncs : seq<Async<'a []>>) = async {
let! ss = Async.Parallel asyncs
return Array.concat ss
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With