Anthony Nichols
Anthony Nichols

Reputation: 1658

F# Expected type List but here has type []

I am running my data through this:

myData |> List.map(myAsyncMethod) |> Async.Parallel |> Async.RunSynchronously

myData is: MyDataType list and that is what I am expecting back, but instead I am getting [] (which I thought was a list)...

Anyway, I somehow need to convert type [] back into a list, or fix my function to return list... or swap out my datatype to be compatible with [].

Any answer will do, I just need it to work (as efficiently as possible).

Upvotes: 0

Views: 161

Answers (1)

John Palmer
John Palmer

Reputation: 25516

Async.Parallel will create an output which is an array.

This makes sense because you need to pre allocate some space to return the result, which you cant do with a list.

You can just use Array.toList to convert to a list at the end

Upvotes: 4

Related Questions