Skip to content

Instantly share code, notes, and snippets.

@hodzanassredin
Last active August 29, 2015 14:02
Show Gist options
  • Save hodzanassredin/51c182bfb497453f6c57 to your computer and use it in GitHub Desktop.
Save hodzanassredin/51c182bfb497453f6c57 to your computer and use it in GitHub Desktop.
unwrap seq of asyncs into async seq
let! results = todo |> Seq.map (fun (name, param, sql) -> (name, db.ExecuteAsync conn param sql))
|> Seq.fold (fun (asyncAcc:Async<seq<string*Result<int>>>) (name,asyncTask) -> async{
let! acc = asyncAcc
let! taskRes = asyncTask
return seq {yield! acc; yield (name, taskRes)}
}) (async {return Seq.empty})
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment