Type 'Async <string []>' is not compatible with type 'seq <' a> '

I have a variable mySources , seq<Async <string []>> . My goal is to smooth the sequence and combine all the elements in the sequence in one Async<string []>

I am using the Seq.collect method.

let myJoinedAsyncs = Seq.collect (fun elems -> elems) mySources

But this line gives me an error on mySource indicating that:

type "Async" is not compatible with type "seq <" a> '

Any ideas? Thanks!

+5
source share
1 answer

You can use Async.Parallel to collect internal values ​​and concat the resulting sequences:

 let flattenAsync (asyncs : seq<Async<'a []>>) = async { let! ss = Async.Parallel asyncs return Array.concat ss } 
+5
source

Source: https://habr.com/ru/post/1261062/


All Articles